1 {$MODE DELPHI}
4 (*
6 SDL2_framerate.h: framerate manager
7 SDL2_gfxPrimitives.h: graphics primitives for SDL
8 SDL2_imageFilter.h: byte-image "filter" routines
9 SDL2_rotozoom.h: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces
11 Copyright (C) 2001-2012 Andreas Schiffler
13 This software is provided 'as-is', without any express or implied
14 warranty. In no event will the authors be held liable for any damages
15 arising from the use of this software.
17 Permission is granted to anyone to use this software for any purpose,
18 including commercial applications, and to alter it and redistribute it
19 freely, subject to the following restrictions:
21 1. The origin of this software must not be misrepresented; you must not
22 claim that you wrote the original software. If you use this software
23 in a product, an acknowledgment in the product documentation would be
24 appreciated but is not required.
26 2. Altered source versions must be plainly marked as such, and must not be
27 misrepresented as being the original software.
29 3. This notice may not be removed or altered from any source
30 distribution.
32 Andreas Schiffler -- aschiffler at ferzkopp dot net
34 *)
36 {$INCLUDE jedi.inc}
38 interface
41 const
42 {$IFDEF WINDOWS}
44 {$ENDIF}
46 {$IFDEF UNIX}
47 {$IFDEF DARWIN}
49 {$ELSE}
50 {$IFDEF FPC}
52 {$ELSE}
54 {$ENDIF}
55 {$ENDIF}
56 {$ENDIF}
58 {$IFDEF MACOS}
60 {$IFDEF FPC}
61 {$linklib libSDL2_gfx}
62 {$ENDIF}
63 {$ENDIF}
65 {$IF DEFINED(DELPHI) AND DEFINED(MACOS)}
66 {$DEFINE DELMAC}
67 {$ENDIF}
71 {---< SDL2_framerate.h >---}
73 Const
74 {*!
75 \brief Highest possible rate supported by framerate controller in Hz (1/s).
76 *}
79 {*!
80 \brief Lowest possible rate supported by framerate controller in Hz (1/s).
81 *}
84 {*!
85 \brief Default rate of framerate controller in Hz (1/s).
86 *}
89 Type
90 {*!
91 \brief Structure holding the state and timing information of the framerate controller.
92 *}
120 {---< SDL2_gfxPrimitives.h >---}
122 Const
127 (* Note: all ___Color routines expect the colour to be in format 0xRRGGBBAA *)
130 {* Pixel *}
138 { Horizontal line }
146 { Vertical line }
151 Function vlineRGBA(renderer: PSDL_Renderer; x, y1, y2: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
154 { Rectangle }
156 Function rectangleColor(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; colour: uInt32):sInt32; cdecl;
159 Function rectangleRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
162 { Rounded-Corner Rectangle }
164 Function roundedRectangleColor(renderer: PSDL_Renderer; x1, y1, x2, y2, rad: sInt16; colour: uInt32):sInt32; cdecl;
167 Function roundedRectangleRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2, rad: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
170 { Filled rectangle (Box) }
172 Function boxColor(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; colour: uInt32):sInt32; cdecl;
175 Function boxRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
178 { Rounded-Corner Filled rectangle (Box) }
180 Function roundedBoxColor(renderer: PSDL_Renderer; x1, y1, x2, y2, rad: sInt16; colour: uInt32):sInt32; cdecl;
183 Function roundedBoxRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2, rad: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
186 { Line }
188 Function lineColor(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; colour: uInt32):sInt32; cdecl;
191 Function lineRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
194 { AA Line }
196 Function aalineColor(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; colour: uInt32):sInt32; cdecl;
199 Function aalineRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
202 { Thick Line }
203 Function thickLineColor(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; width: uInt8; colour: uInt32):sInt32; cdecl;
206 Function thickLineRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2: sInt16; width, r, g, b, a: uInt8):sInt32; cdecl;
209 { Circle }
214 Function circleRGBA(renderer: PSDL_Renderer; x, y, rad: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
217 { Arc }
219 Function arcColor(renderer: PSDL_Renderer; x, y, rad, start, finish: sInt16; colour: uInt32):sInt32; cdecl;
222 Function arcRGBA(renderer: PSDL_Renderer; x, y, rad, start, finish: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
225 { AA Circle }
227 Function aacircleColor(renderer: PSDL_Renderer; x, y, rad: sInt16; colour: uInt32):sInt32; cdecl;
230 Function aacircleRGBA(renderer: PSDL_Renderer; x, y, rad: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
233 { Filled Circle }
235 Function filledCircleColor(renderer: PSDL_Renderer; x, y, rad: sInt16; colour: uInt32):sInt32; cdecl;
238 Function filledCircleRGBA(renderer: PSDL_Renderer; x, y, rad: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
241 { Ellipse }
243 Function ellipseColor(renderer: PSDL_Renderer; x, y, rx, ry: sInt16; colour: uInt32):sInt32; cdecl;
246 Function ellipseRGBA(renderer: PSDL_Renderer; x, y, rx, ry: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
249 { AA Ellipse }
251 Function aaellipseColor(renderer: PSDL_Renderer; x, y, rx, ry: sInt16; colour: uInt32):sInt32; cdecl;
254 Function aaellipseRGBA(renderer: PSDL_Renderer; x, y, rx, ry: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
257 { Filled Ellipse }
259 Function filledEllipseColor(renderer: PSDL_Renderer; x, y, rx, ry: sInt16; colour: uInt32):sInt32; cdecl;
262 Function filledEllipseRGBA(renderer: PSDL_Renderer; x, y, rx, ry: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
265 { Pie }
267 Function pieColor(renderer: PSDL_Renderer; x, y, rad, start, finish: sInt16; colour: uInt32):sInt32; cdecl;
270 Function pieRGBA(renderer: PSDL_Renderer; x, y, rad, start, finish: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
273 { Filled Pie }
275 Function filledPieColor(renderer: PSDL_Renderer; x, y, rad, start, finish: sInt16; colour: uInt32):sInt32; cdecl;
278 Function filledPieRGBA(renderer: PSDL_Renderer; x, y, rad, start, finish: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
281 { Trigon }
283 Function trigonColor(renderer: PSDL_Renderer; x1, y1, x2, y2, x3, y3: sInt16; colour: uInt32):sInt32; cdecl;
286 Function trigonRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2, x3, y3: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
289 { AA-Trigon }
291 Function aatrigonColor(renderer: PSDL_Renderer; x1, y1, x2, y2, x3, y3: sInt16; colour: uInt32):sInt32; cdecl;
294 Function aatrigonRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2, x3, y3: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
297 { Filled Trigon }
299 Function filledTrigonColor(renderer: PSDL_Renderer; x1, y1, x2, y2, x3, y3: sInt16; colour: uInt32):sInt32; cdecl;
302 Function filledTrigonRGBA(renderer: PSDL_Renderer; x1, y1, x2, y2, x3, y3: sInt16; r, g, b, a: uInt8):sInt32; cdecl;
305 { Polygon }
307 Function polygonColor(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n: sInt32; colour: uInt32):sInt32; cdecl;
310 Function polygonRGBA(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n: sInt32; r, g, b, a: uInt8):sInt32; cdecl;
313 { AA-Polygon }
315 Function aapolygonColor(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n: sInt32; colour: uInt32):sInt32; cdecl;
318 Function aapolygonRGBA(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n: sInt32; r, g, b, a: uInt8):sInt32; cdecl;
321 { Filled Polygon }
323 Function filledPolygonColor(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n: sInt32; colour: uInt32):sInt32; cdecl;
326 Function filledPolygonRGBA(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n: sInt32; r, g, b, a: uInt8):sInt32; cdecl;
329 { Textured Polygon }
331 Function texturedPolygon(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n: sInt32; texture: PSDL_Surface; texture_dx, texture_dy: sInt32):sInt32; cdecl;
334 { Bezier }
336 Function bezierColor(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n, s: sInt32; colour: uInt32):sInt32; cdecl;
339 Function bezierRGBA(renderer: PSDL_Renderer; Const vx, vy: PsInt16; n, s: sInt32; r, g, b, a: uInt8):sInt32; cdecl;
342 { Characters/Strings }
351 Function characterColor(renderer: PSDL_Renderer; x, y: sInt16; c: Char; colour: uInt32):sInt32; cdecl;
354 Function characterRGBA(renderer: PSDL_Renderer; x, y: sInt16; c: Char; r, g, b, a: uInt8):sInt32; cdecl;
358 Function stringColor(renderer: PSDL_Renderer; x, y: sInt16; Const str: PChar; colour: uInt32):sInt32; cdecl;
361 Function stringRGBA(renderer: PSDL_Renderer; x, y: sInt16; Const syt: PChar; r, g, b, a: uInt8):sInt32; cdecl;
366 {---< SDL2_imageFilter.h >---}
368 (* Comments: *
369 * 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. *
370 * 2.) Data that is not within an 8 byte boundary is processed using the C routine. *
371 * 3.) Convolution routines do not have C routines at this time. *)
373 // Detect MMX capability in CPU
377 // Force use of MMX off (or turn possible use back on)
385 // SDL_imageFilterAdd: D = saturation255(S1 + S2)
389 // SDL_imageFilterMean: D = S1/2 + S2/2
393 // SDL_imageFilterSub: D = saturation0(S1 - S2)
397 // SDL_imageFilterAbsDiff: D = | S1 - S2 |
402 // SDL_imageFilterMult: D = saturation(S1 * S2)
406 // SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
410 // SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
414 // SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
419 // SDL_imageFilterBitAnd: D = S1 & S2
423 // SDL_imageFilterBitOr: D = S1 | S2
428 // SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
432 // SDL_imageFilterBitNegation: D = !S
437 // SDL_imageFilterAddByte: D = saturation255(S + C)
441 // SDL_imageFilterAddUsInt32: D = saturation255(S + (usInt32)C)
442 Function SDL_imageFilterAddUsInt32(Src1, Dest : PuInt8; Length:uInt32; C : uInt32):Sint32; cdecl;
445 // SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
446 Function SDL_imageFilterAddByteToHalf(Src1, Dest : PuInt8; Length:uInt32; C : uInt8):Sint32; cdecl;
450 // SDL_imageFilterSubByte: D = saturation0(S - C)
454 // SDL_imageFilterSubUsInt32: D = saturation0(S - (usInt32)C)
455 Function SDL_imageFilterSubUsInt32(Src1, Dest : PuInt8; Length:uInt32; C : uInt32):Sint32; cdecl;
459 // SDL_imageFilterShiftRight: D = saturation0(S >> N)
460 Function SDL_imageFilterShiftRight(Src1, Dest : PuInt8; Length:uInt32; N : uInt8):Sint32; cdecl;
463 // SDL_imageFilterShiftRightUsInt32: D = saturation0((usInt32)S >> N)
464 Function SDL_imageFilterShiftRightUsInt32(Src1, Dest : PuInt8; Length:uInt32; N : uInt8):Sint32; cdecl;
468 // SDL_imageFilterMultByByte: D = saturation255(S * C)
469 Function SDL_imageFilterMultByByte(Src1, Dest : PuInt8; Length:uInt32; C : uInt8):Sint32; cdecl;
472 // SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
473 Function SDL_imageFilterShiftRightAndMultByByte(Src1, Dest : PuInt8; Length:uInt32; N, C : uInt8):Sint32; cdecl;
477 // SDL_imageFilterShiftLeftByte: D = (S << N)
478 Function SDL_imageFilterShiftLeftByte(Src1, Dest : PuInt8; Length:uInt32; N: uInt8):Sint32; cdecl;
481 // SDL_imageFilterShiftLeftUsInt32: D = ((usInt32)S << N)
482 Function SDL_imageFilterShiftLeftUsInt32(Src1, Dest : PuInt8; Length:uInt32; N:uInt8):Sint32; cdecl;
485 // SDL_imageFilterShiftLeft: D = saturation255(S << N)
490 // SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
491 Function SDL_imageFilterBinarizeUsingThreshold(Src1, Dest : PuInt8; Length:uInt32; T: uInt8):Sint32; cdecl;
494 // SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
495 Function SDL_imageFilterClipToRange(Src1, Dest : PuInt8; Length:uInt32; Tmin, Tmax: uInt8):Sint32; cdecl;
498 // SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
499 Function SDL_imageFilterNormalizeLinear(Src, Dest: PuInt8; Length, Cmin, Cmax, Nmin, Nmax: sInt32):Sint32; cdecl;
503 {---< SDL2_rotozoom.h >---}
505 Const
506 {*!
507 \brief Disable anti-aliasing (no smoothing).
508 *}
511 {*!
512 \brief Enable anti-aliasing (smoothing).
513 *}
516 { Rotozoom functions }
518 Function rotozoomSurface(src: PSDL_Surface; angle, zoom: Double; smooth: sInt32):PSDL_Surface; cdecl;
521 Function rotozoomSurfaceXY(src: PSDL_Surface; angle, zoomx, zoomy: Double; smooth: sInt32):PSDL_Surface; cdecl;
525 Procedure rotozoomSurfaceSize(width, height: sInt32; angle, zoom: Double; dstwidth, dstheight: PuInt32); cdecl;
528 Procedure rotozoomSurfaceSizeXY(width, height: sInt32; angle, zoomx, zoomy: Double; dstwidth, dstheight:PuInt32); cdecl;
532 { Zooming functions }
534 Function zoomSurface(src: PSDL_Surface; zoomx, zoomy: Double; smooth: sInt32):PSDL_Surface; cdecl;
537 Procedure zoomSurfaceSize(width, height: sInt32; zoomx, zoomy: Double; dstwidth, dstheight: PuInt32); cdecl;
540 { Shrinking functions }
545 { Specialized rotation functions }
547 Function rotateSurface90Degrees(src: PSDL_Surface; numClockwiseTurns: sInt32):PSDL_Surface; cdecl;
551 implementation
554 begin