Removed symlinks to SDL 1.3 files that were changed, nad added the files themselves to SDL 1.2
This commit is contained in:
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/src/video/SDL_pixels.c
|
||||
936
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_pixels.c
Normal file
936
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_pixels.c
Normal file
@@ -0,0 +1,936 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
/* General (mostly internal) pixel/color manipulation routines for SDL */
|
||||
|
||||
#include "SDL_endian.h"
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#else
|
||||
#include "SDL_video-1.3.h"
|
||||
#include "SDL_sysvideo-1.3.h"
|
||||
#endif
|
||||
#include "SDL_blit.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_RLEaccel_c.h"
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
struct SDL_PaletteWatch
|
||||
{
|
||||
SDL_PaletteChangedFunc callback;
|
||||
void *userdata;
|
||||
struct SDL_PaletteWatch *next;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Helper functions */
|
||||
|
||||
SDL_bool
|
||||
SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask,
|
||||
Uint32 * Gmask, Uint32 * Bmask, Uint32 * Amask)
|
||||
{
|
||||
Uint32 masks[4];
|
||||
|
||||
/* Initialize the values here */
|
||||
if (SDL_BYTESPERPIXEL(format) <= 2) {
|
||||
*bpp = SDL_BITSPERPIXEL(format);
|
||||
} else {
|
||||
*bpp = SDL_BYTESPERPIXEL(format) * 8;
|
||||
}
|
||||
*Rmask = *Gmask = *Bmask = *Amask = 0;
|
||||
|
||||
if (format == SDL_PIXELFORMAT_RGB24) {
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
*Rmask = 0x00FF0000;
|
||||
*Gmask = 0x0000FF00;
|
||||
*Bmask = 0x000000FF;
|
||||
#else
|
||||
*Rmask = 0x000000FF;
|
||||
*Gmask = 0x0000FF00;
|
||||
*Bmask = 0x00FF0000;
|
||||
#endif
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (format == SDL_PIXELFORMAT_BGR24) {
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
*Rmask = 0x000000FF;
|
||||
*Gmask = 0x0000FF00;
|
||||
*Bmask = 0x00FF0000;
|
||||
#else
|
||||
*Rmask = 0x00FF0000;
|
||||
*Gmask = 0x0000FF00;
|
||||
*Bmask = 0x000000FF;
|
||||
#endif
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED8 &&
|
||||
SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED16 &&
|
||||
SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED32) {
|
||||
/* Not a format that uses masks */
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
switch (SDL_PIXELLAYOUT(format)) {
|
||||
case SDL_PACKEDLAYOUT_332:
|
||||
masks[0] = 0x00000000;
|
||||
masks[1] = 0x000000E0;
|
||||
masks[2] = 0x0000001C;
|
||||
masks[3] = 0x00000003;
|
||||
break;
|
||||
case SDL_PACKEDLAYOUT_4444:
|
||||
masks[0] = 0x0000F000;
|
||||
masks[1] = 0x00000F00;
|
||||
masks[2] = 0x000000F0;
|
||||
masks[3] = 0x0000000F;
|
||||
break;
|
||||
case SDL_PACKEDLAYOUT_1555:
|
||||
masks[0] = 0x00008000;
|
||||
masks[1] = 0x00007C00;
|
||||
masks[2] = 0x000003E0;
|
||||
masks[3] = 0x0000001F;
|
||||
break;
|
||||
case SDL_PACKEDLAYOUT_5551:
|
||||
masks[0] = 0x0000F800;
|
||||
masks[1] = 0x000007C0;
|
||||
masks[2] = 0x0000003E;
|
||||
masks[3] = 0x00000001;
|
||||
break;
|
||||
case SDL_PACKEDLAYOUT_565:
|
||||
masks[0] = 0x00000000;
|
||||
masks[1] = 0x0000F800;
|
||||
masks[2] = 0x000007E0;
|
||||
masks[3] = 0x0000001F;
|
||||
break;
|
||||
case SDL_PACKEDLAYOUT_8888:
|
||||
masks[0] = 0xFF000000;
|
||||
masks[1] = 0x00FF0000;
|
||||
masks[2] = 0x0000FF00;
|
||||
masks[3] = 0x000000FF;
|
||||
break;
|
||||
case SDL_PACKEDLAYOUT_2101010:
|
||||
masks[0] = 0xC0000000;
|
||||
masks[1] = 0x3FF00000;
|
||||
masks[2] = 0x000FFC00;
|
||||
masks[3] = 0x000003FF;
|
||||
break;
|
||||
case SDL_PACKEDLAYOUT_1010102:
|
||||
masks[0] = 0xFFC00000;
|
||||
masks[1] = 0x003FF000;
|
||||
masks[2] = 0x00000FFC;
|
||||
masks[3] = 0x00000003;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown pixel format");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
switch (SDL_PIXELORDER(format)) {
|
||||
case SDL_PACKEDORDER_XRGB:
|
||||
*Rmask = masks[1];
|
||||
*Gmask = masks[2];
|
||||
*Bmask = masks[3];
|
||||
break;
|
||||
case SDL_PACKEDORDER_RGBX:
|
||||
*Rmask = masks[0];
|
||||
*Gmask = masks[1];
|
||||
*Bmask = masks[2];
|
||||
break;
|
||||
case SDL_PACKEDORDER_ARGB:
|
||||
*Amask = masks[0];
|
||||
*Rmask = masks[1];
|
||||
*Gmask = masks[2];
|
||||
*Bmask = masks[3];
|
||||
break;
|
||||
case SDL_PACKEDORDER_RGBA:
|
||||
*Rmask = masks[0];
|
||||
*Gmask = masks[1];
|
||||
*Bmask = masks[2];
|
||||
*Amask = masks[3];
|
||||
break;
|
||||
case SDL_PACKEDORDER_XBGR:
|
||||
*Bmask = masks[1];
|
||||
*Gmask = masks[2];
|
||||
*Rmask = masks[3];
|
||||
break;
|
||||
case SDL_PACKEDORDER_BGRX:
|
||||
*Bmask = masks[0];
|
||||
*Gmask = masks[1];
|
||||
*Rmask = masks[2];
|
||||
break;
|
||||
case SDL_PACKEDORDER_BGRA:
|
||||
*Bmask = masks[0];
|
||||
*Gmask = masks[1];
|
||||
*Rmask = masks[2];
|
||||
*Amask = masks[3];
|
||||
break;
|
||||
case SDL_PACKEDORDER_ABGR:
|
||||
*Amask = masks[0];
|
||||
*Bmask = masks[1];
|
||||
*Gmask = masks[2];
|
||||
*Rmask = masks[3];
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown pixel format");
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
Uint32
|
||||
SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
|
||||
Uint32 Amask)
|
||||
{
|
||||
switch (bpp) {
|
||||
case 8:
|
||||
switch (Rmask) {
|
||||
case 0:
|
||||
return SDL_PIXELFORMAT_INDEX8;
|
||||
case 0xE0:
|
||||
return SDL_PIXELFORMAT_RGB332;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
switch (Rmask) {
|
||||
case 0x0F00:
|
||||
return SDL_PIXELFORMAT_RGB444;
|
||||
}
|
||||
break;
|
||||
case 15:
|
||||
switch (Rmask) {
|
||||
case 0x001F:
|
||||
return SDL_PIXELFORMAT_BGR555;
|
||||
case 0x7C00:
|
||||
return SDL_PIXELFORMAT_RGB555;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (Rmask) {
|
||||
case 0x000F:
|
||||
return SDL_PIXELFORMAT_ABGR4444;
|
||||
case 0x001F:
|
||||
if (Gmask == 0x07E0) {
|
||||
return SDL_PIXELFORMAT_BGR565;
|
||||
}
|
||||
return SDL_PIXELFORMAT_ABGR1555;
|
||||
case 0x0F00:
|
||||
return SDL_PIXELFORMAT_ARGB4444;
|
||||
case 0x7C00:
|
||||
return SDL_PIXELFORMAT_ARGB1555;
|
||||
case 0xF800:
|
||||
return SDL_PIXELFORMAT_RGB565;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
switch (Rmask) {
|
||||
case 0x00FF0000:
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
return SDL_PIXELFORMAT_RGB24;
|
||||
#else
|
||||
return SDL_PIXELFORMAT_BGR24;
|
||||
#endif
|
||||
case 0x000000FF:
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
return SDL_PIXELFORMAT_BGR24;
|
||||
#else
|
||||
return SDL_PIXELFORMAT_RGB24;
|
||||
#endif
|
||||
case 0x00000000:
|
||||
/* FIXME: At this point we can't distinguish */
|
||||
/* if this format is RGB24 or BGR24 */
|
||||
return SDL_PIXELFORMAT_RGB24;
|
||||
}
|
||||
case 32:
|
||||
switch (Rmask) {
|
||||
case 0xFF000000:
|
||||
if (Amask == 0x000000FF) {
|
||||
return SDL_PIXELFORMAT_RGBA8888;
|
||||
}
|
||||
break;
|
||||
case 0x00FF0000:
|
||||
if (Amask == 0xFF000000) {
|
||||
return SDL_PIXELFORMAT_ARGB8888;
|
||||
} else {
|
||||
return SDL_PIXELFORMAT_RGB888;
|
||||
}
|
||||
break;
|
||||
case 0x0000FF00:
|
||||
if (Amask == 0x000000FF) {
|
||||
return SDL_PIXELFORMAT_BGRA8888;
|
||||
}
|
||||
break;
|
||||
case 0x000000FF:
|
||||
if (Amask == 0xFF000000) {
|
||||
return SDL_PIXELFORMAT_ABGR8888;
|
||||
} else {
|
||||
return SDL_PIXELFORMAT_BGR888;
|
||||
}
|
||||
break;
|
||||
case 0x3FF00000:
|
||||
return SDL_PIXELFORMAT_ARGB2101010;
|
||||
}
|
||||
}
|
||||
return SDL_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
SDL_Palette *
|
||||
SDL_AllocPalette(int ncolors)
|
||||
{
|
||||
SDL_Palette *palette;
|
||||
|
||||
palette = (SDL_Palette *) SDL_malloc(sizeof(*palette));
|
||||
if (!palette) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
palette->colors =
|
||||
(SDL_Color *) SDL_malloc(ncolors * sizeof(*palette->colors));
|
||||
if (!palette->colors) {
|
||||
SDL_free(palette);
|
||||
return NULL;
|
||||
}
|
||||
palette->ncolors = ncolors;
|
||||
palette->watch = NULL;
|
||||
palette->refcount = 1;
|
||||
|
||||
SDL_memset(palette->colors, 0xFF, ncolors * sizeof(*palette->colors));
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_AddPaletteWatch(SDL_Palette * palette, SDL_PaletteChangedFunc callback,
|
||||
void *userdata)
|
||||
{
|
||||
SDL_PaletteWatch *watch;
|
||||
|
||||
if (!palette) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
watch = (SDL_PaletteWatch *) SDL_malloc(sizeof(*watch));
|
||||
if (!watch) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
|
||||
watch->callback = callback;
|
||||
watch->userdata = userdata;
|
||||
watch->next = palette->watch;
|
||||
palette->watch = watch;
|
||||
++palette->refcount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_DelPaletteWatch(SDL_Palette * palette, SDL_PaletteChangedFunc callback,
|
||||
void *userdata)
|
||||
{
|
||||
SDL_PaletteWatch *prev, *watch;
|
||||
|
||||
if (!palette) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (prev = NULL, watch = palette->watch; watch;
|
||||
prev = watch, watch = watch->next) {
|
||||
if (watch->callback == callback && watch->userdata == userdata) {
|
||||
if (prev) {
|
||||
prev->next = watch->next;
|
||||
} else {
|
||||
palette->watch = watch->next;
|
||||
}
|
||||
SDL_free(watch);
|
||||
SDL_FreePalette(palette);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SetPaletteColors(SDL_Palette * palette, const SDL_Color * colors,
|
||||
int firstcolor, int ncolors)
|
||||
{
|
||||
SDL_PaletteWatch *watch;
|
||||
int status = 0;
|
||||
|
||||
/* Verify the parameters */
|
||||
if (!palette) {
|
||||
return -1;
|
||||
}
|
||||
if (ncolors > (palette->ncolors - firstcolor)) {
|
||||
ncolors = (palette->ncolors - firstcolor);
|
||||
status = -1;
|
||||
}
|
||||
|
||||
if (colors != (palette->colors + firstcolor)) {
|
||||
SDL_memcpy(palette->colors + firstcolor, colors,
|
||||
ncolors * sizeof(*colors));
|
||||
}
|
||||
|
||||
for (watch = palette->watch; watch; watch = watch->next) {
|
||||
if (watch->callback(watch->userdata, palette) < 0) {
|
||||
status = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_FreePalette(SDL_Palette * palette)
|
||||
{
|
||||
if (!palette) {
|
||||
return;
|
||||
}
|
||||
if (--palette->refcount > 0) {
|
||||
return;
|
||||
}
|
||||
if (palette->colors) {
|
||||
SDL_free(palette->colors);
|
||||
}
|
||||
SDL_free(palette);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a pixel format structure and fill it according to the given info.
|
||||
*/
|
||||
SDL_PixelFormat *
|
||||
SDL_AllocFormat(int bpp,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
SDL_PixelFormat *format;
|
||||
|
||||
/* Allocate an empty pixel format structure */
|
||||
format = SDL_malloc(sizeof(*format));
|
||||
if (format == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Set up the format */
|
||||
return SDL_InitFormat(format, bpp, Rmask, Gmask, Bmask, Amask);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SDL_PixelFormat *
|
||||
SDL_InitFormat(SDL_PixelFormat * format, int bpp, Uint32 Rmask, Uint32 Gmask,
|
||||
Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
Uint32 mask;
|
||||
|
||||
/* Set up the format */
|
||||
SDL_zerop(format);
|
||||
format->BitsPerPixel = bpp;
|
||||
format->BytesPerPixel = (bpp + 7) / 8;
|
||||
if (Rmask || Bmask || Gmask) { /* Packed pixels with custom mask */
|
||||
format->Rshift = 0;
|
||||
format->Rloss = 8;
|
||||
if (Rmask) {
|
||||
for (mask = Rmask; !(mask & 0x01); mask >>= 1)
|
||||
++format->Rshift;
|
||||
for (; (mask & 0x01); mask >>= 1)
|
||||
--format->Rloss;
|
||||
}
|
||||
format->Gshift = 0;
|
||||
format->Gloss = 8;
|
||||
if (Gmask) {
|
||||
for (mask = Gmask; !(mask & 0x01); mask >>= 1)
|
||||
++format->Gshift;
|
||||
for (; (mask & 0x01); mask >>= 1)
|
||||
--format->Gloss;
|
||||
}
|
||||
format->Bshift = 0;
|
||||
format->Bloss = 8;
|
||||
if (Bmask) {
|
||||
for (mask = Bmask; !(mask & 0x01); mask >>= 1)
|
||||
++format->Bshift;
|
||||
for (; (mask & 0x01); mask >>= 1)
|
||||
--format->Bloss;
|
||||
}
|
||||
format->Ashift = 0;
|
||||
format->Aloss = 8;
|
||||
if (Amask) {
|
||||
for (mask = Amask; !(mask & 0x01); mask >>= 1)
|
||||
++format->Ashift;
|
||||
for (; (mask & 0x01); mask >>= 1)
|
||||
--format->Aloss;
|
||||
}
|
||||
format->Rmask = Rmask;
|
||||
format->Gmask = Gmask;
|
||||
format->Bmask = Bmask;
|
||||
format->Amask = Amask;
|
||||
} else if (bpp > 8) { /* Packed pixels with standard mask */
|
||||
/* R-G-B */
|
||||
if (bpp > 24)
|
||||
bpp = 24;
|
||||
format->Rloss = 8 - (bpp / 3);
|
||||
format->Gloss = 8 - (bpp / 3) - (bpp % 3);
|
||||
format->Bloss = 8 - (bpp / 3);
|
||||
format->Rshift = ((bpp / 3) + (bpp % 3)) + (bpp / 3);
|
||||
format->Gshift = (bpp / 3);
|
||||
format->Bshift = 0;
|
||||
format->Rmask = ((0xFF >> format->Rloss) << format->Rshift);
|
||||
format->Gmask = ((0xFF >> format->Gloss) << format->Gshift);
|
||||
format->Bmask = ((0xFF >> format->Bloss) << format->Bshift);
|
||||
} else {
|
||||
/* Palettized formats have no mask info */
|
||||
format->Rloss = 8;
|
||||
format->Gloss = 8;
|
||||
format->Bloss = 8;
|
||||
format->Aloss = 8;
|
||||
format->Rshift = 0;
|
||||
format->Gshift = 0;
|
||||
format->Bshift = 0;
|
||||
format->Ashift = 0;
|
||||
format->Rmask = 0;
|
||||
format->Gmask = 0;
|
||||
format->Bmask = 0;
|
||||
format->Amask = 0;
|
||||
}
|
||||
format->palette = NULL;
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
/*
|
||||
* Change any previous mappings from/to the new surface format
|
||||
*/
|
||||
void
|
||||
SDL_FormatChanged(SDL_Surface * surface)
|
||||
{
|
||||
static int format_version = 0;
|
||||
++format_version;
|
||||
if (format_version < 0) { /* It wrapped... */
|
||||
format_version = 1;
|
||||
}
|
||||
surface->format_version = format_version;
|
||||
SDL_InvalidateMap(surface->map);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a previously allocated format structure
|
||||
*/
|
||||
void
|
||||
SDL_FreeFormat(SDL_PixelFormat * format)
|
||||
{
|
||||
if (!format) {
|
||||
return;
|
||||
}
|
||||
SDL_free(format);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors
|
||||
*/
|
||||
void
|
||||
SDL_DitherColors(SDL_Color * colors, int bpp)
|
||||
{
|
||||
int i;
|
||||
if (bpp != 8)
|
||||
return; /* only 8bpp supported right now */
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
int r, g, b;
|
||||
/* map each bit field to the full [0, 255] interval,
|
||||
so 0 is mapped to (0, 0, 0) and 255 to (255, 255, 255) */
|
||||
r = i & 0xe0;
|
||||
r |= r >> 3 | r >> 6;
|
||||
colors[i].r = r;
|
||||
g = (i << 3) & 0xe0;
|
||||
g |= g >> 3 | g >> 6;
|
||||
colors[i].g = g;
|
||||
b = i & 0x3;
|
||||
b |= b << 2;
|
||||
b |= b << 4;
|
||||
colors[i].b = b;
|
||||
colors[i].unused = SDL_ALPHA_OPAQUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the pad-aligned scanline width of a surface
|
||||
*/
|
||||
int
|
||||
SDL_CalculatePitch(SDL_Surface * surface)
|
||||
{
|
||||
int pitch;
|
||||
|
||||
/* Surface should be 4-byte aligned for speed */
|
||||
pitch = surface->w * surface->format->BytesPerPixel;
|
||||
switch (surface->format->BitsPerPixel) {
|
||||
case 1:
|
||||
pitch = (pitch + 7) / 8;
|
||||
break;
|
||||
case 4:
|
||||
pitch = (pitch + 1) / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 4-byte aligning adds extra memcpy() with OpenGL ES renderer
|
||||
// TODO: check if we really can disable that for Android
|
||||
#ifndef ANDROID
|
||||
pitch = (pitch + 3) & ~3; /* 4-byte aligning */
|
||||
#endif
|
||||
return (pitch);
|
||||
}
|
||||
|
||||
/*
|
||||
* Match an RGB value to a particular palette index
|
||||
*/
|
||||
Uint8
|
||||
SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b)
|
||||
{
|
||||
/* Do colorspace distance matching */
|
||||
unsigned int smallest;
|
||||
unsigned int distance;
|
||||
int rd, gd, bd;
|
||||
int i;
|
||||
Uint8 pixel = 0;
|
||||
|
||||
smallest = ~0;
|
||||
for (i = 0; i < pal->ncolors; ++i) {
|
||||
rd = pal->colors[i].r - r;
|
||||
gd = pal->colors[i].g - g;
|
||||
bd = pal->colors[i].b - b;
|
||||
distance = (rd * rd) + (gd * gd) + (bd * bd);
|
||||
if (distance < smallest) {
|
||||
pixel = i;
|
||||
if (distance == 0) { /* Perfect match! */
|
||||
break;
|
||||
}
|
||||
smallest = distance;
|
||||
}
|
||||
}
|
||||
return (pixel);
|
||||
}
|
||||
|
||||
/* Find the opaque pixel value corresponding to an RGB triple */
|
||||
Uint32
|
||||
SDL_MapRGB(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b)
|
||||
{
|
||||
if (format->palette == NULL) {
|
||||
return (r >> format->Rloss) << format->Rshift
|
||||
| (g >> format->Gloss) << format->Gshift
|
||||
| (b >> format->Bloss) << format->Bshift | format->Amask;
|
||||
} else {
|
||||
return SDL_FindColor(format->palette, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the pixel value corresponding to an RGBA quadruple */
|
||||
Uint32
|
||||
SDL_MapRGBA(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b,
|
||||
Uint8 a)
|
||||
{
|
||||
if (format->palette == NULL) {
|
||||
return (r >> format->Rloss) << format->Rshift
|
||||
| (g >> format->Gloss) << format->Gshift
|
||||
| (b >> format->Bloss) << format->Bshift
|
||||
| ((a >> format->Aloss) << format->Ashift & format->Amask);
|
||||
} else {
|
||||
return SDL_FindColor(format->palette, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g,
|
||||
Uint8 * b)
|
||||
{
|
||||
if (format->palette == NULL) {
|
||||
/*
|
||||
* This makes sure that the result is mapped to the
|
||||
* interval [0..255], and the maximum value for each
|
||||
* component is 255. This is important to make sure
|
||||
* that white is indeed reported as (255, 255, 255).
|
||||
* This only works for RGB bit fields at least 4 bit
|
||||
* wide, which is almost always the case.
|
||||
*/
|
||||
unsigned v;
|
||||
v = (pixel & format->Rmask) >> format->Rshift;
|
||||
*r = (v << format->Rloss) + (v >> (8 - (format->Rloss << 1)));
|
||||
v = (pixel & format->Gmask) >> format->Gshift;
|
||||
*g = (v << format->Gloss) + (v >> (8 - (format->Gloss << 1)));
|
||||
v = (pixel & format->Bmask) >> format->Bshift;
|
||||
*b = (v << format->Bloss) + (v >> (8 - (format->Bloss << 1)));
|
||||
} else {
|
||||
*r = format->palette->colors[pixel].r;
|
||||
*g = format->palette->colors[pixel].g;
|
||||
*b = format->palette->colors[pixel].b;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format,
|
||||
Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a)
|
||||
{
|
||||
if (format->palette == NULL) {
|
||||
/*
|
||||
* This makes sure that the result is mapped to the
|
||||
* interval [0..255], and the maximum value for each
|
||||
* component is 255. This is important to make sure
|
||||
* that white is indeed reported as (255, 255, 255),
|
||||
* and that opaque alpha is 255.
|
||||
* This only works for RGB bit fields at least 4 bit
|
||||
* wide, which is almost always the case.
|
||||
*/
|
||||
unsigned v;
|
||||
v = (pixel & format->Rmask) >> format->Rshift;
|
||||
*r = (v << format->Rloss) + (v >> (8 - (format->Rloss << 1)));
|
||||
v = (pixel & format->Gmask) >> format->Gshift;
|
||||
*g = (v << format->Gloss) + (v >> (8 - (format->Gloss << 1)));
|
||||
v = (pixel & format->Bmask) >> format->Bshift;
|
||||
*b = (v << format->Bloss) + (v >> (8 - (format->Bloss << 1)));
|
||||
if (format->Amask) {
|
||||
v = (pixel & format->Amask) >> format->Ashift;
|
||||
*a = (v << format->Aloss) + (v >> (8 - (format->Aloss << 1)));
|
||||
} else {
|
||||
*a = SDL_ALPHA_OPAQUE;
|
||||
}
|
||||
} else {
|
||||
*r = format->palette->colors[pixel].r;
|
||||
*g = format->palette->colors[pixel].g;
|
||||
*b = format->palette->colors[pixel].b;
|
||||
*a = SDL_ALPHA_OPAQUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Apply gamma to a set of colors - this is easy. :) */
|
||||
void
|
||||
SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors, SDL_Color * output,
|
||||
int ncolors)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ncolors; ++i) {
|
||||
output[i].r = gamma[0 * 256 + colors[i].r] >> 8;
|
||||
output[i].g = gamma[1 * 256 + colors[i].g] >> 8;
|
||||
output[i].b = gamma[2 * 256 + colors[i].b] >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
/* Map from Palette to Palette */
|
||||
static Uint8 *
|
||||
Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
|
||||
{
|
||||
Uint8 *map;
|
||||
int i;
|
||||
|
||||
if (identical) {
|
||||
if (src->ncolors <= dst->ncolors) {
|
||||
/* If an identical palette, no need to map */
|
||||
if (src == dst
|
||||
||
|
||||
(SDL_memcmp
|
||||
(src->colors, dst->colors,
|
||||
src->ncolors * sizeof(SDL_Color)) == 0)) {
|
||||
*identical = 1;
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
*identical = 0;
|
||||
}
|
||||
map = (Uint8 *) SDL_malloc(src->ncolors);
|
||||
if (map == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (NULL);
|
||||
}
|
||||
for (i = 0; i < src->ncolors; ++i) {
|
||||
map[i] = SDL_FindColor(dst,
|
||||
src->colors[i].r, src->colors[i].g,
|
||||
src->colors[i].b);
|
||||
}
|
||||
return (map);
|
||||
}
|
||||
|
||||
/* Map from Palette to BitField */
|
||||
static Uint8 *
|
||||
Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
|
||||
SDL_PixelFormat * dst)
|
||||
{
|
||||
Uint8 *map;
|
||||
int i;
|
||||
int bpp;
|
||||
SDL_Palette *pal = src->palette;
|
||||
|
||||
bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
|
||||
map = (Uint8 *) SDL_malloc(pal->ncolors * bpp);
|
||||
if (map == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* We memory copy to the pixel map so the endianness is preserved */
|
||||
for (i = 0; i < pal->ncolors; ++i) {
|
||||
Uint8 A = Amod;
|
||||
Uint8 R = (Uint8) ((pal->colors[i].r * Rmod) / 255);
|
||||
Uint8 G = (Uint8) ((pal->colors[i].g * Gmod) / 255);
|
||||
Uint8 B = (Uint8) ((pal->colors[i].b * Bmod) / 255);
|
||||
ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, R, G, B, A);
|
||||
}
|
||||
return (map);
|
||||
}
|
||||
|
||||
/* Map from BitField to Dithered-Palette to Palette */
|
||||
static Uint8 *
|
||||
MapNto1(SDL_PixelFormat * src, SDL_PixelFormat * dst, int *identical)
|
||||
{
|
||||
/* Generate a 256 color dither palette */
|
||||
SDL_Palette dithered;
|
||||
SDL_Color colors[256];
|
||||
SDL_Palette *pal = dst->palette;
|
||||
|
||||
dithered.ncolors = 256;
|
||||
SDL_DitherColors(colors, 8);
|
||||
dithered.colors = colors;
|
||||
return (Map1to1(&dithered, pal, identical));
|
||||
}
|
||||
|
||||
SDL_BlitMap *
|
||||
SDL_AllocBlitMap(void)
|
||||
{
|
||||
SDL_BlitMap *map;
|
||||
|
||||
/* Allocate the empty map */
|
||||
map = (SDL_BlitMap *) SDL_calloc(1, sizeof(*map));
|
||||
if (map == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return (NULL);
|
||||
}
|
||||
map->info.r = 0xFF;
|
||||
map->info.g = 0xFF;
|
||||
map->info.b = 0xFF;
|
||||
map->info.a = 0xFF;
|
||||
|
||||
/* It's ready to go */
|
||||
return (map);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_InvalidateMap(SDL_BlitMap * map)
|
||||
{
|
||||
if (!map) {
|
||||
return;
|
||||
}
|
||||
map->dst = NULL;
|
||||
map->format_version = (unsigned int) -1;
|
||||
if (map->info.table) {
|
||||
SDL_free(map->info.table);
|
||||
map->info.table = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst)
|
||||
{
|
||||
SDL_PixelFormat *srcfmt;
|
||||
SDL_PixelFormat *dstfmt;
|
||||
SDL_BlitMap *map;
|
||||
|
||||
/* Clear out any previous mapping */
|
||||
map = src->map;
|
||||
if ((src->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
|
||||
SDL_UnRLESurface(src, 1);
|
||||
}
|
||||
SDL_InvalidateMap(map);
|
||||
|
||||
/* Figure out what kind of mapping we're doing */
|
||||
map->identity = 0;
|
||||
srcfmt = src->format;
|
||||
dstfmt = dst->format;
|
||||
switch (srcfmt->BytesPerPixel) {
|
||||
case 1:
|
||||
switch (dstfmt->BytesPerPixel) {
|
||||
case 1:
|
||||
/* Palette --> Palette */
|
||||
map->info.table =
|
||||
Map1to1(srcfmt->palette, dstfmt->palette, &map->identity);
|
||||
if (!map->identity) {
|
||||
if (map->info.table == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (srcfmt->BitsPerPixel != dstfmt->BitsPerPixel)
|
||||
map->identity = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Palette --> BitField */
|
||||
map->info.table =
|
||||
Map1toN(srcfmt, src->map->info.r, src->map->info.g,
|
||||
src->map->info.b, src->map->info.a, dstfmt);
|
||||
if (map->info.table == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (dstfmt->BytesPerPixel) {
|
||||
case 1:
|
||||
/* BitField --> Palette */
|
||||
map->info.table = MapNto1(srcfmt, dstfmt, &map->identity);
|
||||
if (!map->identity) {
|
||||
if (map->info.table == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
map->identity = 0; /* Don't optimize to copy */
|
||||
break;
|
||||
default:
|
||||
/* BitField --> BitField */
|
||||
if (FORMAT_EQUAL(srcfmt, dstfmt))
|
||||
map->identity = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
map->dst = dst;
|
||||
map->format_version = dst->format_version;
|
||||
|
||||
/* Choose your blitters wisely */
|
||||
return (SDL_CalculateBlit(src));
|
||||
}
|
||||
|
||||
void
|
||||
SDL_FreeBlitMap(SDL_BlitMap * map)
|
||||
{
|
||||
if (map) {
|
||||
SDL_InvalidateMap(map);
|
||||
SDL_free(map);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/include/SDL_pixels.h
|
||||
417
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_pixels.h
Normal file
417
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_pixels.h
Normal file
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_pixels.h
|
||||
*
|
||||
* Header for the enumerated pixel format definitions.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_pixels_h
|
||||
#define _SDL_pixels_h
|
||||
|
||||
#include "SDL_version.h"
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#else
|
||||
#include "SDL_video-1.3.h"
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name Transparency definitions
|
||||
*
|
||||
* These define alpha as the opacity of a surface.
|
||||
*/
|
||||
/*@{*/
|
||||
#define SDL_ALPHA_OPAQUE 255
|
||||
#define SDL_ALPHA_TRANSPARENT 0
|
||||
/*@}*/
|
||||
|
||||
/** Pixel type. */
|
||||
enum
|
||||
{
|
||||
SDL_PIXELTYPE_UNKNOWN,
|
||||
SDL_PIXELTYPE_INDEX1,
|
||||
SDL_PIXELTYPE_INDEX4,
|
||||
SDL_PIXELTYPE_INDEX8,
|
||||
SDL_PIXELTYPE_PACKED8,
|
||||
SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PIXELTYPE_ARRAYU8,
|
||||
SDL_PIXELTYPE_ARRAYU16,
|
||||
SDL_PIXELTYPE_ARRAYU32,
|
||||
SDL_PIXELTYPE_ARRAYF16,
|
||||
SDL_PIXELTYPE_ARRAYF32
|
||||
};
|
||||
|
||||
/** Bitmap pixel order, high bit -> low bit. */
|
||||
enum
|
||||
{
|
||||
SDL_BITMAPORDER_NONE,
|
||||
SDL_BITMAPORDER_4321,
|
||||
SDL_BITMAPORDER_1234
|
||||
};
|
||||
|
||||
/** Packed component order, high bit -> low bit. */
|
||||
enum
|
||||
{
|
||||
SDL_PACKEDORDER_NONE,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDORDER_RGBX,
|
||||
SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDORDER_BGRX,
|
||||
SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDORDER_BGRA
|
||||
};
|
||||
|
||||
/** Array component order, low byte -> high byte. */
|
||||
enum
|
||||
{
|
||||
SDL_ARRAYORDER_NONE,
|
||||
SDL_ARRAYORDER_RGB,
|
||||
SDL_ARRAYORDER_RGBA,
|
||||
SDL_ARRAYORDER_ARGB,
|
||||
SDL_ARRAYORDER_BGR,
|
||||
SDL_ARRAYORDER_BGRA,
|
||||
SDL_ARRAYORDER_ABGR
|
||||
};
|
||||
|
||||
/** Packed component layout. */
|
||||
enum
|
||||
{
|
||||
SDL_PACKEDLAYOUT_NONE,
|
||||
SDL_PACKEDLAYOUT_332,
|
||||
SDL_PACKEDLAYOUT_4444,
|
||||
SDL_PACKEDLAYOUT_1555,
|
||||
SDL_PACKEDLAYOUT_5551,
|
||||
SDL_PACKEDLAYOUT_565,
|
||||
SDL_PACKEDLAYOUT_8888,
|
||||
SDL_PACKEDLAYOUT_2101010,
|
||||
SDL_PACKEDLAYOUT_1010102
|
||||
};
|
||||
|
||||
#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D)
|
||||
|
||||
#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
|
||||
((1 << 31) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
|
||||
((bits) << 8) | ((bytes) << 0))
|
||||
|
||||
#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
|
||||
#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
|
||||
#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
|
||||
#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
|
||||
#define SDL_BYTESPERPIXEL(X) (((X) >> 0) & 0xFF)
|
||||
|
||||
#define SDL_ISPIXELFORMAT_INDEXED(format) \
|
||||
((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
|
||||
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
|
||||
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))
|
||||
|
||||
#define SDL_ISPIXELFORMAT_ALPHA(format) \
|
||||
((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \
|
||||
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \
|
||||
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \
|
||||
(SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))
|
||||
|
||||
#define SDL_ISPIXELFORMAT_FOURCC(format) \
|
||||
((format) && !((format) & 0x80000000))
|
||||
|
||||
enum
|
||||
{
|
||||
SDL_PIXELFORMAT_UNKNOWN,
|
||||
SDL_PIXELFORMAT_INDEX1LSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
|
||||
1, 0),
|
||||
SDL_PIXELFORMAT_INDEX1MSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0,
|
||||
1, 0),
|
||||
SDL_PIXELFORMAT_INDEX4LSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0,
|
||||
4, 0),
|
||||
SDL_PIXELFORMAT_INDEX4MSB =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
|
||||
4, 0),
|
||||
SDL_PIXELFORMAT_INDEX8 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1),
|
||||
SDL_PIXELFORMAT_RGB332 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_332, 8, 1),
|
||||
SDL_PIXELFORMAT_RGB444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_4444, 12, 2),
|
||||
SDL_PIXELFORMAT_RGB555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2),
|
||||
SDL_PIXELFORMAT_BGR555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2),
|
||||
SDL_PIXELFORMAT_ARGB4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
SDL_PIXELFORMAT_ABGR4444 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
SDL_PIXELFORMAT_RGBA4444 = /* Android-specific */
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2),
|
||||
SDL_PIXELFORMAT_ARGB1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_1555, 16, 2),
|
||||
SDL_PIXELFORMAT_ABGR1555 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_1555, 16, 2),
|
||||
SDL_PIXELFORMAT_RGBA5551 = /* Android-specific */
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_5551, 16, 2),
|
||||
SDL_PIXELFORMAT_RGB565 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_565, 16, 2),
|
||||
SDL_PIXELFORMAT_BGR565 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_565, 16, 2),
|
||||
SDL_PIXELFORMAT_RGB24 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0,
|
||||
24, 3),
|
||||
SDL_PIXELFORMAT_BGR24 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0,
|
||||
24, 3),
|
||||
SDL_PIXELFORMAT_RGB888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4),
|
||||
SDL_PIXELFORMAT_BGR888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4),
|
||||
SDL_PIXELFORMAT_ARGB8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4),
|
||||
SDL_PIXELFORMAT_RGBA8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4),
|
||||
SDL_PIXELFORMAT_ABGR8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4),
|
||||
SDL_PIXELFORMAT_BGRA8888 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4),
|
||||
SDL_PIXELFORMAT_ARGB2101010 =
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_2101010, 32, 4),
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
|
||||
SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */
|
||||
SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'),
|
||||
SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'),
|
||||
SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
|
||||
SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
|
||||
#endif
|
||||
};
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
typedef struct SDL_Color
|
||||
{
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
Uint8 unused;
|
||||
} SDL_Color;
|
||||
#define SDL_Colour SDL_Color
|
||||
|
||||
typedef struct SDL_Palette SDL_Palette;
|
||||
typedef int (*SDL_PaletteChangedFunc) (void *userdata, SDL_Palette * palette);
|
||||
typedef struct SDL_PaletteWatch SDL_PaletteWatch;
|
||||
|
||||
struct SDL_Palette
|
||||
{
|
||||
int ncolors;
|
||||
SDL_Color *colors;
|
||||
|
||||
int refcount;
|
||||
SDL_PaletteWatch *watch;
|
||||
};
|
||||
|
||||
/**
|
||||
* \note Everything in the pixel format structure is read-only.
|
||||
*/
|
||||
typedef struct SDL_PixelFormat
|
||||
{
|
||||
SDL_Palette *palette;
|
||||
Uint8 BitsPerPixel;
|
||||
Uint8 BytesPerPixel;
|
||||
Uint8 Rloss;
|
||||
Uint8 Gloss;
|
||||
Uint8 Bloss;
|
||||
Uint8 Aloss;
|
||||
Uint8 Rshift;
|
||||
Uint8 Gshift;
|
||||
Uint8 Bshift;
|
||||
Uint8 Ashift;
|
||||
Uint32 Rmask;
|
||||
Uint32 Gmask;
|
||||
Uint32 Bmask;
|
||||
Uint32 Amask;
|
||||
} SDL_PixelFormat;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
|
||||
*
|
||||
* \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
|
||||
*
|
||||
* \sa SDL_MasksToPixelFormatEnum()
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
|
||||
int *bpp,
|
||||
Uint32 * Rmask,
|
||||
Uint32 * Gmask,
|
||||
Uint32 * Bmask,
|
||||
Uint32 * Amask);
|
||||
|
||||
/**
|
||||
* \brief Convert a bpp and RGBA masks to an enumerated pixel format.
|
||||
*
|
||||
* \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion
|
||||
* wasn't possible.
|
||||
*
|
||||
* \sa SDL_PixelFormatEnumToMasks()
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
|
||||
Uint32 Rmask,
|
||||
Uint32 Gmask,
|
||||
Uint32 Bmask,
|
||||
Uint32 Amask);
|
||||
|
||||
/**
|
||||
* \brief Create a palette structure with the specified number of color
|
||||
* entries.
|
||||
*
|
||||
* \return A new palette, or NULL if there wasn't enough memory.
|
||||
*
|
||||
* \note The palette entries are initialized to white.
|
||||
*
|
||||
* \sa SDL_FreePalette()
|
||||
*/
|
||||
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
|
||||
|
||||
/**
|
||||
* \brief Add a callback function which is called when the palette changes.
|
||||
*
|
||||
* \sa SDL_DelPaletteWatch()
|
||||
*/
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
|
||||
SDL_PaletteChangedFunc
|
||||
callback, void *userdata);
|
||||
|
||||
/**
|
||||
* \brief Remove a callback function previously added with
|
||||
* SDL_AddPaletteWatch().
|
||||
*
|
||||
* \sa SDL_AddPaletteWatch()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette,
|
||||
SDL_PaletteChangedFunc
|
||||
callback, void *userdata);
|
||||
#endif
|
||||
/**
|
||||
* \brief Set a range of colors in a palette.
|
||||
*
|
||||
* \param palette The palette to modify.
|
||||
* \param colors An array of colors to copy into the palette.
|
||||
* \param firstcolor The index of the first palette entry to modify.
|
||||
* \param ncolors The number of entries to modify.
|
||||
*
|
||||
* \return 0 on success, or -1 if not all of the colors could be set.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
|
||||
const SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
|
||||
/**
|
||||
* \brief Free a palette created with SDL_AllocPalette().
|
||||
*
|
||||
* \sa SDL_AllocPalette()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
|
||||
|
||||
/**
|
||||
* \brief Maps an RGB triple to an opaque pixel value for a given pixel format.
|
||||
*
|
||||
* \sa SDL_MapRGBA
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
|
||||
Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
/**
|
||||
* \brief Maps an RGBA quadruple to a pixel value for a given pixel format.
|
||||
*
|
||||
* \sa SDL_MapRGB
|
||||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
|
||||
Uint8 r, Uint8 g, Uint8 b,
|
||||
Uint8 a);
|
||||
|
||||
/**
|
||||
* \brief Get the RGB components from a pixel of the specified format.
|
||||
*
|
||||
* \sa SDL_GetRGBA
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
|
||||
const SDL_PixelFormat * format,
|
||||
Uint8 * r, Uint8 * g, Uint8 * b);
|
||||
|
||||
/**
|
||||
* \brief Get the RGBA components from a pixel of the specified format.
|
||||
*
|
||||
* \sa SDL_GetRGB
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
||||
const SDL_PixelFormat * format,
|
||||
Uint8 * r, Uint8 * g, Uint8 * b,
|
||||
Uint8 * a);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_pixels_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/src/video/SDL_pixels_c.h
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
/* Useful functions and variables from SDL_pixel.c */
|
||||
|
||||
#include "SDL_blit.h"
|
||||
|
||||
/* Pixel format functions */
|
||||
extern SDL_PixelFormat *SDL_AllocFormat(int bpp,
|
||||
Uint32 Rmask, Uint32 Gmask,
|
||||
Uint32 Bmask, Uint32 Amask);
|
||||
extern SDL_PixelFormat *SDL_InitFormat(SDL_PixelFormat * format, int bpp,
|
||||
Uint32 Rmask, Uint32 Gmask,
|
||||
Uint32 Bmask, Uint32 Amask);
|
||||
extern void SDL_FormatChanged(SDL_Surface * surface);
|
||||
extern void SDL_FreeFormat(SDL_PixelFormat * format);
|
||||
|
||||
/* Blit mapping functions */
|
||||
extern SDL_BlitMap *SDL_AllocBlitMap(void);
|
||||
extern void SDL_InvalidateMap(SDL_BlitMap * map);
|
||||
extern int SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst);
|
||||
extern void SDL_FreeBlitMap(SDL_BlitMap * map);
|
||||
|
||||
/* Miscellaneous functions */
|
||||
extern int SDL_CalculatePitch(SDL_Surface * surface);
|
||||
extern void SDL_DitherColors(SDL_Color * colors, int bpp);
|
||||
extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b);
|
||||
extern void SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors,
|
||||
SDL_Color * output, int ncolors);
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/src/video/SDL_rect.c
|
||||
405
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_rect.c
Normal file
405
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_rect.c
Normal file
@@ -0,0 +1,405 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_rect_c.h"
|
||||
|
||||
SDL_bool
|
||||
SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
|
||||
{
|
||||
int Amin, Amax, Bmin, Bmax;
|
||||
|
||||
/* Horizontal intersection */
|
||||
Amin = A->x;
|
||||
Amax = Amin + A->w;
|
||||
Bmin = B->x;
|
||||
Bmax = Bmin + B->w;
|
||||
if (Bmin > Amin)
|
||||
Amin = Bmin;
|
||||
if (Bmax < Amax)
|
||||
Amax = Bmax;
|
||||
if (Amax <= Amin)
|
||||
return SDL_FALSE;
|
||||
|
||||
/* Vertical intersection */
|
||||
Amin = A->y;
|
||||
Amax = Amin + A->h;
|
||||
Bmin = B->y;
|
||||
Bmax = Bmin + B->h;
|
||||
if (Bmin > Amin)
|
||||
Amin = Bmin;
|
||||
if (Bmax < Amax)
|
||||
Amax = Bmax;
|
||||
if (Amax <= Amin)
|
||||
return SDL_FALSE;
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
|
||||
{
|
||||
int Amin, Amax, Bmin, Bmax;
|
||||
|
||||
/* Horizontal intersection */
|
||||
Amin = A->x;
|
||||
Amax = Amin + A->w;
|
||||
Bmin = B->x;
|
||||
Bmax = Bmin + B->w;
|
||||
if (Bmin > Amin)
|
||||
Amin = Bmin;
|
||||
result->x = Amin;
|
||||
if (Bmax < Amax)
|
||||
Amax = Bmax;
|
||||
result->w = Amax - Amin;
|
||||
|
||||
/* Vertical intersection */
|
||||
Amin = A->y;
|
||||
Amax = Amin + A->h;
|
||||
Bmin = B->y;
|
||||
Bmax = Bmin + B->h;
|
||||
if (Bmin > Amin)
|
||||
Amin = Bmin;
|
||||
result->y = Amin;
|
||||
if (Bmax < Amax)
|
||||
Amax = Bmax;
|
||||
result->h = Amax - Amin;
|
||||
|
||||
return !SDL_RectEmpty(result);
|
||||
}
|
||||
|
||||
void
|
||||
SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
|
||||
{
|
||||
int Amin, Amax, Bmin, Bmax;
|
||||
|
||||
/* Horizontal union */
|
||||
Amin = A->x;
|
||||
Amax = Amin + A->w;
|
||||
Bmin = B->x;
|
||||
Bmax = Bmin + B->w;
|
||||
if (Bmin < Amin)
|
||||
Amin = Bmin;
|
||||
result->x = Amin;
|
||||
if (Bmax > Amax)
|
||||
Amax = Bmax;
|
||||
result->w = Amax - Amin;
|
||||
|
||||
/* Vertical intersection */
|
||||
Amin = A->y;
|
||||
Amax = Amin + A->h;
|
||||
Bmin = B->y;
|
||||
Bmax = Bmin + B->h;
|
||||
if (Bmin < Amin)
|
||||
Amin = Bmin;
|
||||
result->y = Amin;
|
||||
if (Bmax > Amax)
|
||||
Amax = Bmax;
|
||||
result->h = Amax - Amin;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip,
|
||||
SDL_Rect * result)
|
||||
{
|
||||
int minx = 0;
|
||||
int miny = 0;
|
||||
int maxx = 0;
|
||||
int maxy = 0;
|
||||
int x, y, i;
|
||||
|
||||
if (count < 1) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (clip) {
|
||||
SDL_bool added = SDL_FALSE;
|
||||
int clip_minx = clip->x;
|
||||
int clip_miny = clip->y;
|
||||
int clip_maxx = clip->x+clip->w-1;
|
||||
int clip_maxy = clip->y+clip->h-1;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
|
||||
if (x < clip_minx || x > clip_maxx ||
|
||||
y < clip_miny || y > clip_maxy) {
|
||||
continue;
|
||||
}
|
||||
if (!added) {
|
||||
minx = maxx = x;
|
||||
miny = maxy = y;
|
||||
added = SDL_TRUE;
|
||||
continue;
|
||||
}
|
||||
if (x < minx) {
|
||||
minx = x;
|
||||
} else if (x > maxx) {
|
||||
maxx = x;
|
||||
}
|
||||
if (y < miny) {
|
||||
miny = y;
|
||||
} else if (y > maxy) {
|
||||
maxy = y;
|
||||
}
|
||||
}
|
||||
if (!added) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
} else {
|
||||
/* No clipping, always add the first point */
|
||||
minx = maxx = points[0].x;
|
||||
miny = maxy = points[0].y;
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
|
||||
if (x < minx) {
|
||||
minx = x;
|
||||
} else if (x > maxx) {
|
||||
maxx = x;
|
||||
}
|
||||
if (y < miny) {
|
||||
miny = y;
|
||||
} else if (y > maxy) {
|
||||
maxy = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result->x = minx;
|
||||
result->y = miny;
|
||||
result->w = (maxx-minx)+1;
|
||||
result->h = (maxy-miny)+1;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Use the Cohen-Sutherland algorithm for line clipping */
|
||||
#define CODE_BOTTOM 1
|
||||
#define CODE_TOP 2
|
||||
#define CODE_LEFT 4
|
||||
#define CODE_RIGHT 8
|
||||
|
||||
static int ComputeOutCode(const SDL_Rect * rect, int x, int y)
|
||||
{
|
||||
int code = 0;
|
||||
if (y < 0) {
|
||||
code |= CODE_TOP;
|
||||
} else if (y >= rect->y + rect->h) {
|
||||
code |= CODE_BOTTOM;
|
||||
}
|
||||
if (x < 0) {
|
||||
code |= CODE_LEFT;
|
||||
} else if (x >= rect->x + rect->w) {
|
||||
code |= CODE_RIGHT;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
SDL_bool
|
||||
SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2,
|
||||
int *Y2)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
int rectx1;
|
||||
int recty1;
|
||||
int rectx2;
|
||||
int recty2;
|
||||
int outcode1, outcode2;
|
||||
|
||||
if (!rect || !X1 || !Y1 || !X2 || !Y2) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
x1 = *X1;
|
||||
y1 = *Y1;
|
||||
x2 = *X2;
|
||||
y2 = *Y2;
|
||||
rectx1 = rect->x;
|
||||
recty1 = rect->y;
|
||||
rectx2 = rect->x + rect->w - 1;
|
||||
recty2 = rect->y + rect->h - 1;
|
||||
|
||||
/* Check to see if entire line is inside rect */
|
||||
if (x1 >= rectx1 && x1 <= rectx2 && x2 >= rectx1 && x2 <= rectx2 &&
|
||||
y1 >= recty1 && y1 <= recty2 && y2 >= recty1 && y2 <= recty2) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Check to see if entire line is to one side of rect */
|
||||
if ((x1 < rectx1 && x2 < rectx1) || (x1 > rectx2 && x2 > rectx2) ||
|
||||
(y1 < recty1 && y2 < recty1) || (y1 > recty2 && y2 > recty2)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (y1 == y2) {
|
||||
/* Horizontal line, easy to clip */
|
||||
if (x1 < rectx1) {
|
||||
*X1 = rectx1;
|
||||
} else if (x1 > rectx2) {
|
||||
*X1 = rectx2;
|
||||
}
|
||||
if (x2 < rectx1) {
|
||||
*X2 = rectx1;
|
||||
} else if (x2 > rectx2) {
|
||||
*X2 = rectx2;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if (x1 == x2) {
|
||||
/* Vertical line, easy to clip */
|
||||
if (y1 < recty1) {
|
||||
*Y1 = recty1;
|
||||
} else if (y1 > recty2) {
|
||||
*Y1 = recty2;
|
||||
}
|
||||
if (y2 < recty1) {
|
||||
*Y2 = recty1;
|
||||
} else if (y2 > recty2) {
|
||||
*Y2 = recty2;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* More complicated Cohen-Sutherland algorithm */
|
||||
outcode1 = ComputeOutCode(rect, x1, y1);
|
||||
outcode2 = ComputeOutCode(rect, x2, y2);
|
||||
while (outcode1 || outcode2) {
|
||||
if (outcode1 & outcode2) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (outcode1) {
|
||||
if (outcode1 & CODE_TOP) {
|
||||
y = recty1;
|
||||
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
|
||||
} else if (outcode1 & CODE_BOTTOM) {
|
||||
y = recty2;
|
||||
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
|
||||
} else if (outcode1 & CODE_LEFT) {
|
||||
x = rectx1;
|
||||
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||
} else if (outcode1 & CODE_RIGHT) {
|
||||
x = rectx2;
|
||||
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||
}
|
||||
x1 = x;
|
||||
y1 = y;
|
||||
outcode1 = ComputeOutCode(rect, x, y);
|
||||
} else {
|
||||
if (outcode2 & CODE_TOP) {
|
||||
y = recty1;
|
||||
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
|
||||
} else if (outcode2 & CODE_BOTTOM) {
|
||||
y = recty2;
|
||||
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
|
||||
} else if (outcode2 & CODE_LEFT) {
|
||||
x = rectx1;
|
||||
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||
} else if (outcode2 & CODE_RIGHT) {
|
||||
x = rectx2;
|
||||
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
|
||||
}
|
||||
x2 = x;
|
||||
y2 = y;
|
||||
outcode2 = ComputeOutCode(rect, x, y);
|
||||
}
|
||||
}
|
||||
*X1 = x1;
|
||||
*Y1 = y1;
|
||||
*X2 = x2;
|
||||
*Y2 = y2;
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect)
|
||||
{
|
||||
SDL_DirtyRect *dirty;
|
||||
|
||||
/* FIXME: At what point is this optimization too expensive? */
|
||||
for (dirty = list->list; dirty; dirty = dirty->next) {
|
||||
if (SDL_HasIntersection(&dirty->rect, rect)) {
|
||||
SDL_UnionRect(&dirty->rect, rect, &dirty->rect);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (list->free) {
|
||||
dirty = list->free;
|
||||
list->free = dirty->next;
|
||||
} else {
|
||||
dirty = (SDL_DirtyRect *) SDL_malloc(sizeof(*dirty));
|
||||
if (!dirty) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
dirty->rect = *rect;
|
||||
dirty->next = list->list;
|
||||
list->list = dirty;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_ClearDirtyRects(SDL_DirtyRectList * list)
|
||||
{
|
||||
SDL_DirtyRect *prev, *curr;
|
||||
|
||||
/* Skip to the end of the free list */
|
||||
prev = NULL;
|
||||
for (curr = list->free; curr; curr = curr->next) {
|
||||
prev = curr;
|
||||
}
|
||||
|
||||
/* Add the list entries to the end */
|
||||
if (prev) {
|
||||
prev->next = list->list;
|
||||
} else {
|
||||
list->free = list->list;
|
||||
}
|
||||
list->list = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_FreeDirtyRects(SDL_DirtyRectList * list)
|
||||
{
|
||||
while (list->list) {
|
||||
SDL_DirtyRect *elem = list->list;
|
||||
list->list = elem->next;
|
||||
SDL_free(elem);
|
||||
}
|
||||
while (list->free) {
|
||||
SDL_DirtyRect *elem = list->free;
|
||||
list->free = elem->next;
|
||||
SDL_free(elem);
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/include/SDL_rect.h
|
||||
142
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_rect.h
Normal file
142
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_rect.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_rect.h
|
||||
*
|
||||
* Header file for SDL_rect definition and management functions.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_rect_h
|
||||
#define _SDL_rect_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_version.h"
|
||||
#if ! SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief The structure that defines a point
|
||||
*
|
||||
* \sa SDL_EnclosePoints
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} SDL_Point;
|
||||
|
||||
/**
|
||||
* \brief A rectangle, with the origin at the upper left.
|
||||
*
|
||||
* \sa SDL_RectEmpty
|
||||
* \sa SDL_RectEquals
|
||||
* \sa SDL_HasIntersection
|
||||
* \sa SDL_IntersectRect
|
||||
* \sa SDL_UnionRect
|
||||
* \sa SDL_EnclosePoints
|
||||
*/
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
typedef struct SDL_Rect
|
||||
{
|
||||
int x, y;
|
||||
int w, h;
|
||||
} SDL_Rect;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Returns true if the rectangle has no area.
|
||||
*/
|
||||
#define SDL_RectEmpty(X) (((X)->w <= 0) || ((X)->h <= 0))
|
||||
|
||||
/**
|
||||
* \brief Returns true if the two rectangles are equal.
|
||||
*/
|
||||
#define SDL_RectEquals(A, B) (((A)->x == (B)->x) && ((A)->y == (B)->y) && \
|
||||
((A)->w == (B)->w) && ((A)->h == (B)->h))
|
||||
|
||||
/**
|
||||
* \brief Determine whether two rectangles intersect.
|
||||
*
|
||||
* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
|
||||
const SDL_Rect * B);
|
||||
|
||||
/**
|
||||
* \brief Calculate the intersection of two rectangles.
|
||||
*
|
||||
* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
|
||||
const SDL_Rect * B,
|
||||
SDL_Rect * result);
|
||||
|
||||
/**
|
||||
* \brief Calculate the union of two rectangles.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
|
||||
const SDL_Rect * B,
|
||||
SDL_Rect * result);
|
||||
|
||||
/**
|
||||
* \brief Calculate a minimal rectangle enclosing a set of points
|
||||
*
|
||||
* \return SDL_TRUE if any points were within the clipping rect
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
|
||||
int count,
|
||||
const SDL_Rect * clip,
|
||||
SDL_Rect * result);
|
||||
|
||||
/**
|
||||
* \brief Calculate the intersection of a rectangle and line segment.
|
||||
*
|
||||
* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
|
||||
rect, int *X1,
|
||||
int *Y1, int *X2,
|
||||
int *Y2);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_rect_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/src/video/SDL_rect_c.h
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_rect.h"
|
||||
|
||||
typedef struct SDL_DirtyRect
|
||||
{
|
||||
SDL_Rect rect;
|
||||
struct SDL_DirtyRect *next;
|
||||
} SDL_DirtyRect;
|
||||
|
||||
typedef struct SDL_DirtyRectList
|
||||
{
|
||||
SDL_DirtyRect *list;
|
||||
SDL_DirtyRect *free;
|
||||
} SDL_DirtyRectList;
|
||||
|
||||
extern void SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect);
|
||||
extern void SDL_ClearDirtyRects(SDL_DirtyRectList * list);
|
||||
extern void SDL_FreeDirtyRects(SDL_DirtyRectList * list);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/src/video/SDL_renderer_gles.c
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/src/video/SDL_sysvideo.h
|
||||
@@ -0,0 +1,462 @@
|
||||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2010 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_sysvideo_1_3_h
|
||||
#define _SDL_sysvideo_1_3_h
|
||||
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_keysym.h"
|
||||
#include "SDL_rect.h"
|
||||
|
||||
/* The SDL video driver */
|
||||
|
||||
typedef struct SDL_Renderer SDL_Renderer;
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
typedef struct SDL_VideoDisplay SDL_VideoDisplay;
|
||||
typedef struct SDL_VideoDevice SDL_VideoDevice;
|
||||
|
||||
/* Define the SDL texture structure */
|
||||
struct SDL_Texture
|
||||
{
|
||||
const void *magic;
|
||||
Uint32 format; /**< The pixel format of the texture */
|
||||
int access; /**< SDL_TextureAccess */
|
||||
int w; /**< The width of the texture */
|
||||
int h; /**< The height of the texture */
|
||||
int modMode; /**< The texture modulation mode */
|
||||
int blendMode; /**< The texture blend mode */
|
||||
int scaleMode; /**< The texture scale mode */
|
||||
Uint8 r, g, b, a; /**< Texture modulation values */
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
void *driverdata; /**< Driver specific texture representation */
|
||||
|
||||
SDL_Texture *prev;
|
||||
SDL_Texture *next;
|
||||
};
|
||||
|
||||
/* Define the SDL renderer structure */
|
||||
struct SDL_Renderer
|
||||
{
|
||||
int (*ActivateRenderer) (SDL_Renderer * renderer);
|
||||
int (*DisplayModeChanged) (SDL_Renderer * renderer);
|
||||
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
void **pixels, int *pitch);
|
||||
int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Color * colors, int firstcolor,
|
||||
int ncolors);
|
||||
int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
SDL_Color * colors, int firstcolor,
|
||||
int ncolors);
|
||||
int (*SetTextureColorMod) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*SetTextureBlendMode) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*SetTextureScaleMode) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, int markDirty, void **pixels,
|
||||
int *pitch);
|
||||
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
int numrects, const SDL_Rect * rects);
|
||||
int (*SetDrawColor) (SDL_Renderer * renderer);
|
||||
int (*SetDrawBlendMode) (SDL_Renderer * renderer);
|
||||
int (*RenderClear) (SDL_Renderer * renderer);
|
||||
int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
|
||||
int count);
|
||||
int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
|
||||
int count);
|
||||
int (*RenderDrawRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
|
||||
int count);
|
||||
int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
|
||||
int count);
|
||||
int (*RenderDrawEllipse) (SDL_Renderer * renderer, int x, int y,
|
||||
int w, int h);
|
||||
int (*RenderFillEllipse) (SDL_Renderer * renderer, int x, int y,
|
||||
int w, int h);
|
||||
int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * dstrect);
|
||||
int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch);
|
||||
int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, const void * pixels, int pitch);
|
||||
void (*RenderPresent) (SDL_Renderer * renderer);
|
||||
void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
|
||||
void (*DestroyRenderer) (SDL_Renderer * renderer);
|
||||
|
||||
/* The current renderer info */
|
||||
SDL_RendererInfo info;
|
||||
|
||||
/* The window associated with the renderer */
|
||||
SDL_Window *window;
|
||||
|
||||
/* The list of textures */
|
||||
SDL_Texture *textures;
|
||||
|
||||
Uint8 r, g, b, a; /**< Color for drawing operations values */
|
||||
int blendMode; /**< The drawing blend mode */
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Define the SDL render driver structure */
|
||||
struct SDL_RenderDriver
|
||||
{
|
||||
SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
|
||||
|
||||
/* Info about the renderer capabilities */
|
||||
SDL_RendererInfo info;
|
||||
/* Used for resizing renderer */
|
||||
size_t infoSize;
|
||||
};
|
||||
|
||||
/* Define the SDL window structure, corresponding to toplevel windows */
|
||||
struct SDL_Window
|
||||
{
|
||||
const void *magic;
|
||||
Uint32 id;
|
||||
char *title;
|
||||
int x, y;
|
||||
int w, h;
|
||||
Uint32 flags;
|
||||
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
SDL_DisplayMode fullscreen_mode;
|
||||
|
||||
void *userdata;
|
||||
void *driverdata;
|
||||
|
||||
SDL_Window *prev;
|
||||
SDL_Window *next;
|
||||
};
|
||||
#define FULLSCREEN_VISIBLE(W) \
|
||||
(((W)->flags & SDL_WINDOW_FULLSCREEN) && \
|
||||
((W)->flags & SDL_WINDOW_SHOWN) && \
|
||||
!((W)->flags & SDL_WINDOW_MINIMIZED))
|
||||
|
||||
/*
|
||||
* Define the SDL display structure This corresponds to physical monitors
|
||||
* attached to the system.
|
||||
*/
|
||||
struct SDL_VideoDisplay
|
||||
{
|
||||
int max_display_modes;
|
||||
int num_display_modes;
|
||||
SDL_DisplayMode *display_modes;
|
||||
SDL_DisplayMode desktop_mode;
|
||||
SDL_DisplayMode current_mode;
|
||||
SDL_bool updating_fullscreen;
|
||||
SDL_Palette *palette;
|
||||
|
||||
Uint16 *gamma;
|
||||
Uint16 *saved_gamma; /* (just offset into gamma) */
|
||||
|
||||
int num_render_drivers;
|
||||
SDL_RenderDriver *render_drivers;
|
||||
|
||||
SDL_Window *windows;
|
||||
SDL_Window *fullscreen_window;
|
||||
|
||||
SDL_Renderer *current_renderer;
|
||||
|
||||
SDL_VideoDevice *device;
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Define the SDL video driver structure */
|
||||
#define _THIS SDL_VideoDevice *_this
|
||||
|
||||
struct SDL_VideoDevice
|
||||
{
|
||||
/* * * */
|
||||
/* The name of this video driver */
|
||||
const char *name;
|
||||
|
||||
/* * * */
|
||||
/* Initialization/Query functions */
|
||||
|
||||
/*
|
||||
* Initialize the native video subsystem, filling in the list of
|
||||
* displays for this driver, returning 0 or -1 if there's an error.
|
||||
*/
|
||||
int (*VideoInit) (_THIS);
|
||||
|
||||
/*
|
||||
* Reverse the effects VideoInit() -- called if VideoInit() fails or
|
||||
* if the application is shutting down the video subsystem.
|
||||
*/
|
||||
void (*VideoQuit) (_THIS);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* Display functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get the bounds of a display
|
||||
*/
|
||||
int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||
|
||||
/*
|
||||
* Get a list of the available display modes. e.g.
|
||||
* SDL_AddDisplayMode(_this->current_display, mode)
|
||||
*/
|
||||
void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
|
||||
|
||||
/*
|
||||
* Setting the display mode is independent of creating windows, so
|
||||
* when the display mode is changed, all existing windows should have
|
||||
* their data updated accordingly, including the display surfaces
|
||||
* associated with them.
|
||||
*/
|
||||
int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
|
||||
/* Set the color entries of the display palette */
|
||||
int (*SetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
|
||||
|
||||
/* Get the color entries of the display palette */
|
||||
int (*GetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
|
||||
|
||||
/* Set the gamma ramp */
|
||||
int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
|
||||
|
||||
/* Get the gamma ramp */
|
||||
int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* Window functions
|
||||
*/
|
||||
int (*CreateWindow) (_THIS, SDL_Window * window);
|
||||
int (*CreateWindowFrom) (_THIS, SDL_Window * window, const void *data);
|
||||
void (*SetWindowTitle) (_THIS, SDL_Window * window);
|
||||
void (*SetWindowIcon) (_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||
void (*SetWindowPosition) (_THIS, SDL_Window * window);
|
||||
void (*SetWindowSize) (_THIS, SDL_Window * window);
|
||||
void (*ShowWindow) (_THIS, SDL_Window * window);
|
||||
void (*HideWindow) (_THIS, SDL_Window * window);
|
||||
void (*RaiseWindow) (_THIS, SDL_Window * window);
|
||||
void (*MaximizeWindow) (_THIS, SDL_Window * window);
|
||||
void (*MinimizeWindow) (_THIS, SDL_Window * window);
|
||||
void (*RestoreWindow) (_THIS, SDL_Window * window);
|
||||
void (*SetWindowGrab) (_THIS, SDL_Window * window);
|
||||
void (*DestroyWindow) (_THIS, SDL_Window * window);
|
||||
|
||||
/* Get some platform dependent window information */
|
||||
SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo * info);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* OpenGL support
|
||||
*/
|
||||
int (*GL_LoadLibrary) (_THIS, const char *path);
|
||||
void *(*GL_GetProcAddress) (_THIS, const char *proc);
|
||||
void (*GL_UnloadLibrary) (_THIS);
|
||||
SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
|
||||
int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
|
||||
int (*GL_SetSwapInterval) (_THIS, int interval);
|
||||
int (*GL_GetSwapInterval) (_THIS);
|
||||
void (*GL_SwapWindow) (_THIS, SDL_Window * window);
|
||||
void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
|
||||
|
||||
/* * * */
|
||||
/*
|
||||
* Event manager functions
|
||||
*/
|
||||
void (*PumpEvents) (_THIS);
|
||||
|
||||
/* Suspend the screensaver */
|
||||
void (*SuspendScreenSaver) (_THIS);
|
||||
|
||||
/* Text input */
|
||||
void (*StartTextInput) (_THIS);
|
||||
void (*StopTextInput) (_THIS);
|
||||
void (*SetTextInputRect) (_THIS, SDL_Rect *rect);
|
||||
|
||||
/* Clipboard */
|
||||
int (*SetClipboardText) (_THIS, const char *text);
|
||||
char * (*GetClipboardText) (_THIS);
|
||||
SDL_bool (*HasClipboardText) (_THIS);
|
||||
|
||||
/* * * */
|
||||
/* Data common to all drivers */
|
||||
SDL_bool suspend_screensaver;
|
||||
int num_displays;
|
||||
SDL_VideoDisplay *displays;
|
||||
int current_display;
|
||||
Uint8 window_magic;
|
||||
Uint8 texture_magic;
|
||||
Uint32 next_object_id;
|
||||
char * clipboard_text;
|
||||
|
||||
/* * * */
|
||||
/* Data used by the GL drivers */
|
||||
struct
|
||||
{
|
||||
int red_size;
|
||||
int green_size;
|
||||
int blue_size;
|
||||
int alpha_size;
|
||||
int depth_size;
|
||||
int buffer_size;
|
||||
int stencil_size;
|
||||
int double_buffer;
|
||||
int accum_red_size;
|
||||
int accum_green_size;
|
||||
int accum_blue_size;
|
||||
int accum_alpha_size;
|
||||
int stereo;
|
||||
int multisamplebuffers;
|
||||
int multisamplesamples;
|
||||
int accelerated;
|
||||
int major_version;
|
||||
int minor_version;
|
||||
int retained_backing;
|
||||
int driver_loaded;
|
||||
char driver_path[256];
|
||||
void *dll_handle;
|
||||
} gl_config;
|
||||
|
||||
/* * * */
|
||||
/* Data private to this driver */
|
||||
void *driverdata;
|
||||
struct SDL_GLDriverData *gl_data;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
struct SDL_PrivateGLESData *gles_data;
|
||||
#endif
|
||||
|
||||
/* * * */
|
||||
/* The function used to dispose of this structure */
|
||||
void (*free) (_THIS);
|
||||
};
|
||||
|
||||
typedef struct VideoBootStrap
|
||||
{
|
||||
const char *name;
|
||||
const char *desc;
|
||||
int (*available) (void);
|
||||
SDL_VideoDevice *(*create) (int devindex);
|
||||
} VideoBootStrap;
|
||||
|
||||
#if SDL_VIDEO_DRIVER_COCOA
|
||||
extern VideoBootStrap COCOA_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_X11
|
||||
extern VideoBootStrap X11_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_FBCON
|
||||
extern VideoBootStrap FBCON_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DIRECTFB
|
||||
extern VideoBootStrap DirectFB_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PS3
|
||||
extern VideoBootStrap PS3_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_SVGALIB
|
||||
extern VideoBootStrap SVGALIB_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_GAPI
|
||||
extern VideoBootStrap GAPI_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_WIN32
|
||||
extern VideoBootStrap WIN32_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_BWINDOW
|
||||
extern VideoBootStrap BWINDOW_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PHOTON
|
||||
extern VideoBootStrap photon_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_QNXGF
|
||||
extern VideoBootStrap qnxgf_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_EPOC
|
||||
extern VideoBootStrap EPOC_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_RISCOS
|
||||
extern VideoBootStrap RISCOS_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_UIKIT
|
||||
extern VideoBootStrap UIKIT_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_ANDROID
|
||||
extern VideoBootStrap ANDROID_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
extern VideoBootStrap DUMMY_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_NDS
|
||||
extern VideoBootStrap NDS_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
extern VideoBootStrap PND_bootstrap;
|
||||
#endif
|
||||
|
||||
#define SDL_CurrentDisplay (&_this->displays[_this->current_display])
|
||||
#define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer)
|
||||
|
||||
extern SDL_VideoDevice *SDL_GetVideoDevice(void);
|
||||
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
|
||||
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
|
||||
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
|
||||
extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display);
|
||||
extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode);
|
||||
extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
|
||||
extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
|
||||
extern int SDL_SetPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors);
|
||||
extern int SDL_GetPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors);
|
||||
extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
|
||||
extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
|
||||
extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver);
|
||||
|
||||
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
|
||||
|
||||
extern void SDL_OnWindowShown(SDL_Window * window);
|
||||
extern void SDL_OnWindowHidden(SDL_Window * window);
|
||||
extern void SDL_OnWindowResized(SDL_Window * window);
|
||||
extern void SDL_OnWindowMinimized(SDL_Window * window);
|
||||
extern void SDL_OnWindowRestored(SDL_Window * window);
|
||||
extern void SDL_OnWindowFocusGained(SDL_Window * window);
|
||||
extern void SDL_OnWindowFocusLost(SDL_Window * window);
|
||||
extern SDL_Window * SDL_GetFocusWindow(void);
|
||||
|
||||
#endif /* _SDL_sysvideo_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/include/SDL_video.h
|
||||
1468
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_video-1.3.h
Normal file
1468
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_video-1.3.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
../../../../sdl-1.3/src/video/SDL_video.c
|
||||
3675
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_video.c
Normal file
3675
alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_video.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -29,14 +29,6 @@
|
||||
#ifndef _SDL_pixels_h
|
||||
#define _SDL_pixels_h
|
||||
|
||||
#include "SDL_version.h"
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#else
|
||||
#include "SDL_video-1.3.h"
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
@@ -227,7 +219,6 @@ enum
|
||||
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_2101010, 32, 4),
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
|
||||
SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */
|
||||
@@ -238,10 +229,8 @@ enum
|
||||
SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
|
||||
SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
|
||||
#endif
|
||||
};
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
typedef struct SDL_Color
|
||||
{
|
||||
Uint8 r;
|
||||
@@ -285,7 +274,6 @@ typedef struct SDL_PixelFormat
|
||||
Uint32 Bmask;
|
||||
Uint32 Amask;
|
||||
} SDL_PixelFormat;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
|
||||
@@ -332,7 +320,6 @@ extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
|
||||
*
|
||||
* \sa SDL_DelPaletteWatch()
|
||||
*/
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
|
||||
SDL_PaletteChangedFunc
|
||||
callback, void *userdata);
|
||||
@@ -346,7 +333,7 @@ extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
|
||||
extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette,
|
||||
SDL_PaletteChangedFunc
|
||||
callback, void *userdata);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Set a range of colors in a palette.
|
||||
*
|
||||
|
||||
@@ -31,11 +31,8 @@
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_version.h"
|
||||
#if ! SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
@@ -66,13 +63,11 @@ typedef struct
|
||||
* \sa SDL_UnionRect
|
||||
* \sa SDL_EnclosePoints
|
||||
*/
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
typedef struct SDL_Rect
|
||||
{
|
||||
int x, y;
|
||||
int w, h;
|
||||
} SDL_Rect;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Returns true if the rectangle has no area.
|
||||
|
||||
@@ -26,17 +26,13 @@
|
||||
* Header file for SDL video functions.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_video_1_3_h
|
||||
#define _SDL_video_1_3_h
|
||||
#ifndef _SDL_video_h
|
||||
#define _SDL_video_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include "SDL_rect.h"
|
||||
#include "SDL_surface.h"
|
||||
#include "SDL_version.h"
|
||||
#if ! SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
@@ -260,7 +256,6 @@ typedef struct SDL_Texture SDL_Texture;
|
||||
*/
|
||||
typedef void *SDL_GLContext;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
/**
|
||||
* \brief OpenGL configuration attributes
|
||||
*/
|
||||
@@ -286,7 +281,7 @@ typedef enum
|
||||
SDL_GL_CONTEXT_MAJOR_VERSION,
|
||||
SDL_GL_CONTEXT_MINOR_VERSION
|
||||
} SDL_GLattr;
|
||||
#endif
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
@@ -323,13 +318,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index);
|
||||
*
|
||||
* \sa SDL_VideoQuit()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
SDL_VideoInit
|
||||
#else
|
||||
SDL_VideoInit_1_3
|
||||
#endif
|
||||
(const char *driver_name, Uint32 flags);
|
||||
extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name,
|
||||
Uint32 flags);
|
||||
|
||||
/**
|
||||
* \brief Shuts down the video subsystem.
|
||||
|
||||
@@ -20,32 +20,22 @@
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
/* General (mostly internal) pixel/color manipulation routines for SDL */
|
||||
|
||||
#include "SDL_endian.h"
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#else
|
||||
#include "SDL_video-1.3.h"
|
||||
#include "SDL_sysvideo-1.3.h"
|
||||
#endif
|
||||
#include "SDL_blit.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_RLEaccel_c.h"
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
struct SDL_PaletteWatch
|
||||
{
|
||||
SDL_PaletteChangedFunc callback;
|
||||
void *userdata;
|
||||
struct SDL_PaletteWatch *next;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Helper functions */
|
||||
|
||||
@@ -298,7 +288,7 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
|
||||
return SDL_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
SDL_Palette *
|
||||
SDL_AllocPalette(int ncolors)
|
||||
{
|
||||
@@ -438,8 +428,6 @@ SDL_AllocFormat(int bpp,
|
||||
return SDL_InitFormat(format, bpp, Rmask, Gmask, Bmask, Amask);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SDL_PixelFormat *
|
||||
SDL_InitFormat(SDL_PixelFormat * format, int bpp, Uint32 Rmask, Uint32 Gmask,
|
||||
Uint32 Bmask, Uint32 Amask)
|
||||
@@ -520,8 +508,6 @@ SDL_InitFormat(SDL_PixelFormat * format, int bpp, Uint32 Rmask, Uint32 Gmask,
|
||||
return format;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
/*
|
||||
* Change any previous mappings from/to the new surface format
|
||||
*/
|
||||
@@ -597,11 +583,7 @@ SDL_CalculatePitch(SDL_Surface * surface)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 4-byte aligning adds extra memcpy() with OpenGL ES renderer
|
||||
// TODO: check if we really can disable that for Android
|
||||
#ifndef ANDROID
|
||||
pitch = (pitch + 3) & ~3; /* 4-byte aligning */
|
||||
#endif
|
||||
return (pitch);
|
||||
}
|
||||
|
||||
@@ -931,6 +913,5 @@ SDL_FreeBlitMap(SDL_BlitMap * map)
|
||||
SDL_free(map);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
/* Useful functions and variables from SDL_pixel.c */
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_rect.h"
|
||||
|
||||
typedef struct SDL_DirtyRect
|
||||
{
|
||||
|
||||
@@ -20,23 +20,15 @@
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL_ES
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#else
|
||||
#include "SDL_video-1.3.h"
|
||||
#include "SDL_sysvideo-1.3.h"
|
||||
#endif
|
||||
#include "SDL_opengles.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
#include "SDL_rect_c.h"
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_yuv_sw_c.h"
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
@@ -229,13 +221,11 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
GLint value;
|
||||
int doublebuffer;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||
if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
@@ -313,15 +303,11 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
// Always double-buffered
|
||||
#else
|
||||
if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
|
||||
if (!doublebuffer) {
|
||||
renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PANDORA
|
||||
data->GL_OES_draw_texture_supported = SDL_FALSE;
|
||||
data->useDrawTexture = SDL_FALSE;
|
||||
@@ -369,7 +355,6 @@ GLES_ActivateRenderer(SDL_Renderer * renderer)
|
||||
data->glMatrixMode(GL_MODELVIEW);
|
||||
data->glLoadIdentity();
|
||||
#if SDL_VIDEO_RENDER_RESIZE
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "GLES_ActivateRenderer(): %dx%d", (int)window->display->desktop_mode.w, (int)window->display->desktop_mode.h);
|
||||
data->glViewport(0, 0, window->display->desktop_mode.w, window->display->desktop_mode.h);
|
||||
data->glOrthof(0.0, (GLfloat) window->display->desktop_mode.w, (GLfloat) window->display->desktop_mode.h,
|
||||
0.0, 0.0, 1.0);
|
||||
@@ -951,7 +936,6 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
|
||||
/* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
GLint cropRect[4];
|
||||
cropRect[0] = srcrect->x;
|
||||
cropRect[1] = srcrect->y + srcrect->h;
|
||||
|
||||
@@ -21,12 +21,11 @@
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_sysvideo_1_3_h
|
||||
#define _SDL_sysvideo_1_3_h
|
||||
#ifndef _SDL_sysvideo_h
|
||||
#define _SDL_sysvideo_h
|
||||
|
||||
#include "SDL_mouse.h"
|
||||
#include "SDL_keysym.h"
|
||||
#include "SDL_rect.h"
|
||||
|
||||
/* The SDL video driver */
|
||||
|
||||
|
||||
@@ -20,28 +20,19 @@
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
/* The high-level video driver subsystem */
|
||||
|
||||
#include "SDL.h"
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_sysvideo.h"
|
||||
#else
|
||||
#include "SDL_video-1.3.h"
|
||||
#include "SDL_sysvideo-1.3.h"
|
||||
#include "SDL_androidvideo.h"
|
||||
#endif
|
||||
#include "SDL_blit.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
#include "SDL_renderer_gl.h"
|
||||
#include "SDL_renderer_gles.h"
|
||||
#include "SDL_renderer_sw.h"
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
#include "../events/SDL_sysevents.h"
|
||||
#include "../events/SDL_events_c.h"
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
@@ -191,12 +182,8 @@ SDL_GetVideoDriver(int index)
|
||||
/*
|
||||
* Initialize the video and event subsystems -- determine native pixel format
|
||||
*/
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
int SDL_VideoInit
|
||||
#else
|
||||
int SDL_VideoInit_1_3
|
||||
#endif
|
||||
(const char *driver_name, Uint32 flags)
|
||||
int
|
||||
SDL_VideoInit(const char *driver_name, Uint32 flags)
|
||||
{
|
||||
SDL_VideoDevice *video;
|
||||
int index;
|
||||
@@ -207,7 +194,6 @@ int SDL_VideoInit_1_3
|
||||
SDL_VideoQuit();
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
/* Toggle the event thread flags, based on OS requirements */
|
||||
#if defined(MUST_THREAD_EVENTS)
|
||||
flags |= SDL_INIT_EVENTTHREAD;
|
||||
@@ -222,11 +208,10 @@ int SDL_VideoInit_1_3
|
||||
if (SDL_StartEventLoop(flags) < 0) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Select the proper video driver */
|
||||
index = 0;
|
||||
video = NULL;
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (driver_name == NULL) {
|
||||
driver_name = SDL_getenv("SDL_VIDEODRIVER");
|
||||
}
|
||||
@@ -255,14 +240,8 @@ int SDL_VideoInit_1_3
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
_this = video;
|
||||
_this->name = bootstrap[i]->name;
|
||||
#else
|
||||
video = ANDROID_CreateDevice_1_3(0);
|
||||
_this = video;
|
||||
_this->name = "android";
|
||||
#endif
|
||||
_this->next_object_id = 1;
|
||||
|
||||
|
||||
@@ -311,11 +290,9 @@ int SDL_VideoInit_1_3
|
||||
SDL_AddRenderDriver(display, &GL_ES_RenderDriver);
|
||||
#endif
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (display->num_render_drivers > 0) {
|
||||
SDL_AddRenderDriver(display, &SW_RenderDriver);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We're ready to go! */
|
||||
@@ -721,7 +698,6 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
|
||||
}
|
||||
display->current_mode = display_mode;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
/* Set up a palette, if necessary */
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) {
|
||||
ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format));
|
||||
@@ -743,7 +719,6 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
|
||||
SDL_BITSPERPIXEL(display_mode.format));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -789,8 +764,6 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
static void
|
||||
SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt)
|
||||
{
|
||||
@@ -908,8 +881,6 @@ SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors)
|
||||
return SDL_GetPaletteForDisplay(SDL_CurrentDisplay, colors, firstcolor, ncolors);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SDL_Window *
|
||||
SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
{
|
||||
@@ -921,7 +892,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
SDL_VideoDisplay *display;
|
||||
SDL_Window *window;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (!_this) {
|
||||
/* Initialize the video system if needed */
|
||||
if (SDL_VideoInit(NULL, 0) < 0) {
|
||||
@@ -935,8 +905,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
}
|
||||
SDL_GL_LoadLibrary(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
display = SDL_CurrentDisplay;
|
||||
window = (SDL_Window *)SDL_calloc(1, sizeof(*window));
|
||||
window->magic = &_this->window_magic;
|
||||
@@ -953,7 +921,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
}
|
||||
display->windows = window;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) {
|
||||
SDL_DestroyWindow(window);
|
||||
return NULL;
|
||||
@@ -972,13 +939,10 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
SDL_ShowWindow(window);
|
||||
}
|
||||
SDL_UpdateWindowGrab(window);
|
||||
#endif
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
SDL_Window *
|
||||
SDL_CreateWindowFrom(const void *data)
|
||||
{
|
||||
@@ -1072,7 +1036,6 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline__ SDL_Renderer *
|
||||
SDL_GetCurrentRenderer(SDL_bool create)
|
||||
@@ -1093,7 +1056,6 @@ SDL_GetCurrentRenderer(SDL_bool create)
|
||||
return SDL_CurrentRenderer;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
Uint32
|
||||
SDL_GetWindowID(SDL_Window * window)
|
||||
{
|
||||
@@ -1485,8 +1447,6 @@ SDL_GetFocusWindow(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
SDL_DestroyWindow(SDL_Window * window)
|
||||
{
|
||||
@@ -1502,19 +1462,15 @@ SDL_DestroyWindow(SDL_Window * window)
|
||||
SDL_DestroyRenderer(window);
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
/* Restore video mode, etc. */
|
||||
SDL_UpdateFullscreenMode(window, SDL_FALSE);
|
||||
#endif
|
||||
|
||||
if (_this->DestroyWindow) {
|
||||
_this->DestroyWindow(_this, window);
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
SDL_GL_UnloadLibrary();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Unlink the window from the list */
|
||||
display = window->display;
|
||||
@@ -1579,7 +1535,6 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
||||
/* Free any existing renderer */
|
||||
SDL_DestroyRenderer(window);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (index < 0) {
|
||||
char *override = SDL_getenv("SDL_VIDEO_RENDERER");
|
||||
int n = SDL_GetNumRenderDrivers();
|
||||
@@ -1633,9 +1588,6 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
||||
/* Create a new renderer instance */
|
||||
window->renderer = SDL_CurrentDisplay->render_drivers[index].CreateRenderer(window, flags);
|
||||
}
|
||||
#else
|
||||
window->renderer = GL_ES_RenderDriver.CreateRenderer(window, flags);
|
||||
#endif
|
||||
|
||||
if (window->renderer == NULL) {
|
||||
/* Assuming renderer set its error */
|
||||
@@ -1754,13 +1706,8 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
|
||||
}
|
||||
} else {
|
||||
if (surface->format->Amask
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|| !(surface->map->info.flags &
|
||||
(SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
|
||||
#else
|
||||
|| !(surface->flags &
|
||||
(SDL_SRCCOLORKEY | SDL_SRCALPHA))) {
|
||||
#endif
|
||||
Uint32 it;
|
||||
int pfmt;
|
||||
|
||||
@@ -1985,7 +1932,6 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
|
||||
|
||||
/* Set up a destination surface for the texture update */
|
||||
SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask);
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(format)) {
|
||||
dst_fmt.palette =
|
||||
SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
|
||||
@@ -1998,17 +1944,14 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
|
||||
SDL_BITSPERPIXEL(format));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
dst = SDL_ConvertSurface(surface, &dst_fmt, 0);
|
||||
if (dst) {
|
||||
SDL_UpdateTexture(texture, NULL, dst->pixels, dst->pitch);
|
||||
SDL_FreeSurface(dst);
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (dst_fmt.palette) {
|
||||
SDL_FreePalette(dst_fmt.palette);
|
||||
}
|
||||
#endif
|
||||
if (!dst) {
|
||||
SDL_DestroyTexture(texture);
|
||||
return 0;
|
||||
@@ -2020,7 +1963,6 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
|
||||
int blendMode;
|
||||
int scaleMode;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
SDL_GetSurfaceColorMod(surface, &r, &g, &b);
|
||||
SDL_SetTextureColorMod(texture, r, g, b);
|
||||
|
||||
@@ -2032,20 +1974,12 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
|
||||
|
||||
SDL_GetSurfaceScaleMode(surface, &scaleMode);
|
||||
SDL_SetTextureScaleMode(texture, scaleMode);
|
||||
#else
|
||||
if(surface->flags & SDL_SRCALPHA) {
|
||||
SDL_SetTextureAlphaMod(texture, surface->format->alpha);
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) {
|
||||
SDL_SetTexturePalette(texture, fmt->palette->colors, 0,
|
||||
fmt->palette->ncolors);
|
||||
}
|
||||
#endif
|
||||
return texture;
|
||||
}
|
||||
|
||||
@@ -3020,8 +2954,6 @@ SDL_DisableScreenSaver()
|
||||
}
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
void
|
||||
SDL_VideoQuit(void)
|
||||
{
|
||||
@@ -3156,8 +3088,6 @@ SDL_GL_UnloadLibrary(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SDL_bool
|
||||
SDL_GL_ExtensionSupported(const char *extension)
|
||||
{
|
||||
@@ -3212,8 +3142,6 @@ SDL_GL_ExtensionSupported(const char *extension)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
|
||||
int
|
||||
SDL_GL_SetAttribute(SDL_GLattr attr, int value)
|
||||
{
|
||||
@@ -3451,8 +3379,6 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
|
||||
#endif /* SDL_VIDEO_OPENGL */
|
||||
}
|
||||
|
||||
#endif /* SDL 1.3.0 */
|
||||
|
||||
SDL_GLContext
|
||||
SDL_GL_CreateContext(SDL_Window * window)
|
||||
{
|
||||
@@ -3631,7 +3557,6 @@ SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
SDL_bool
|
||||
SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info)
|
||||
{
|
||||
@@ -3670,6 +3595,5 @@ SDL_SetTextInputRect(SDL_Rect *rect)
|
||||
_this->SetTextInputRect(_this, rect);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
Reference in New Issue
Block a user