include/SDL_surface.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 14 Aug 2017 13:37:14 -0700
changeset 11289 ca3c2c98f2e1
parent 11284 3db78361e751
child 11702 cf166abbde4a
permissions -rw-r--r--
Fixed bug 2441 - SDL_DuplicateSurface


Rainer Deyke

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