SDL
2.0
|
#include "../SDL_internal.h"
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#include "SDL_blit.h"
#include "SDL_RLEaccel_c.h"
#include "SDL_pixels_c.h"
#include "SDL_yuv_c.h"
Go to the source code of this file.
Definition at line 39 of file SDL_surface.c.
References SDL_BITSPERPIXEL, and SDL_BYTESPERPIXEL.
Referenced by SDL_CreateRGBSurfaceWithFormat().
SDL_COMPILE_TIME_ASSERT | ( | surface_size_assumptions | , |
sizeof(int) | = =sizeof(Sint32) |
||
) |
|
static |
Definition at line 334 of file SDL_surface.c.
References SDL_PixelFormat::Amask, SDL_PixelFormat::BytesPerPixel, SDL_BlitInfo::colorkey, SDL_BlitInfo::flags, SDL_Surface::format, SDL_Surface::h, SDL_BlitMap::info, SDL_Surface::map, SDL_Surface::pitch, SDL_Surface::pixels, SDL_BLENDMODE_BLEND, SDL_COPY_COLORKEY, SDL_LockSurface(), SDL_SetColorKey(), SDL_SetSurfaceBlendMode(), SDL_UnlockSurface(), and SDL_Surface::w.
Referenced by SDL_ConvertSurface().
int SDL_ConvertPixels | ( | int | width, |
int | height, | ||
Uint32 | src_format, | ||
const void * | src, | ||
int | src_pitch, | ||
Uint32 | dst_format, | ||
void * | dst, | ||
int | dst_pitch | ||
) |
Copy a block of pixels of one format to another format.
Definition at line 1158 of file SDL_surface.c.
References SDL_Rect::h, i, rect, SDL_BYTESPERPIXEL, SDL_ConvertPixels_RGB_to_YUV(), SDL_ConvertPixels_YUV_to_RGB(), SDL_ConvertPixels_YUV_to_YUV(), SDL_CreateSurfaceOnStack(), SDL_InvalidParamError, SDL_ISPIXELFORMAT_FOURCC, SDL_LowerBlit(), SDL_memcpy, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.
SDL_Surface* SDL_ConvertSurface | ( | SDL_Surface * | src, |
const SDL_PixelFormat * | fmt, | ||
Uint32 | flags | ||
) |
Creates a new surface of the specified format, and then copies and maps the given surface to it so the blit of the converted surface will be as fast as possible. If this function fails, it returns NULL.
The flags
parameter is passed to SDL_CreateRGBSurface() and has those semantics. You can also pass SDL_RLEACCEL in the flags parameter and SDL will try to RLE accelerate colorkey and alpha blits in the resulting surface.
Definition at line 945 of file SDL_surface.c.
References SDL_BlitInfo::a, SDL_Color::a, SDL_PixelFormat::Amask, SDL_BlitInfo::b, SDL_Color::b, SDL_PixelFormat::BitsPerPixel, SDL_PixelFormat::Bmask, SDL_PixelFormat::BytesPerPixel, SDL_Surface::clip_rect, SDL_BlitInfo::colorkey, SDL_Palette::colors, SDL_BlitInfo::flags, SDL_Surface::format, SDL_BlitInfo::g, SDL_Color::g, SDL_PixelFormat::Gmask, SDL_Rect::h, SDL_Surface::h, i, SDL_BlitMap::info, SDL_Surface::map, SDL_Palette::ncolors, NULL, SDL_PixelFormat::palette, SDL_Surface::pixels, SDL_BlitInfo::r, SDL_Color::r, SDL_PixelFormat::Rmask, SDL_BLENDMODE_BLEND, SDL_ConvertColorkeyToAlpha(), SDL_COPY_BLEND, SDL_COPY_COLORKEY, SDL_COPY_MODULATE_ALPHA, SDL_COPY_RLE_ALPHAKEY, SDL_COPY_RLE_COLORKEY, SDL_COPY_RLE_DESIRED, SDL_CreateRGBSurface(), SDL_FALSE, SDL_FillRect, SDL_FreeSurface(), SDL_InvalidateMap(), SDL_InvalidParamError, SDL_LowerBlit(), SDL_memcmp, SDL_memcpy, SDL_RLEACCEL, SDL_SetClipRect(), SDL_SetColorKey(), SDL_SetError, SDL_SetSurfaceBlendMode(), SDL_SetSurfacePalette(), SDL_SetSurfaceRLE(), SDL_TRUE, SDL_Rect::w, SDL_Surface::w, SDL_Rect::x, and SDL_Rect::y.
Referenced by SDL_ConvertSurfaceFormat(), and SDL_DuplicateSurface().
SDL_Surface* SDL_ConvertSurfaceFormat | ( | SDL_Surface * | surface, |
Uint32 | pixel_format, | ||
Uint32 | flags | ||
) |
Definition at line 1102 of file SDL_surface.c.
References NULL, SDL_AllocFormat, SDL_ConvertSurface(), SDL_FreeFormat, and SDL_INLINE.
SDL_Surface* SDL_CreateRGBSurface | ( | Uint32 | flags, |
int | width, | ||
int | height, | ||
int | depth, | ||
Uint32 | Rmask, | ||
Uint32 | Gmask, | ||
Uint32 | Bmask, | ||
Uint32 | Amask | ||
) |
Allocate and free an RGB surface.
If the depth is 4 or 8 bits, an empty palette is allocated for the surface. If the depth is greater than 8 bits, the pixel format is set using the flags '[RGB]mask'.
If the function runs out of memory, it will return NULL.
flags | The flags are obsolete and should be set to 0. |
width | The width in pixels of the surface to create. |
height | The height in pixels of the surface to create. |
depth | The depth in bits of the surface to create. |
Rmask | The red mask of the surface to create. |
Gmask | The green mask of the surface to create. |
Bmask | The blue mask of the surface to create. |
Amask | The alpha mask of the surface to create. |
Definition at line 159 of file SDL_surface.c.
References NULL, SDL_CreateRGBSurfaceWithFormat(), SDL_MasksToPixelFormatEnum, SDL_PIXELFORMAT_UNKNOWN, and SDL_SetError.
Referenced by SDL_ConvertSurface(), and SDL_CreateRGBSurfaceFrom().
SDL_Surface* SDL_CreateRGBSurfaceFrom | ( | void * | pixels, |
int | width, | ||
int | height, | ||
int | depth, | ||
int | pitch, | ||
Uint32 | Rmask, | ||
Uint32 | Gmask, | ||
Uint32 | Bmask, | ||
Uint32 | Amask | ||
) |
Definition at line 179 of file SDL_surface.c.
References SDL_Surface::flags, SDL_Surface::h, NULL, SDL_Surface::pitch, SDL_Surface::pixels, SDL_CreateRGBSurface(), SDL_PREALLOC, SDL_SetClipRect(), and SDL_Surface::w.
SDL_Surface* SDL_CreateRGBSurfaceWithFormat | ( | Uint32 | flags, |
int | width, | ||
int | height, | ||
int | depth, | ||
Uint32 | format | ||
) |
Definition at line 64 of file SDL_surface.c.
References SDL_PixelFormat::Amask, SDL_Color::b, SDL_PixelFormat::BitsPerPixel, SDL_Palette::colors, SDL_Surface::format, SDL_PixelFormat::format, SDL_Color::g, SDL_Surface::h, SDL_Surface::map, SDL_Palette::ncolors, NULL, SDL_Surface::pitch, SDL_Surface::pixels, SDL_Color::r, SDL_Surface::refcount, SDL_AllocBlitMap(), SDL_AllocFormat, SDL_AllocPalette, SDL_BLENDMODE_BLEND, SDL_CalculatePitch(), SDL_calloc, SDL_FreePalette, SDL_FreeSurface(), SDL_ISPIXELFORMAT_INDEXED, SDL_malloc, SDL_MAX_SINT32, SDL_memset, SDL_OutOfMemory, SDL_SetClipRect(), SDL_SetSurfaceBlendMode(), SDL_SetSurfacePalette(), void, and SDL_Surface::w.
Referenced by SDL_CreateRGBSurface(), and SDL_CreateRGBSurfaceWithFormatFrom().
SDL_Surface* SDL_CreateRGBSurfaceWithFormatFrom | ( | void * | pixels, |
int | width, | ||
int | height, | ||
int | depth, | ||
int | pitch, | ||
Uint32 | format | ||
) |
Definition at line 203 of file SDL_surface.c.
References SDL_Surface::flags, SDL_Surface::h, NULL, SDL_Surface::pitch, SDL_Surface::pixels, SDL_CreateRGBSurfaceWithFormat(), SDL_PREALLOC, SDL_SetClipRect(), and SDL_Surface::w.
|
static |
Definition at line 1120 of file SDL_surface.c.
References SDL_BlitInfo::a, SDL_BlitInfo::b, SDL_Surface::flags, SDL_Surface::format, SDL_BlitInfo::g, SDL_Surface::h, SDL_BlitMap::info, SDL_Surface::map, SDL_Surface::pitch, SDL_Surface::pixels, SDL_BlitInfo::r, SDL_Surface::refcount, SDL_FALSE, SDL_InitFormat(), SDL_ISPIXELFORMAT_INDEXED, SDL_PREALLOC, SDL_SetError, SDL_TRUE, SDL_zerop, and SDL_Surface::w.
Referenced by SDL_ConvertPixels().
SDL_Surface* SDL_DuplicateSurface | ( | SDL_Surface * | surface | ) |
Definition at line 936 of file SDL_surface.c.
References SDL_Surface::flags, SDL_Surface::format, and SDL_ConvertSurface().
void SDL_FreeSurface | ( | SDL_Surface * | surface | ) |
Definition at line 1219 of file SDL_surface.c.
References SDL_Surface::flags, SDL_Surface::format, SDL_Surface::locked, SDL_Surface::map, NULL, SDL_Surface::pixels, SDL_Surface::refcount, SDL_DONTFREE, SDL_free, SDL_FreeBlitMap(), SDL_FreeFormat, SDL_InvalidateMap(), SDL_PREALLOC, SDL_RLEACCEL, SDL_SetSurfacePalette(), SDL_UnlockSurface(), and SDL_UnRLESurface().
Referenced by SDL_ConvertSurface(), and SDL_CreateRGBSurfaceWithFormat().
void SDL_GetClipRect | ( | SDL_Surface * | surface, |
SDL_Rect * | rect | ||
) |
Gets the clipping rectangle for the destination surface in a blit.
rect
must be a pointer to a valid rectangle which will be filled with the correct values.
Definition at line 575 of file SDL_surface.c.
References SDL_Surface::clip_rect.
int SDL_GetColorKey | ( | SDL_Surface * | surface, |
Uint32 * | key | ||
) |
Gets the color key (transparent pixel) in a blittable surface.
surface | The surface to update |
key | A pointer filled in with the transparent pixel in the native surface format |
Definition at line 316 of file SDL_surface.c.
References SDL_BlitInfo::colorkey, SDL_BlitInfo::flags, SDL_BlitMap::info, SDL_Surface::map, SDL_COPY_COLORKEY, SDL_InvalidParamError, and SDL_SetError.
int SDL_GetSurfaceAlphaMod | ( | SDL_Surface * | surface, |
Uint8 * | alpha | ||
) |
Get the additional alpha value used in blit operations.
surface | The surface to query. |
alpha | A pointer filled in with the current alpha value. |
Definition at line 472 of file SDL_surface.c.
References SDL_BlitInfo::a, SDL_BlitMap::info, and SDL_Surface::map.
int SDL_GetSurfaceBlendMode | ( | SDL_Surface * | surface, |
SDL_BlendMode * | blendMode | ||
) |
Get the blend mode used for blit operations.
surface | The surface to query. |
blendMode | A pointer filled in with the current blend mode. |
Definition at line 522 of file SDL_surface.c.
References SDL_Surface::map, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, SDL_BLENDMODE_NONE, SDL_COPY_ADD, SDL_COPY_BLEND, and SDL_COPY_MOD.
int SDL_GetSurfaceColorMod | ( | SDL_Surface * | surface, |
Uint8 * | r, | ||
Uint8 * | g, | ||
Uint8 * | b | ||
) |
Get the additional color value used in blit operations.
surface | The surface to query. |
r | A pointer filled in with the current red color value. |
g | A pointer filled in with the current green color value. |
b | A pointer filled in with the current blue color value. |
Definition at line 430 of file SDL_surface.c.
References SDL_BlitInfo::b, SDL_BlitInfo::g, SDL_BlitMap::info, SDL_Surface::map, and SDL_BlitInfo::r.
SDL_bool SDL_HasColorKey | ( | SDL_Surface * | surface | ) |
Returns whether the surface has a color key.
Definition at line 302 of file SDL_surface.c.
References SDL_BlitInfo::flags, SDL_BlitMap::info, SDL_Surface::map, SDL_COPY_COLORKEY, SDL_FALSE, and SDL_TRUE.
int SDL_LockSurface | ( | SDL_Surface * | surface | ) |
Sets up a surface for directly accessing the pixels.
Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to and read from surface->pixels
, using the pixel format stored in surface->format
. Once you are done accessing the surface, you should use SDL_UnlockSurface() to release it.
Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates to 0, then you can read and write to the surface at any time, and the pixel format of the surface will not change.
No operating system or library calls should be made between lock/unlock pairs, as critical system locks may be held during this time.
SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
Definition at line 897 of file SDL_surface.c.
References SDL_Surface::flags, SDL_Surface::locked, SDL_RLEACCEL, and SDL_UnRLESurface().
Referenced by SDL_ConvertColorkeyToAlpha().
int SDL_LowerBlit | ( | SDL_Surface * | src, |
SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
SDL_Rect * | dstrect | ||
) |
This is a semi-private blit function and it performs low-level surface blitting only.
Definition at line 594 of file SDL_surface.c.
References SDL_BlitMap::blit, SDL_BlitMap::dst, SDL_BlitMap::dst_palette_version, SDL_Surface::format, SDL_Surface::map, SDL_PixelFormat::palette, SDL_MapSurface(), SDL_BlitMap::src_palette_version, and SDL_Palette::version.
Referenced by SDL_ConvertPixels(), SDL_ConvertSurface(), SDL_LowerBlitScaled(), and SDL_UpperBlit().
int SDL_LowerBlitScaled | ( | SDL_Surface * | src, |
SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
SDL_Rect * | dstrect | ||
) |
This is a semi-private blit function and it performs low-level surface scaled blitting only.
Definition at line 870 of file SDL_surface.c.
References SDL_BlitInfo::flags, SDL_Surface::format, SDL_PixelFormat::format, SDL_BlitMap::info, SDL_Surface::map, SDL_COPY_ADD, SDL_COPY_BLEND, SDL_COPY_COLORKEY, SDL_COPY_MOD, SDL_COPY_MODULATE_ALPHA, SDL_COPY_MODULATE_COLOR, SDL_COPY_NEAREST, SDL_InvalidateMap(), SDL_ISPIXELFORMAT_INDEXED, SDL_LowerBlit(), and SDL_SoftStretch.
Referenced by SDL_UpperBlitScaled().
SDL_bool SDL_SetClipRect | ( | SDL_Surface * | surface, |
const SDL_Rect * | rect | ||
) |
Sets the clipping rectangle for the destination surface in a blit.
If the clip rectangle is NULL, clipping will be disabled.
If the clip rectangle doesn't intersect the surface, the function will return SDL_FALSE and blits will be completely clipped. Otherwise the function returns SDL_TRUE and blits to the surface will be clipped to the intersection of the surface area and the clipping rectangle.
Note that blits are automatically clipped to the edges of the source and destination surfaces.
Definition at line 551 of file SDL_surface.c.
References SDL_Surface::clip_rect, SDL_Rect::h, SDL_Surface::h, SDL_FALSE, SDL_IntersectRect, SDL_TRUE, SDL_Rect::w, SDL_Surface::w, SDL_Rect::x, and SDL_Rect::y.
Referenced by SDL_ConvertSurface(), SDL_CreateRGBSurfaceFrom(), SDL_CreateRGBSurfaceWithFormat(), and SDL_CreateRGBSurfaceWithFormatFrom().
int SDL_SetColorKey | ( | SDL_Surface * | surface, |
int | flag, | ||
Uint32 | key | ||
) |
Sets the color key (transparent pixel) in a blittable surface.
surface | The surface to update |
flag | Non-zero to enable colorkey and 0 to disable colorkey |
key | The transparent pixel in the native surface format |
You can pass SDL_RLEACCEL to enable RLE accelerated blits.
Definition at line 257 of file SDL_surface.c.
References SDL_Color::a, SDL_BlitInfo::colorkey, SDL_Palette::colors, SDL_BlitInfo::flags, SDL_Surface::format, SDL_BlitMap::info, SDL_Surface::map, SDL_Palette::ncolors, SDL_PixelFormat::palette, SDL_ALPHA_OPAQUE, SDL_ALPHA_TRANSPARENT, SDL_COPY_COLORKEY, SDL_InvalidateMap(), SDL_InvalidParamError, SDL_RLEACCEL, SDL_SetSurfaceRLE(), and SDL_Palette::version.
Referenced by SDL_ConvertColorkeyToAlpha(), and SDL_ConvertSurface().
int SDL_SetSurfaceAlphaMod | ( | SDL_Surface * | surface, |
Uint8 | alpha | ||
) |
Set an additional alpha value used in blit operations.
surface | The surface to update. |
alpha | The alpha value multiplied into blit operations. |
Definition at line 449 of file SDL_surface.c.
References SDL_BlitInfo::a, SDL_BlitInfo::flags, SDL_BlitMap::info, SDL_Surface::map, SDL_COPY_MODULATE_ALPHA, and SDL_InvalidateMap().
int SDL_SetSurfaceBlendMode | ( | SDL_Surface * | surface, |
SDL_BlendMode | blendMode | ||
) |
Set the blend mode used for blit operations.
surface | The surface to update. |
blendMode | SDL_BlendMode to use for blit blending. |
Definition at line 485 of file SDL_surface.c.
References SDL_BlitInfo::flags, SDL_BlitMap::info, SDL_Surface::map, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, SDL_BLENDMODE_NONE, SDL_COPY_ADD, SDL_COPY_BLEND, SDL_COPY_MOD, SDL_InvalidateMap(), and SDL_Unsupported.
Referenced by SDL_ConvertColorkeyToAlpha(), SDL_ConvertSurface(), and SDL_CreateRGBSurfaceWithFormat().
int SDL_SetSurfaceColorMod | ( | SDL_Surface * | surface, |
Uint8 | r, | ||
Uint8 | g, | ||
Uint8 | b | ||
) |
Set an additional color value used in blit operations.
surface | The surface to update. |
r | The red color value multiplied into blit operations. |
g | The green color value multiplied into blit operations. |
b | The blue color value multiplied into blit operations. |
Definition at line 404 of file SDL_surface.c.
References SDL_BlitInfo::b, SDL_BlitInfo::flags, SDL_BlitInfo::g, SDL_BlitMap::info, SDL_Surface::map, SDL_BlitInfo::r, SDL_COPY_MODULATE_COLOR, and SDL_InvalidateMap().
int SDL_SetSurfacePalette | ( | SDL_Surface * | surface, |
SDL_Palette * | palette | ||
) |
Set the palette used by a surface.
Definition at line 222 of file SDL_surface.c.
References SDL_Surface::format, SDL_Surface::map, SDL_InvalidateMap(), SDL_SetError, and SDL_SetPixelFormatPalette.
Referenced by SDL_ConvertSurface(), SDL_CreateRGBSurfaceWithFormat(), and SDL_FreeSurface().
int SDL_SetSurfaceRLE | ( | SDL_Surface * | surface, |
int | flag | ||
) |
Sets the RLE acceleration hint for a surface.
Definition at line 236 of file SDL_surface.c.
References SDL_BlitInfo::flags, SDL_BlitMap::info, SDL_Surface::map, SDL_COPY_RLE_DESIRED, and SDL_InvalidateMap().
Referenced by SDL_ConvertSurface(), and SDL_SetColorKey().
void SDL_UnlockSurface | ( | SDL_Surface * | surface | ) |
Definition at line 918 of file SDL_surface.c.
References SDL_Surface::flags, SDL_Surface::locked, SDL_RLEACCEL, and SDL_RLESurface().
Referenced by SDL_ConvertColorkeyToAlpha(), and SDL_FreeSurface().
int SDL_UpperBlit | ( | SDL_Surface * | src, |
const SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
SDL_Rect * | dstrect | ||
) |
This is the public blit function, SDL_BlitSurface(), and it performs rectangle validation and clipping before passing it to SDL_LowerBlit()
Definition at line 617 of file SDL_surface.c.
References SDL_Surface::clip_rect, SDL_BlitInfo::flags, SDL_Rect::h, SDL_Surface::h, SDL_BlitMap::info, SDL_Surface::locked, SDL_Surface::map, NULL, SDL_COPY_NEAREST, SDL_InvalidateMap(), SDL_LowerBlit(), SDL_SetError, SDL_Rect::w, SDL_Surface::w, SDL_Rect::x, and SDL_Rect::y.
int SDL_UpperBlitScaled | ( | SDL_Surface * | src, |
const SDL_Rect * | srcrect, | ||
SDL_Surface * | dst, | ||
SDL_Rect * | dstrect | ||
) |
This is the public scaled blit function, SDL_BlitScaled(), and it performs rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
Definition at line 716 of file SDL_surface.c.
References SDL_Surface::clip_rect, SDL_Rect::h, SDL_Surface::h, SDL_Surface::locked, NULL, SDL_BlitSurface, SDL_floor, SDL_LowerBlitScaled(), SDL_SetError, SDL_Rect::w, SDL_Surface::w, SDL_Rect::x, and SDL_Rect::y.