include/SDL_surface.h
author Sylvain Becker <sylvain.becker@gmail.com>
Thu, 31 Jan 2019 11:45:31 +0100
changeset 12587 b2d4dcb4ba33
parent 12503 806492103856
child 12589 85bc5436a005
permissions -rw-r--r--
Add SDL_MEMALIGNED flag for SDL_Surface using aligned memory.

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