include/SDL_surface.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 18 May 2013 12:48:50 -0700
changeset 7190 11612d544fcd
parent 7188 20bd120bf7e4
child 7191 75360622e65f
permissions -rw-r--r--
Added mobile application events, with implementations for iOS and Android
slouken@2275
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
slouken@2275
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@2275
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@2275
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@2275
    20
*/
slouken@2275
    21
slouken@2275
    22
/**
slouken@3407
    23
 *  \file SDL_surface.h
slouken@3407
    24
 *  
slouken@3407
    25
 *  Header file for ::SDL_surface definition and management functions.
slouken@2275
    26
 */
slouken@2275
    27
slouken@2275
    28
#ifndef _SDL_surface_h
slouken@2275
    29
#define _SDL_surface_h
slouken@2275
    30
slouken@2275
    31
#include "SDL_stdinc.h"
slouken@2275
    32
#include "SDL_pixels.h"
slouken@2275
    33
#include "SDL_rect.h"
slouken@4929
    34
#include "SDL_blendmode.h"
slouken@2275
    35
#include "SDL_rwops.h"
slouken@2275
    36
slouken@2275
    37
#include "begin_code.h"
slouken@2275
    38
/* Set up for C function definitions, even when using C++ */
slouken@2275
    39
#ifdef __cplusplus
slouken@2275
    40
/* *INDENT-OFF* */
slouken@2275
    41
extern "C" {
slouken@2275
    42
/* *INDENT-ON* */
slouken@2275
    43
#endif
slouken@2275
    44
slouken@3407
    45
/**
slouken@3407
    46
 *  \name Surface flags
slouken@3407
    47
 *  
slouken@3407
    48
 *  These are the currently supported flags for the ::SDL_surface.
slouken@3407
    49
 *  
slouken@3407
    50
 *  \internal
slouken@3407
    51
 *  Used internally (read-only).
slouken@3341
    52
 */
slouken@3341
    53
/*@{*/
slouken@6257
    54
#define SDL_SWSURFACE       0           /**< Just here for compatibility */
slouken@3341
    55
#define SDL_PREALLOC        0x00000001  /**< Surface uses preallocated memory */
slouken@3341
    56
#define SDL_RLEACCEL        0x00000002  /**< Surface is RLE encoded */
slouken@5288
    57
#define SDL_DONTFREE        0x00000004  /**< Surface is referenced internally */
slouken@3407
    58
/*@}*//*Surface flags*/
slouken@2275
    59
slouken@3407
    60
/**
slouken@3407
    61
 *  Evaluates to true if the surface needs to be locked before access.
slouken@3407
    62
 */
slouken@2275
    63
#define SDL_MUSTLOCK(S)	(((S)->flags & SDL_RLEACCEL) != 0)
slouken@2275
    64
slouken@2275
    65
/**
slouken@3407
    66
 * \brief A collection of pixels used in software blitting.
slouken@2275
    67
 *
slouken@3407
    68
 * \note  This structure should be treated as read-only, except for \c pixels,
slouken@2275
    69
 *        which, if not NULL, contains the raw pixel data for the surface.
slouken@2275
    70
 */
slouken@2275
    71
typedef struct SDL_Surface
slouken@2275
    72
{
slouken@2275
    73
    Uint32 flags;               /**< Read-only */
slouken@2275
    74
    SDL_PixelFormat *format;    /**< Read-only */
slouken@2275
    75
    int w, h;                   /**< Read-only */
slouken@2275
    76
    int pitch;                  /**< Read-only */
slouken@2275
    77
    void *pixels;               /**< Read-write */
slouken@2275
    78
slouken@3708
    79
    /** Application data associated with the surface */
slouken@2275
    80
    void *userdata;             /**< Read-write */
slouken@2275
    81
slouken@3407
    82
    /** information needed for surfaces requiring locks */
slouken@2275
    83
    int locked;                 /**< Read-only */
slouken@2275
    84
    void *lock_data;            /**< Read-only */
slouken@2275
    85
slouken@3407
    86
    /** clipping information */
slouken@2275
    87
    SDL_Rect clip_rect;         /**< Read-only */
slouken@2275
    88
slouken@3407
    89
    /** info for fast blit mapping to other surfaces */
slouken@2275
    90
    struct SDL_BlitMap *map;    /**< Private */
slouken@2275
    91
slouken@3407
    92
    /** Reference count -- used when freeing surface */
slouken@2275
    93
    int refcount;               /**< Read-mostly */
slouken@2275
    94
} SDL_Surface;
slouken@2275
    95
slouken@2275
    96
/**
slouken@3407
    97
 * \brief The type of function used for surface blitting functions.
slouken@2275
    98
 */
slouken@2275
    99
typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
slouken@2275
   100
                         struct SDL_Surface * dst, SDL_Rect * dstrect);
slouken@2275
   101
slouken@3341
   102
/**
slouken@4424
   103
 *  Allocate and free an RGB surface.
slouken@3407
   104
 *  
slouken@3407
   105
 *  If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
slouken@3407
   106
 *  If the depth is greater than 8 bits, the pixel format is set using the
slouken@3407
   107
 *  flags '[RGB]mask'.
slouken@3407
   108
 *  
slouken@3407
   109
 *  If the function runs out of memory, it will return NULL.
slouken@3407
   110
 *  
slouken@3407
   111
 *  \param flags The \c flags are obsolete and should be set to 0.
philipp@7188
   112
 *  \param width The width in pixels of the surface to create.
philipp@7188
   113
 *  \param height The height in pixels of the surface to create.
philipp@7188
   114
 *  \param depth The depth in bits of the surface to create.
philipp@7188
   115
 *  \param Rmask The red mask of the surface to create.
philipp@7188
   116
 *  \param Gmask The green mask of the surface to create.
philipp@7188
   117
 *  \param Bmask The blue mask of the surface to create.
philipp@7188
   118
 *  \param Amask The alpha mask of the surface to create.
slouken@2275
   119
 */
slouken@2275
   120
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
slouken@2275
   121
    (Uint32 flags, int width, int height, int depth,
slouken@2275
   122
     Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
slouken@2275
   123
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
slouken@2275
   124
                                                              int width,
slouken@2275
   125
                                                              int height,
slouken@2275
   126
                                                              int depth,
slouken@2275
   127
                                                              int pitch,
slouken@2275
   128
                                                              Uint32 Rmask,
slouken@2275
   129
                                                              Uint32 Gmask,
slouken@2275
   130
                                                              Uint32 Bmask,
slouken@2275
   131
                                                              Uint32 Amask);
slouken@2275
   132
extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
slouken@2275
   133
slouken@2275
   134
/**
slouken@3407
   135
 *  \brief Set the palette used by a surface.
slouken@3407
   136
 *  
slouken@3407
   137
 *  \return 0, or -1 if the surface format doesn't use a palette.
slouken@3407
   138
 *  
slouken@3407
   139
 *  \note A single palette can be shared with many surfaces.
slouken@2275
   140
 */
slouken@2275
   141
extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
slouken@2275
   142
                                                  SDL_Palette * palette);
slouken@2275
   143
slouken@3341
   144
/**
slouken@3407
   145
 *  \brief Sets up a surface for directly accessing the pixels.
slouken@3407
   146
 *  
slouken@3407
   147
 *  Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
slouken@3407
   148
 *  to and read from \c surface->pixels, using the pixel format stored in 
slouken@3407
   149
 *  \c surface->format.  Once you are done accessing the surface, you should 
slouken@3407
   150
 *  use SDL_UnlockSurface() to release it.
slouken@3407
   151
 *  
slouken@3407
   152
 *  Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
slouken@3407
   153
 *  to 0, then you can read and write to the surface at any time, and the
slouken@3407
   154
 *  pixel format of the surface will not change.
slouken@3407
   155
 *  
slouken@3407
   156
 *  No operating system or library calls should be made between lock/unlock
slouken@3407
   157
 *  pairs, as critical system locks may be held during this time.
slouken@3407
   158
 *  
slouken@3407
   159
 *  SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
slouken@3407
   160
 *  
slouken@3407
   161
 *  \sa SDL_UnlockSurface()
slouken@2275
   162
 */
slouken@2275
   163
extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
slouken@3341
   164
/** \sa SDL_LockSurface() */
slouken@2275
   165
extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
slouken@2275
   166
slouken@3341
   167
/**
slouken@4971
   168
 *  Load a surface from a seekable SDL data stream (memory or file).
slouken@3407
   169
 *  
slouken@4971
   170
 *  If \c freesrc is non-zero, the stream will be closed after being read.
slouken@3407
   171
 *  
slouken@3407
   172
 *  The new surface should be freed with SDL_FreeSurface().
slouken@3407
   173
 *  
slouken@3407
   174
 *  \return the new surface, or NULL if there was an error.
slouken@2275
   175
 */
slouken@2275
   176
extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
slouken@2275
   177
                                                    int freesrc);
slouken@2275
   178
slouken@3407
   179
/**
slouken@3407
   180
 *  Load a surface from a file.
slouken@3407
   181
 *  
slouken@3407
   182
 *  Convenience macro.
slouken@3407
   183
 */
slouken@2275
   184
#define SDL_LoadBMP(file)	SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
slouken@2275
   185
slouken@3341
   186
/**
slouken@4971
   187
 *  Save a surface to a seekable SDL data stream (memory or file).
slouken@3407
   188
 *  
slouken@4971
   189
 *  If \c freedst is non-zero, the stream will be closed after being written.
slouken@3407
   190
 *  
slouken@3407
   191
 *  \return 0 if successful or -1 if there was an error.
slouken@2275
   192
 */
slouken@2275
   193
extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
slouken@2275
   194
    (SDL_Surface * surface, SDL_RWops * dst, int freedst);
slouken@2275
   195
slouken@3407
   196
/** 
slouken@3407
   197
 *  Save a surface to a file.
slouken@3407
   198
 *  
slouken@3407
   199
 *  Convenience macro.
slouken@3407
   200
 */
slouken@2275
   201
#define SDL_SaveBMP(surface, file) \
slouken@2275
   202
		SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
slouken@2275
   203
slouken@3341
   204
/**
slouken@3407
   205
 *  \brief Sets the RLE acceleration hint for a surface.
slouken@3407
   206
 *  
slouken@3407
   207
 *  \return 0 on success, or -1 if the surface is not valid
slouken@3407
   208
 *  
slouken@3407
   209
 *  \note If RLE is enabled, colorkey and alpha blending blits are much faster,
slouken@3407
   210
 *        but the surface must be locked before directly accessing the pixels.
slouken@2275
   211
 */
slouken@2275
   212
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
slouken@2275
   213
                                              int flag);
slouken@2275
   214
slouken@3341
   215
/**
slouken@3407
   216
 *  \brief Sets the color key (transparent pixel) in a blittable surface.
slouken@3407
   217
 *  
slouken@3407
   218
 *  \param surface The surface to update
slouken@6257
   219
 *  \param flag Non-zero to enable colorkey and 0 to disable colorkey
slouken@3407
   220
 *  \param key The transparent pixel in the native surface format
slouken@3407
   221
 *  
slouken@3407
   222
 *  \return 0 on success, or -1 if the surface is not valid
slouken@6257
   223
 *
slouken@6257
   224
 *  You can pass SDL_RLEACCEL to enable RLE accelerated blits.
slouken@2275
   225
 */
slouken@2275
   226
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
slouken@3560
   227
                                            int flag, Uint32 key);
slouken@2275
   228
slouken@3341
   229
/**
slouken@3550
   230
 *  \brief Gets the color key (transparent pixel) in a blittable surface.
slouken@3407
   231
 *  
slouken@3407
   232
 *  \param surface The surface to update
slouken@3407
   233
 *  \param key A pointer filled in with the transparent pixel in the native 
slouken@3407
   234
 *             surface format
slouken@3407
   235
 *  
slouken@3407
   236
 *  \return 0 on success, or -1 if the surface is not valid or colorkey is not 
slouken@3407
   237
 *          enabled.
slouken@3103
   238
 */
slouken@3103
   239
extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
slouken@3103
   240
                                            Uint32 * key);
slouken@3103
   241
slouken@2275
   242
/**
slouken@3407
   243
 *  \brief Set an additional color value used in blit operations.
slouken@3407
   244
 *  
slouken@3407
   245
 *  \param surface The surface to update.
slouken@4971
   246
 *  \param r The red color value multiplied into blit operations.
slouken@4971
   247
 *  \param g The green color value multiplied into blit operations.
slouken@4971
   248
 *  \param b The blue color value multiplied into blit operations.
slouken@3407
   249
 *  
slouken@3407
   250
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@3407
   251
 *  
slouken@3407
   252
 *  \sa SDL_GetSurfaceColorMod()
slouken@2275
   253
 */
slouken@2275
   254
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
slouken@2275
   255
                                                   Uint8 r, Uint8 g, Uint8 b);
slouken@2275
   256
slouken@2275
   257
slouken@2275
   258
/**
slouken@3407
   259
 *  \brief Get the additional color value used in blit operations.
slouken@3407
   260
 *  
slouken@3407
   261
 *  \param surface The surface to query.
slouken@4971
   262
 *  \param r A pointer filled in with the current red color value.
slouken@4971
   263
 *  \param g A pointer filled in with the current green color value.
slouken@4971
   264
 *  \param b A pointer filled in with the current blue color value.
slouken@3407
   265
 *  
slouken@3407
   266
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@3407
   267
 *  
slouken@3407
   268
 *  \sa SDL_SetSurfaceColorMod()
slouken@2275
   269
 */
slouken@2275
   270
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
slouken@2275
   271
                                                   Uint8 * r, Uint8 * g,
slouken@2275
   272
                                                   Uint8 * b);
slouken@2275
   273
slouken@2275
   274
/**
slouken@3407
   275
 *  \brief Set an additional alpha value used in blit operations.
slouken@3407
   276
 *  
slouken@3407
   277
 *  \param surface The surface to update.
slouken@4971
   278
 *  \param alpha The alpha value multiplied into blit operations.
slouken@3407
   279
 *  
slouken@3407
   280
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@3407
   281
 *  
slouken@3407
   282
 *  \sa SDL_GetSurfaceAlphaMod()
slouken@2275
   283
 */
slouken@2275
   284
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
slouken@2275
   285
                                                   Uint8 alpha);
slouken@2275
   286
slouken@2275
   287
/**
slouken@3407
   288
 *  \brief Get the additional alpha value used in blit operations.
slouken@3407
   289
 *  
slouken@3407
   290
 *  \param surface The surface to query.
slouken@4971
   291
 *  \param alpha A pointer filled in with the current alpha value.
slouken@3407
   292
 *  
slouken@3407
   293
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@3407
   294
 *  
slouken@3407
   295
 *  \sa SDL_SetSurfaceAlphaMod()
slouken@2275
   296
 */
slouken@2275
   297
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
slouken@2275
   298
                                                   Uint8 * alpha);
slouken@2275
   299
slouken@2275
   300
/**
slouken@3407
   301
 *  \brief Set the blend mode used for blit operations.
slouken@3407
   302
 *  
slouken@3407
   303
 *  \param surface The surface to update.
slouken@3407
   304
 *  \param blendMode ::SDL_BlendMode to use for blit blending.
slouken@3407
   305
 *  
slouken@3407
   306
 *  \return 0 on success, or -1 if the parameters are not valid.
slouken@3407
   307
 *  
slouken@3407
   308
 *  \sa SDL_GetSurfaceBlendMode()
slouken@2275
   309
 */
slouken@2275
   310
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
slouken@4929
   311
                                                    SDL_BlendMode blendMode);
slouken@2275
   312
slouken@2275
   313
/**
slouken@3407
   314
 *  \brief Get the blend mode used for blit operations.
slouken@3407
   315
 *  
slouken@3407
   316
 *  \param surface   The surface to query.
slouken@3407
   317
 *  \param blendMode A pointer filled in with the current blend mode.
slouken@3407
   318
 *  
slouken@3407
   319
 *  \return 0 on success, or -1 if the surface is not valid.
slouken@3407
   320
 *  
slouken@3407
   321
 *  \sa SDL_SetSurfaceBlendMode()
slouken@2275
   322
 */
slouken@2275
   323
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
slouken@4929
   324
                                                    SDL_BlendMode *blendMode);
slouken@2275
   325
slouken@2275
   326
/**
slouken@3407
   327
 *  Sets the clipping rectangle for the destination surface in a blit.
slouken@3407
   328
 *  
slouken@3407
   329
 *  If the clip rectangle is NULL, clipping will be disabled.
slouken@3407
   330
 *  
slouken@3407
   331
 *  If the clip rectangle doesn't intersect the surface, the function will
slouken@3407
   332
 *  return SDL_FALSE and blits will be completely clipped.  Otherwise the
slouken@3407
   333
 *  function returns SDL_TRUE and blits to the surface will be clipped to
slouken@3407
   334
 *  the intersection of the surface area and the clipping rectangle.
slouken@3407
   335
 *  
slouken@3407
   336
 *  Note that blits are automatically clipped to the edges of the source
slouken@3407
   337
 *  and destination surfaces.
slouken@2275
   338
 */
slouken@2275
   339
extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
slouken@2275
   340
                                                 const SDL_Rect * rect);
slouken@2275
   341
slouken@3341
   342
/**
slouken@3407
   343
 *  Gets the clipping rectangle for the destination surface in a blit.
slouken@3407
   344
 *  
slouken@3407
   345
 *  \c rect must be a pointer to a valid rectangle which will be filled
slouken@3407
   346
 *  with the correct values.
slouken@2275
   347
 */
slouken@2275
   348
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
slouken@2275
   349
                                             SDL_Rect * rect);
slouken@2275
   350
slouken@3341
   351
/**
slouken@3407
   352
 *  Creates a new surface of the specified format, and then copies and maps 
slouken@3407
   353
 *  the given surface to it so the blit of the converted surface will be as 
slouken@3407
   354
 *  fast as possible.  If this function fails, it returns NULL.
slouken@3407
   355
 *  
slouken@3407
   356
 *  The \c flags parameter is passed to SDL_CreateRGBSurface() and has those 
slouken@3407
   357
 *  semantics.  You can also pass ::SDL_RLEACCEL in the flags parameter and
slouken@3407
   358
 *  SDL will try to RLE accelerate colorkey and alpha blits in the resulting
slouken@3407
   359
 *  surface.
slouken@2275
   360
 */
slouken@2275
   361
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
slouken@2275
   362
    (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
slouken@5375
   363
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
slouken@5375
   364
    (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
slouken@2275
   365
slouken@3341
   366
/**
slouken@3434
   367
 * \brief Copy a block of pixels of one format to another format
slouken@6041
   368
 *  
slouken@6041
   369
 *  \return 0 on success, or -1 if there was an error
slouken@3434
   370
 */
slouken@3434
   371
extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
slouken@3434
   372
                                              Uint32 src_format,
slouken@3434
   373
                                              const void * src, int src_pitch,
slouken@3434
   374
                                              Uint32 dst_format,
slouken@3434
   375
                                              void * dst, int dst_pitch);
slouken@3434
   376
slouken@3434
   377
/**
slouken@3407
   378
 *  Performs a fast fill of the given rectangle with \c color.
slouken@3407
   379
 *  
slouken@3536
   380
 *  If \c rect is NULL, the whole surface will be filled with \c color.
slouken@3407
   381
 *  
slouken@3407
   382
 *  The color should be a pixel of the format used by the surface, and 
slouken@3407
   383
 *  can be generated by the SDL_MapRGB() function.
slouken@3407
   384
 *  
slouken@3407
   385
 *  \return 0 on success, or -1 on error.
slouken@2275
   386
 */
slouken@2275
   387
extern DECLSPEC int SDLCALL SDL_FillRect
slouken@3536
   388
    (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
slouken@3536
   389
extern DECLSPEC int SDLCALL SDL_FillRects
slouken@5297
   390
    (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
slouken@2275
   391
slouken@3341
   392
/**
slouken@3407
   393
 *  Performs a fast blit from the source surface to the destination surface.
slouken@3407
   394
 *  
slouken@3407
   395
 *  This assumes that the source and destination rectangles are
slouken@3407
   396
 *  the same size.  If either \c srcrect or \c dstrect are NULL, the entire
slouken@3407
   397
 *  surface (\c src or \c dst) is copied.  The final blit rectangles are saved
slouken@3407
   398
 *  in \c srcrect and \c dstrect after all clipping is performed.
slouken@3407
   399
 *  
slouken@3407
   400
 *  \return If the blit is successful, it returns 0, otherwise it returns -1.
slouken@2275
   401
 *
slouken@3407
   402
 *  The blit function should not be called on a locked surface.
slouken@2275
   403
 *
slouken@3407
   404
 *  The blit semantics for surfaces with and without alpha and colorkey
slouken@3407
   405
 *  are defined as follows:
slouken@3407
   406
 *  \verbatim
slouken@3407
   407
    RGBA->RGB:
slouken@3407
   408
      SDL_SRCALPHA set:
slouken@3407
   409
        alpha-blend (using alpha-channel).
slouken@3407
   410
        SDL_SRCCOLORKEY ignored.
slouken@3407
   411
      SDL_SRCALPHA not set:
slouken@3407
   412
        copy RGB.
slouken@3407
   413
        if SDL_SRCCOLORKEY set, only copy the pixels matching the
philipp@7125
   414
        RGB values of the source color key, ignoring alpha in the
slouken@3407
   415
        comparison.
slouken@3407
   416
   
slouken@3407
   417
    RGB->RGBA:
slouken@3407
   418
      SDL_SRCALPHA set:
slouken@3407
   419
        alpha-blend (using the source per-surface alpha value);
slouken@3407
   420
        set destination alpha to opaque.
slouken@3407
   421
      SDL_SRCALPHA not set:
slouken@3407
   422
        copy RGB, set destination alpha to source per-surface alpha value.
slouken@3407
   423
      both:
slouken@3407
   424
        if SDL_SRCCOLORKEY set, only copy the pixels matching the
philipp@7125
   425
        source color key.
slouken@3407
   426
   
slouken@3407
   427
    RGBA->RGBA:
slouken@3407
   428
      SDL_SRCALPHA set:
slouken@3407
   429
        alpha-blend (using the source alpha channel) the RGB values;
slouken@3407
   430
        leave destination alpha untouched. [Note: is this correct?]
slouken@3407
   431
        SDL_SRCCOLORKEY ignored.
slouken@3407
   432
      SDL_SRCALPHA not set:
slouken@3407
   433
        copy all of RGBA to the destination.
slouken@3407
   434
        if SDL_SRCCOLORKEY set, only copy the pixels matching the
philipp@7125
   435
        RGB values of the source color key, ignoring alpha in the
slouken@3407
   436
       comparison.
slouken@3407
   437
   
slouken@3407
   438
    RGB->RGB: 
slouken@3407
   439
      SDL_SRCALPHA set:
slouken@3407
   440
        alpha-blend (using the source per-surface alpha value).
slouken@3407
   441
      SDL_SRCALPHA not set:
slouken@3407
   442
        copy RGB.
slouken@3407
   443
      both:
slouken@3407
   444
        if SDL_SRCCOLORKEY set, only copy the pixels matching the
philipp@7125
   445
        source color key.
slouken@3407
   446
    \endverbatim
slouken@3407
   447
 *  
slouken@3407
   448
 *  You should call SDL_BlitSurface() unless you know exactly how SDL
slouken@3407
   449
 *  blitting works internally and how to use the other blit functions.
slouken@2275
   450
 */
slouken@2275
   451
#define SDL_BlitSurface SDL_UpperBlit
slouken@2275
   452
slouken@3407
   453
/**
slouken@3407
   454
 *  This is the public blit function, SDL_BlitSurface(), and it performs
slouken@3341
   455
 *  rectangle validation and clipping before passing it to SDL_LowerBlit()
slouken@3341
   456
 */
slouken@2275
   457
extern DECLSPEC int SDLCALL SDL_UpperBlit
slouken@4949
   458
    (SDL_Surface * src, const SDL_Rect * srcrect,
slouken@2275
   459
     SDL_Surface * dst, SDL_Rect * dstrect);
slouken@3341
   460
slouken@3407
   461
/**
slouken@3407
   462
 *  This is a semi-private blit function and it performs low-level surface
slouken@3341
   463
 *  blitting only.
slouken@3341
   464
 */
slouken@2275
   465
extern DECLSPEC int SDLCALL SDL_LowerBlit
slouken@2275
   466
    (SDL_Surface * src, SDL_Rect * srcrect,
slouken@2275
   467
     SDL_Surface * dst, SDL_Rect * dstrect);
slouken@2275
   468
slouken@2275
   469
/**
slouken@3407
   470
 *  \brief Perform a fast, low quality, stretch blit between two surfaces of the
slouken@3407
   471
 *         same pixel format.
slouken@3407
   472
 *  
slouken@3407
   473
 *  \note This function uses a static buffer, and is not thread-safe.
slouken@2275
   474
 */
slouken@2275
   475
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
slouken@2828
   476
                                            const SDL_Rect * srcrect,
slouken@2275
   477
                                            SDL_Surface * dst,
slouken@2828
   478
                                            const SDL_Rect * dstrect);
slouken@2275
   479
ken@5499
   480
#define SDL_BlitScaled SDL_UpperBlitScaled
ken@5499
   481
ken@5296
   482
/**
ken@5499
   483
 *  This is the public scaled blit function, SDL_BlitScaled(), and it performs
ken@5499
   484
 *  rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
ken@5296
   485
 */
ken@5499
   486
extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
ken@5296
   487
    (SDL_Surface * src, const SDL_Rect * srcrect,
ken@5499
   488
    SDL_Surface * dst, SDL_Rect * dstrect);
ken@5499
   489
ken@5499
   490
/**
ken@5499
   491
 *  This is a semi-private blit function and it performs low-level surface
ken@5499
   492
 *  scaled blitting only.
ken@5499
   493
 */
ken@5499
   494
extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
ken@5499
   495
    (SDL_Surface * src, SDL_Rect * srcrect,
ken@5499
   496
    SDL_Surface * dst, SDL_Rect * dstrect);
ken@5296
   497
ken@5296
   498
slouken@2275
   499
/* Ends C function definitions when using C++ */
slouken@2275
   500
#ifdef __cplusplus
slouken@2275
   501
/* *INDENT-OFF* */
slouken@2275
   502
}
slouken@2275
   503
/* *INDENT-ON* */
slouken@2275
   504
#endif
slouken@2275
   505
#include "close_code.h"
slouken@2275
   506
slouken@2275
   507
#endif /* _SDL_surface_h */
slouken@2275
   508
slouken@2275
   509
/* vi: set ts=4 sw=4 expandtab: */