DEADSOFTWARE

put "{$MODE ...}" directive in each source file; removed trailing spaces, and convert...
[d2df-sdl.git] / src / lib / sdl2 / sdlsurface.inc
1 //from "sdl_surface.h"
3 const
4 {**
5 * Surface flags
6 *
7 * These are the currently supported flags for the ::SDL_surface.
8 *
9 * Used internally (read-only).
10 *}
12 SDL_SWSURFACE = 0; {**< Just here for compatibility *}
13 SDL_PREALLOC = $00000001; {**< Surface uses preallocated memory *}
14 SDL_RLEACCEL = $00000002; {**< Surface is RLE encoded *}
15 SDL_DONTFREE = $00000004; {**< Surface is referenced internally *}
17 type
18 {**
19 * A collection of pixels used in software blitting.
20 *
21 * This structure should be treated as read-only, except for \c pixels,
22 * which, if not NULL, contains the raw pixel data for the surface.
23 *}
25 PSDL_BlitMap = ^TSDL_BlitMap;
26 TSDL_BlitMap = record
27 map: Pointer;
28 end;
30 PSDL_Surface = ^TSDL_Surface;
31 TSDL_Surface = record
32 flags: UInt32; {**< Read-only *}
33 format: PSDL_PixelFormat; {**< Read-only *}
34 w, h: SInt32; {**< Read-only *}
35 pitch: SInt32; {**< Read-only *}
36 pixels: Pointer; {**< Read-write *}
38 {** Application data associated with the surface *}
39 userdata: Pointer; {**< Read-write *}
41 {** information needed for surfaces requiring locks *}
42 locked: SInt32; {**< Read-only *}
43 lock_data: Pointer; {**< Read-only *}
45 {** clipping information *}
46 clip_rect: PSDL_Rect; {**< Read-only *}
48 {** info for fast blit mapping to other surfaces *}
49 map: Pointer; {**< Private *} //SDL_BlitMap
51 {** Reference count -- used when freeing surface *}
52 refcount: SInt32; {**< Read-mostly *}
53 end;
55 {**
56 * The type of function used for surface blitting functions.
57 *}
59 TSDL_Blit = function(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32;
61 // Evaluates to true if the surface needs to be locked before access.
62 function SDL_MUSTLOCK(Const S:PSDL_Surface):Boolean;
64 {**
65 * Allocate and free an RGB surface.
66 *
67 * If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
68 * If the depth is greater than 8 bits, the pixel format is set using the
69 * flags '[RGB]mask'.
70 *
71 * If the function runs out of memory, it will return NULL.
72 *
73 * flags The flags are obsolete and should be set to 0.
74 *}
76 function SDL_CreateRGBSurface(flags: UInt32; width: SInt32; height: SInt32; depth: SInt32; Rmask: UInt32; Gmask: UInt32; Bmask: UInt32; Amask: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_CreateRGBSurface' {$ENDIF} {$ENDIF};
77 function SDL_CreateRGBSurfaceFrom(pixels: Pointer; width: SInt32; height: SInt32; depth: SInt32; pitch: SInt32; Rmask: UInt32; Gmask: UInt32; Bmask: UInt32; Amask: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_CreateRGBSurfaceFrom' {$ENDIF} {$ENDIF};
78 procedure SDL_FreeSurface(surface: PSDL_Surface) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreeSurface' {$ENDIF} {$ENDIF};
80 {**
81 * Set the palette used by a surface.
82 *
83 * 0, or -1 if the surface format doesn't use a palette.
84 *
85 * A single palette can be shared with many surfaces.
86 *}
88 function SDL_SetSurfacePalette(surface: PSDL_Surface; palette: PSDL_Palette): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfacePalette' {$ENDIF} {$ENDIF};
90 {**
91 * Sets up a surface for directly accessing the pixels.
92 *
93 * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write
94 * to and read from surface.pixels, using the pixel format stored in
95 * surface.format. Once you are done accessing the surface, you should
96 * use SDL_UnlockSurface() to release it.
97 *
98 * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
99 * to 0, then you can read and write to the surface at any time, and the
100 * pixel format of the surface will not change.
102 * No operating system or library calls should be made between lock/unlock
103 * pairs, as critical system locks may be held during this time.
105 * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
107 * SDL_UnlockSurface()
108 *}
110 function SDL_LockSurface(surface: PSDL_Surface): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LockSurface' {$ENDIF} {$ENDIF};
112 {** SDL_LockSurface() *}
114 procedure SDL_UnlockSurface(surface: PSDL_Surface) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UnlockSurface' {$ENDIF} {$ENDIF};
116 {**
117 * Load a surface from a seekable SDL data stream (memory or file).
119 * If freesrc is non-zero, the stream will be closed after being read.
121 * The new surface should be freed with SDL_FreeSurface().
123 * the new surface, or NULL if there was an error.
124 *}
126 function SDL_LoadBMP_RW(src: PSDL_RWops; freesrc: SInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LoadBMP_RW' {$ENDIF} {$ENDIF};
128 {**
129 * Load a surface from a file.
131 * Convenience macro.
132 *}
134 function SDL_LoadBMP(_file: PAnsiChar): PSDL_Surface;
136 {**
137 * Save a surface to a seekable SDL data stream (memory or file).
139 * If freedst is non-zero, the stream will be closed after being written.
141 * 0 if successful or -1 if there was an error.
142 *}
144 function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LoadBMP_RW' {$ENDIF} {$ENDIF};
146 {**
147 * Save a surface to a file.
149 * Convenience macro.
150 *}
151 function SDL_SaveBMP(Const surface:PSDL_Surface; Const filename:AnsiString):sInt32;
153 {**
154 * Sets the RLE acceleration hint for a surface.
156 * 0 on success, or -1 if the surface is not valid
158 * If RLE is enabled, colorkey and alpha blending blits are much faster,
159 * but the surface must be locked before directly accessing the pixels.
160 *}
162 function SDL_SetSurfaceRLE(surface: PSDL_Surface; flag: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceRLE' {$ENDIF} {$ENDIF};
164 {**
165 * Sets the color key (transparent pixel) in a blittable surface.
167 * surface The surface to update
168 * flag Non-zero to enable colorkey and 0 to disable colorkey
169 * key The transparent pixel in the native surface format
171 * 0 on success, or -1 if the surface is not valid
173 * You can pass SDL_RLEACCEL to enable RLE accelerated blits.
174 *}
176 function SDL_SetColorKey(surface: PSDL_Surface; flag: SInt32; key: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetColorKey' {$ENDIF} {$ENDIF};
178 {**
179 * Gets the color key (transparent pixel) in a blittable surface.
181 * surface The surface to update
182 * key A pointer filled in with the transparent pixel in the native
183 * surface format
185 * 0 on success, or -1 if the surface is not valid or colorkey is not
186 * enabled.
187 *}
189 function SDL_GetColorKey(surface: PSDL_Surface; key: PUInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetColorKey' {$ENDIF} {$ENDIF};
191 {**
192 * Set an additional color value used in blit operations.
194 * surface The surface to update.
195 * r The red color value multiplied into blit operations.
196 * g The green color value multiplied into blit operations.
197 * b The blue color value multiplied into blit operations.
199 * 0 on success, or -1 if the surface is not valid.
201 * SDL_GetSurfaceColorMod()
202 *}
204 function SDL_SetSurfaceColorMod(surface: PSDL_Surface; r: UInt8; g: UInt8; b: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceColorMod' {$ENDIF} {$ENDIF};
206 {**
207 * Get the additional color value used in blit operations.
209 * surface The surface to query.
210 * r A pointer filled in with the current red color value.
211 * g A pointer filled in with the current green color value.
212 * b A pointer filled in with the current blue color value.
214 * 0 on success, or -1 if the surface is not valid.
216 * SDL_SetSurfaceColorMod()
217 *}
219 function SDL_GetSurfaceColorMod(surface: PSDL_Surface; r: PUInt8; g: PUInt8; b: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSurfaceColorMod' {$ENDIF} {$ENDIF};
221 {**
222 * Set an additional alpha value used in blit operations.
224 * surface The surface to update.
225 * alpha The alpha value multiplied into blit operations.
227 * 0 on success, or -1 if the surface is not valid.
229 * SDL_GetSurfaceAlphaMod()
230 *}
232 function SDL_SetSurfaceAlphaMod(surface: PSDL_Surface; alpha: UInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceAlphaMod' {$ENDIF} {$ENDIF};
234 {**
235 * Get the additional alpha value used in blit operations.
237 * surface The surface to query.
238 * alpha A pointer filled in with the current alpha value.
240 * 0 on success, or -1 if the surface is not valid.
242 * SDL_SetSurfaceAlphaMod()
243 *}
245 function SDL_GetSurfaceAlphaMod(surface: PSDL_Surface; alpha: PUInt8): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSurfaceAlphaMod' {$ENDIF} {$ENDIF};
247 {**
248 * Set the blend mode used for blit operations.
250 * surface The surface to update.
251 * blendMode ::SDL_BlendMode to use for blit blending.
253 * 0 on success, or -1 if the parameters are not valid.
255 * SDL_GetSurfaceBlendMode()
256 *}
258 function SDL_SetSurfaceBlendMode(surface: PSDL_Surface; blendMode: TSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetSurfaceBlendMode' {$ENDIF} {$ENDIF};
260 {**
261 * Get the blend mode used for blit operations.
263 * surface The surface to query.
264 * blendMode A pointer filled in with the current blend mode.
266 * 0 on success, or -1 if the surface is not valid.
268 * SDL_SetSurfaceBlendMode()
269 *}
271 function SDL_GetSurfaceBlendMode(surface: PSDL_Surface; blendMode: PSDL_BlendMode): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetSurfaceBlendMode' {$ENDIF} {$ENDIF};
273 {**
274 * Sets the clipping rectangle for the destination surface in a blit.
276 * If the clip rectangle is NULL, clipping will be disabled.
278 * If the clip rectangle doesn't intersect the surface, the function will
279 * return SDL_FALSE and blits will be completely clipped. Otherwise the
280 * function returns SDL_TRUE and blits to the surface will be clipped to
281 * the intersection of the surface area and the clipping rectangle.
283 * Note that blits are automatically clipped to the edges of the source
284 * and destination surfaces.
285 *}
287 function SDL_SetClipRect(surface: PSDL_Surface; const rect: PSDL_Rect): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetClipRect' {$ENDIF} {$ENDIF};
289 {**
290 * Gets the clipping rectangle for the destination surface in a blit.
292 * rect must be a pointer to a valid rectangle which will be filled
293 * with the correct values.
294 *}
296 procedure SDL_GetClipRect(surface: PSDL_Surface; rect: PSDL_Rect) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetClipRect' {$ENDIF} {$ENDIF};
298 {**
299 * Creates a new surface of the specified format, and then copies and maps
300 * the given surface to it so the blit of the converted surface will be as
301 * fast as possible. If this function fails, it returns NULL.
303 * The flags parameter is passed to SDL_CreateRGBSurface() and has those
304 * semantics. You can also pass SDL_RLEACCEL in the flags parameter and
305 * SDL will try to RLE accelerate colorkey and alpha blits in the resulting
306 * surface.
307 *}
309 function SDL_ConvertSurface(src: PSDL_Surface; fmt: PSDL_PixelFormat; flags: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ConvertSurface' {$ENDIF} {$ENDIF};
310 function SDL_ConvertSurfaceFormat(src: PSDL_Surface; pixel_format: UInt32; flags: UInt32): PSDL_Surface cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ConvertSurfaceFormat' {$ENDIF} {$ENDIF};
312 {**
313 * Copy a block of pixels of one format to another format
315 * 0 on success, or -1 if there was an error
316 *}
318 function SDL_ConvertPixels(width: SInt32; height: SInt32; src_format: UInt32; const src: Pointer; src_pitch: SInt32; dst_format: UInt32; dst: Pointer; dst_pitch: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ConvertPixels' {$ENDIF} {$ENDIF};
320 {**
321 * Performs a fast fill of the given rectangle with color.
323 * If rect is NULL, the whole surface will be filled with color.
325 * The color should be a pixel of the format used by the surface, and
326 * can be generated by the SDL_MapRGB() function.
328 * 0 on success, or -1 on error.
329 *}
331 function SDL_FillRect(dst: PSDL_Surface; const rect: PSDL_Rect; color: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FillRect' {$ENDIF} {$ENDIF};
332 function SDL_FillRects(dst: PSDL_Surface; const rects: PSDL_Rect; count: SInt32; color: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FillRects' {$ENDIF} {$ENDIF};
334 {**
335 * Performs a fast blit from the source surface to the destination surface.
337 * This assumes that the source and destination rectangles are
338 * the same size. If either \c srcrect or \c dstrect are NULL, the entire
339 * surface ( src or dst) is copied. The final blit rectangles are saved
340 * in srcrect and dstrect after all clipping is performed.
342 * If the blit is successful, it returns 0, otherwise it returns -1.
344 * The blit function should not be called on a locked surface.
346 * The blit semantics for surfaces with and without alpha and colorkey
347 * are defined as follows:
349 RGBA->RGB:
350 SDL_SRCALPHA set:
351 alpha-blend (using alpha-channel).
352 SDL_SRCCOLORKEY ignored.
353 SDL_SRCALPHA not set:
354 copy RGB.
355 if SDL_SRCCOLORKEY set, only copy the pixels matching the
356 RGB values of the source colour key, ignoring alpha in the
357 comparison.
359 RGB->RGBA:
360 SDL_SRCALPHA set:
361 alpha-blend (using the source per-surface alpha value);
362 set destination alpha to opaque.
363 SDL_SRCALPHA not set:
364 copy RGB, set destination alpha to source per-surface alpha value.
365 both:
366 if SDL_SRCCOLORKEY set, only copy the pixels matching the
367 source colour key.
369 RGBA->RGBA:
370 SDL_SRCALPHA set:
371 alpha-blend (using the source alpha channel) the RGB values;
372 leave destination alpha untouched. [Note: is this correct?]
373 SDL_SRCCOLORKEY ignored.
374 SDL_SRCALPHA not set:
375 copy all of RGBA to the destination.
376 if SDL_SRCCOLORKEY set, only copy the pixels matching the
377 RGB values of the source colour key, ignoring alpha in the
378 comparison.
380 RGB->RGB:
381 SDL_SRCALPHA set:
382 alpha-blend (using the source per-surface alpha value).
383 SDL_SRCALPHA not set:
384 copy RGB.
385 both:
386 if SDL_SRCCOLORKEY set, only copy the pixels matching the
387 source colour key.r
389 * You should call SDL_BlitSurface() unless you know exactly how SDL
390 * blitting works internally and how to use the other blit functions.
391 *}
393 (* SDL_surface.h uses #define to change all SDL_BlitSurface() calls into SDL_UpperBlit() calls. *
394 * Since Pascal macro support is very limited, we workaround by outright pointing SDL_BlitSurface() to SDL_UpperBlit(). *)
395 function SDL_BlitSurface(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl;
396 external SDL_LibName name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_SDL_UpperBlit' {$ELSE} 'SDL_UpperBlit' {$IFEND};
399 {**
400 * This is the public blit function, SDL_BlitSurface(), and it performs
401 * rectangle validation and clipping before passing it to SDL_LowerBlit()
402 *}
404 function SDL_UpperBlit(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UpperBlit' {$ENDIF} {$ENDIF};
406 {**
407 * This is a semi-private blit function and it performs low-level surface
408 * blitting only.
409 *}
411 function SDL_LowerBlit(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LowerBlit' {$ENDIF} {$ENDIF};
413 {**
414 * Perform a fast, low quality, stretch blit between two surfaces of the
415 * same pixel format.
417 * This function uses a static buffer, and is not thread-safe.
418 *}
420 function SDL_SoftStretch(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; const dstrect: PSDL_Surface): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SoftStretch' {$ENDIF} {$ENDIF};
422 (* SDL_surface.h uses #define to change all SDL_BlitSurfaceScaled() calls into SDL_UpperBlitScaled() calls. *
423 * Since Pascal macro support is very limited, we workaround by outright pointing SDL_BlitSurfaceScaled() to SDL_UpperBlitScaled(). *)
424 function SDL_BlitSurfaceScaled(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl;
425 external SDL_LibName name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_SDL_UpperBlitScaled' {$ELSE} 'SDL_UpperBlitScaled' {$IFEND};
427 {**
428 * This is the public scaled blit function, SDL_BlitScaled(), and it performs
429 * rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
430 *}
432 function SDL_UpperBlitScaled(src: PSDL_Surface; const srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UpperBlitScaled' {$ENDIF} {$ENDIF};
434 {**
435 * This is a semi-private blit function and it performs low-level surface
436 * scaled blitting only.
437 *}
439 function SDL_LowerBlitScaled(src: PSDL_Surface; srcrect: PSDL_Rect; dst: PSDL_Surface; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_LowerBlitScaled' {$ENDIF} {$ENDIF};