diff --git a/changelog.md b/changelog.md index f96fe3c967f..54f338a7cb3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,9 @@ In this file will be listed the changes, especially the breaking ones that one should be careful of when upgrading from a version of rust-sdl2 to another. +[PR #746](https://github.com/Rust-SDL2/rust-sdl2/pull/746) +* Make `{ttf, image, mixer, gfx}::ffi` public. + ### v0.31.1 [PR #737](https://github.com/Rust-SDL2/rust-sdl2/pull/737) diff --git a/src/sdl2/gfx/ffi.rs b/src/sdl2/gfx/ffi.rs new file mode 100644 index 00000000000..09e8c23cf1f --- /dev/null +++ b/src/sdl2/gfx/ffi.rs @@ -0,0 +1,610 @@ + +use libc::*; +use sys::SDL_Renderer; +use sys::SDL_Surface; + +#[repr(C)] +pub struct FPSmanager { + pub framecount: uint32_t, + pub rateticks: c_float, + pub baseticks: uint32_t, + pub lastticks: uint32_t, + pub rate: uint32_t, +} + +extern "C" { + pub fn SDL_initFramerate(manager: *mut FPSmanager); + pub fn SDL_setFramerate(manager: *mut FPSmanager, rate: uint32_t) -> c_int; + pub fn SDL_getFramerate(manager: *mut FPSmanager) -> c_int; + pub fn SDL_getFramecount(manager: *mut FPSmanager) -> c_int; + pub fn SDL_framerateDelay(manager: *mut FPSmanager) -> uint32_t; +} + +extern "C" { + pub fn SDL_imageFilterMMXdetect() -> c_int; + pub fn SDL_imageFilterMMXoff(); + pub fn SDL_imageFilterMMXon(); + pub fn SDL_imageFilterAdd(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> c_int; + pub fn SDL_imageFilterMean(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> c_int; + pub fn SDL_imageFilterSub(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> c_int; + pub fn SDL_imageFilterAbsDiff(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> + c_int; + pub fn SDL_imageFilterMult(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> c_int; + pub fn SDL_imageFilterMultNor(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> + c_int; + pub fn SDL_imageFilterMultDivby2(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> + c_int; + pub fn SDL_imageFilterMultDivby4(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> + c_int; + pub fn SDL_imageFilterBitAnd(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> c_int; + pub fn SDL_imageFilterBitOr(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> c_int; + pub fn SDL_imageFilterDiv(Src1: *mut u8, Src2: *mut u8, + Dest: *mut u8, length: c_uint) -> c_int; + pub fn SDL_imageFilterBitNegation(Src1: *mut u8, Dest: *mut u8, + length: c_uint) -> c_int; + pub fn SDL_imageFilterAddByte(Src1: *mut u8, Dest: *mut u8, + length: c_uint, C: u8) -> c_int; + pub fn SDL_imageFilterAddUint(Src1: *mut u8, Dest: *mut u8, + length: c_uint, C: c_uint) -> c_int; + pub fn SDL_imageFilterAddByteToHalf(Src1: *mut u8, + Dest: *mut u8, length: c_uint, + C: u8) -> c_int; + pub fn SDL_imageFilterSubByte(Src1: *mut u8, Dest: *mut u8, + length: c_uint, C: u8) -> c_int; + pub fn SDL_imageFilterSubUint(Src1: *mut u8, Dest: *mut u8, + length: c_uint, C: c_uint) -> c_int; + pub fn SDL_imageFilterShiftRight(Src1: *mut u8, Dest: *mut u8, + length: c_uint, N: u8) -> c_int; + pub fn SDL_imageFilterShiftRightUint(Src1: *mut u8, + Dest: *mut u8, length: c_uint, + N: u8) -> c_int; + pub fn SDL_imageFilterMultByByte(Src1: *mut u8, Dest: *mut u8, + length: c_uint, C: u8) -> c_int; + pub fn SDL_imageFilterShiftRightAndMultByByte(Src1: *mut u8, + Dest: *mut u8, + length: c_uint, N: u8, + C: u8) -> c_int; + pub fn SDL_imageFilterShiftLeftByte(Src1: *mut u8, + Dest: *mut u8, length: c_uint, + N: u8) -> c_int; + pub fn SDL_imageFilterShiftLeftUint(Src1: *mut u8, + Dest: *mut u8, length: c_uint, + N: u8) -> c_int; + pub fn SDL_imageFilterShiftLeft(Src1: *mut u8, Dest: *mut u8, + length: c_uint, N: u8) -> c_int; + pub fn SDL_imageFilterBinarizeUsingThreshold(Src1: *mut u8, + Dest: *mut u8, + length: c_uint, T: u8) + -> c_int; + pub fn SDL_imageFilterClipToRange(Src1: *mut u8, Dest: *mut u8, + length: c_uint, Tmin: u8, + Tmax: u8) -> c_int; + pub fn SDL_imageFilterNormalizeLinear(Src: *mut u8, + Dest: *mut u8, length: c_uint, + Cmin: c_int, Cmax: c_int, + Nmin: c_int, Nmax: c_int) -> c_int; +} + +extern "C" { + pub fn pixelColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + color: uint32_t) + -> c_int; + pub fn pixelRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn hlineColor(renderer: *const SDL_Renderer, + x1: int16_t, + x2: int16_t, + y: int16_t, + color: uint32_t) + -> c_int; + pub fn hlineRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + x2: int16_t, + y: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn vlineColor(renderer: *const SDL_Renderer, + x: int16_t, + y1: int16_t, + y2: int16_t, + color: uint32_t) + -> c_int; + pub fn vlineRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y1: int16_t, + y2: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn rectangleColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + color: uint32_t) + -> c_int; + pub fn rectangleRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn roundedRectangleColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + rad: int16_t, + color: uint32_t) + -> c_int; + pub fn roundedRectangleRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + rad: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn boxColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + color: uint32_t) + -> c_int; + pub fn boxRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn roundedBoxColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + rad: int16_t, + color: uint32_t) + -> c_int; + pub fn roundedBoxRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + rad: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn lineColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + color: uint32_t) + -> c_int; + pub fn lineRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn aalineColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + color: uint32_t) + -> c_int; + pub fn aalineRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn thickLineColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + width: uint8_t, + color: uint32_t) + -> c_int; + pub fn thickLineRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + width: uint8_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn circleColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + color: uint32_t) + -> c_int; + pub fn circleRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn arcColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + start: int16_t, + end: int16_t, + color: uint32_t) + -> c_int; + pub fn arcRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + start: int16_t, + end: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn aacircleColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + color: uint32_t) + -> c_int; + pub fn aacircleRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn filledCircleColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + r: int16_t, + color: uint32_t) + -> c_int; + pub fn filledCircleRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn ellipseColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rx: int16_t, + ry: int16_t, + color: uint32_t) + -> c_int; + pub fn ellipseRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rx: int16_t, + ry: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn aaellipseColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rx: int16_t, + ry: int16_t, + color: uint32_t) + -> c_int; + pub fn aaellipseRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rx: int16_t, + ry: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn filledEllipseColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rx: int16_t, + ry: int16_t, + color: uint32_t) + -> c_int; + pub fn filledEllipseRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rx: int16_t, + ry: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn pieColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + start: int16_t, + end: int16_t, + color: uint32_t) + -> c_int; + pub fn pieRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + start: int16_t, + end: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn filledPieColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + start: int16_t, + end: int16_t, + color: uint32_t) + -> c_int; + pub fn filledPieRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + rad: int16_t, + start: int16_t, + end: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn trigonColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + x3: int16_t, + y3: int16_t, + color: uint32_t) + -> c_int; + pub fn trigonRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + x3: int16_t, + y3: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn aatrigonColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + x3: int16_t, + y3: int16_t, + color: uint32_t) + -> c_int; + pub fn aatrigonRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + x3: int16_t, + y3: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn filledTrigonColor(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + x3: int16_t, + y3: int16_t, + color: uint32_t) + -> c_int; + pub fn filledTrigonRGBA(renderer: *const SDL_Renderer, + x1: int16_t, + y1: int16_t, + x2: int16_t, + y2: int16_t, + x3: int16_t, + y3: int16_t, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn polygonColor(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + color: uint32_t) + -> c_int; + pub fn polygonRGBA(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn aapolygonColor(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + color: uint32_t) + -> c_int; + pub fn aapolygonRGBA(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn filledPolygonColor(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + color: uint32_t) + -> c_int; + pub fn filledPolygonRGBA(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn texturedPolygon(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + texture: *mut SDL_Surface, + texture_dx: c_int, + texture_dy: c_int) + -> c_int; + pub fn bezierColor(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + s: c_int, + color: uint32_t) + -> c_int; + pub fn bezierRGBA(renderer: *const SDL_Renderer, + vx: *const int16_t, + vy: *const int16_t, + n: c_int, + s: c_int, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn gfxPrimitivesSetFont(fontdata: *const c_void, cw: uint32_t, ch: uint32_t); + pub fn gfxPrimitivesSetFontRotation(rotation: uint32_t); + pub fn characterColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + c: c_char, + color: uint32_t) + -> c_int; + pub fn characterRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + c: c_char, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; + pub fn stringColor(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + s: *mut c_char, + color: uint32_t) + -> c_int; + pub fn stringRGBA(renderer: *const SDL_Renderer, + x: int16_t, + y: int16_t, + s: *mut c_char, + r: uint8_t, + g: uint8_t, + b: uint8_t, + a: uint8_t) + -> c_int; +} + +extern "C" { + pub fn rotozoomSurface(src: *mut SDL_Surface, angle: c_double, + zoom: c_double, smooth: c_int) -> *mut SDL_Surface; + pub fn rotozoomSurfaceXY(src: *mut SDL_Surface, angle: c_double, + zoomx: c_double, zoomy: c_double, smooth: c_int) + -> *mut SDL_Surface; + pub fn rotozoomSurfaceSize(width: c_int, height: c_int, angle: c_double, + zoom: c_double, dstwidth: *mut c_int, + dstheight: *mut c_int); + pub fn rotozoomSurfaceSizeXY(width: c_int, height: c_int, angle: c_double, + zoomx: c_double, zoomy: c_double, + dstwidth: *mut c_int, dstheight: *mut c_int); + pub fn zoomSurface(src: *mut SDL_Surface, zoomx: c_double, + zoomy: c_double, smooth: c_int) -> *mut SDL_Surface; + pub fn zoomSurfaceSize(width: c_int, height: c_int, zoomx: c_double, + zoomy: c_double, dstwidth: *mut c_int, + dstheight: *mut c_int); + pub fn shrinkSurface(src: *mut SDL_Surface, factorx: c_int, + factory: c_int) -> *mut SDL_Surface; + pub fn rotateSurface90Degrees(src: *mut SDL_Surface, + numClockwiseTurns: c_int) -> + *mut SDL_Surface; +} + diff --git a/src/sdl2/gfx/framerate.rs b/src/sdl2/gfx/framerate.rs index 9fb620fb04b..848cd29ca45 100644 --- a/src/sdl2/gfx/framerate.rs +++ b/src/sdl2/gfx/framerate.rs @@ -4,48 +4,27 @@ use libc; use libc::{c_void, uint32_t, size_t}; use std::mem; use ::get_error; - - -mod ll { - /* automatically generated by rust-bindgen */ - - use libc::*; - #[repr(C)] - pub struct FPSmanager { - pub framecount: uint32_t, - pub rateticks: c_float, - pub baseticks: uint32_t, - pub lastticks: uint32_t, - pub rate: uint32_t, - } - extern "C" { - pub fn SDL_initFramerate(manager: *mut FPSmanager); - pub fn SDL_setFramerate(manager: *mut FPSmanager, rate: uint32_t) -> c_int; - pub fn SDL_getFramerate(manager: *mut FPSmanager) -> c_int; - pub fn SDL_getFramecount(manager: *mut FPSmanager) -> c_int; - pub fn SDL_framerateDelay(manager: *mut FPSmanager) -> uint32_t; - } -} +use super::ffi; /// Structure holding the state and timing information of the framerate controller. pub struct FPSManager { - raw: *mut ll::FPSmanager, + raw: *mut ffi::FPSmanager, } impl FPSManager { /// Create the framerate manager. pub fn new() -> FPSManager { unsafe { - let size = mem::size_of::() as size_t; - let raw = libc::malloc(size) as *mut ll::FPSmanager; - ll::SDL_initFramerate(raw); + let size = mem::size_of::() as size_t; + let raw = libc::malloc(size) as *mut ffi::FPSmanager; + ffi::SDL_initFramerate(raw); FPSManager { raw: raw } } } /// Set the framerate in Hz. pub fn set_framerate(&mut self, rate: u32) -> Result<(), String> { - let ret = unsafe { ll::SDL_setFramerate(self.raw, rate as uint32_t) }; + let ret = unsafe { ffi::SDL_setFramerate(self.raw, rate as uint32_t) }; match ret { 0 => Ok(()), _ => Err(get_error()) @@ -55,18 +34,18 @@ impl FPSManager { /// Return the current target framerate in Hz. pub fn get_framerate(&self) -> i32 { // will not get an error - unsafe { ll::SDL_getFramerate(self.raw) as i32 } + unsafe { ffi::SDL_getFramerate(self.raw) as i32 } } /// Return the current framecount. pub fn get_frame_count(&self) -> i32 { // will not get an error - unsafe { ll::SDL_getFramecount(self.raw) as i32 } + unsafe { ffi::SDL_getFramecount(self.raw) as i32 } } /// Delay execution to maintain a constant framerate and calculate fps. pub fn delay(&mut self) -> u32 { - unsafe { ll::SDL_framerateDelay(self.raw) as u32 } + unsafe { ffi::SDL_framerateDelay(self.raw) as u32 } } } diff --git a/src/sdl2/gfx/imagefilter.rs b/src/sdl2/gfx/imagefilter.rs index cdad1a930a7..07855538c99 100644 --- a/src/sdl2/gfx/imagefilter.rs +++ b/src/sdl2/gfx/imagefilter.rs @@ -4,86 +4,7 @@ use std::mem; use libc::{self,size_t, c_void, c_uint, c_int}; use ::get_error; use c_vec::CVec; - -mod ll { - /* automatically generated by rust-bindgen */ - - use libc::*; - extern "C" { - pub fn SDL_imageFilterMMXdetect() -> c_int; - pub fn SDL_imageFilterMMXoff(); - pub fn SDL_imageFilterMMXon(); - pub fn SDL_imageFilterAdd(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> c_int; - pub fn SDL_imageFilterMean(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> c_int; - pub fn SDL_imageFilterSub(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> c_int; - pub fn SDL_imageFilterAbsDiff(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> - c_int; - pub fn SDL_imageFilterMult(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> c_int; - pub fn SDL_imageFilterMultNor(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> - c_int; - pub fn SDL_imageFilterMultDivby2(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> - c_int; - pub fn SDL_imageFilterMultDivby4(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> - c_int; - pub fn SDL_imageFilterBitAnd(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> c_int; - pub fn SDL_imageFilterBitOr(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> c_int; - pub fn SDL_imageFilterDiv(Src1: *mut u8, Src2: *mut u8, - Dest: *mut u8, length: c_uint) -> c_int; - pub fn SDL_imageFilterBitNegation(Src1: *mut u8, Dest: *mut u8, - length: c_uint) -> c_int; - pub fn SDL_imageFilterAddByte(Src1: *mut u8, Dest: *mut u8, - length: c_uint, C: u8) -> c_int; - pub fn SDL_imageFilterAddUint(Src1: *mut u8, Dest: *mut u8, - length: c_uint, C: c_uint) -> c_int; - pub fn SDL_imageFilterAddByteToHalf(Src1: *mut u8, - Dest: *mut u8, length: c_uint, - C: u8) -> c_int; - pub fn SDL_imageFilterSubByte(Src1: *mut u8, Dest: *mut u8, - length: c_uint, C: u8) -> c_int; - pub fn SDL_imageFilterSubUint(Src1: *mut u8, Dest: *mut u8, - length: c_uint, C: c_uint) -> c_int; - pub fn SDL_imageFilterShiftRight(Src1: *mut u8, Dest: *mut u8, - length: c_uint, N: u8) -> c_int; - pub fn SDL_imageFilterShiftRightUint(Src1: *mut u8, - Dest: *mut u8, length: c_uint, - N: u8) -> c_int; - pub fn SDL_imageFilterMultByByte(Src1: *mut u8, Dest: *mut u8, - length: c_uint, C: u8) -> c_int; - pub fn SDL_imageFilterShiftRightAndMultByByte(Src1: *mut u8, - Dest: *mut u8, - length: c_uint, N: u8, - C: u8) -> c_int; - pub fn SDL_imageFilterShiftLeftByte(Src1: *mut u8, - Dest: *mut u8, length: c_uint, - N: u8) -> c_int; - pub fn SDL_imageFilterShiftLeftUint(Src1: *mut u8, - Dest: *mut u8, length: c_uint, - N: u8) -> c_int; - pub fn SDL_imageFilterShiftLeft(Src1: *mut u8, Dest: *mut u8, - length: c_uint, N: u8) -> c_int; - pub fn SDL_imageFilterBinarizeUsingThreshold(Src1: *mut u8, - Dest: *mut u8, - length: c_uint, T: u8) - -> c_int; - pub fn SDL_imageFilterClipToRange(Src1: *mut u8, Dest: *mut u8, - length: c_uint, Tmin: u8, - Tmax: u8) -> c_int; - pub fn SDL_imageFilterNormalizeLinear(Src: *mut u8, - Dest: *mut u8, length: c_uint, - Cmin: c_int, Cmax: c_int, - Nmin: c_int, Nmax: c_int) -> c_int; - } -} +use super::ffi as ll; /// MMX detection routine (with override flag). pub fn mmx_detect() -> bool { diff --git a/src/sdl2/gfx/mod.rs b/src/sdl2/gfx/mod.rs index 728634d82ef..cf625aa4be0 100644 --- a/src/sdl2/gfx/mod.rs +++ b/src/sdl2/gfx/mod.rs @@ -24,6 +24,9 @@ #[link(name="SDL2_gfx")] extern {} +#[allow(non_camel_case_types, dead_code)] +pub mod ffi; + pub mod primitives; pub mod rotozoom; pub mod framerate; diff --git a/src/sdl2/gfx/primitives.rs b/src/sdl2/gfx/primitives.rs index 72bd8bc6df8..1d5af78a680 100644 --- a/src/sdl2/gfx/primitives.rs +++ b/src/sdl2/gfx/primitives.rs @@ -9,503 +9,7 @@ use render::Canvas; use surface::Surface; use pixels; use get_error; - -#[allow(dead_code)] -mod ll { - /* automatically generated by rust-bindgen */ - - use libc::*; - use sys::SDL_Renderer; - use sys::SDL_Surface; - extern "C" { - pub fn pixelColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - color: uint32_t) - -> c_int; - pub fn pixelRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn hlineColor(renderer: *const SDL_Renderer, - x1: int16_t, - x2: int16_t, - y: int16_t, - color: uint32_t) - -> c_int; - pub fn hlineRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - x2: int16_t, - y: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn vlineColor(renderer: *const SDL_Renderer, - x: int16_t, - y1: int16_t, - y2: int16_t, - color: uint32_t) - -> c_int; - pub fn vlineRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y1: int16_t, - y2: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn rectangleColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - color: uint32_t) - -> c_int; - pub fn rectangleRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn roundedRectangleColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - rad: int16_t, - color: uint32_t) - -> c_int; - pub fn roundedRectangleRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - rad: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn boxColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - color: uint32_t) - -> c_int; - pub fn boxRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn roundedBoxColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - rad: int16_t, - color: uint32_t) - -> c_int; - pub fn roundedBoxRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - rad: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn lineColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - color: uint32_t) - -> c_int; - pub fn lineRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn aalineColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - color: uint32_t) - -> c_int; - pub fn aalineRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn thickLineColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - width: uint8_t, - color: uint32_t) - -> c_int; - pub fn thickLineRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - width: uint8_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn circleColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - color: uint32_t) - -> c_int; - pub fn circleRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn arcColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - start: int16_t, - end: int16_t, - color: uint32_t) - -> c_int; - pub fn arcRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - start: int16_t, - end: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn aacircleColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - color: uint32_t) - -> c_int; - pub fn aacircleRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn filledCircleColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - r: int16_t, - color: uint32_t) - -> c_int; - pub fn filledCircleRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn ellipseColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rx: int16_t, - ry: int16_t, - color: uint32_t) - -> c_int; - pub fn ellipseRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rx: int16_t, - ry: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn aaellipseColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rx: int16_t, - ry: int16_t, - color: uint32_t) - -> c_int; - pub fn aaellipseRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rx: int16_t, - ry: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn filledEllipseColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rx: int16_t, - ry: int16_t, - color: uint32_t) - -> c_int; - pub fn filledEllipseRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rx: int16_t, - ry: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn pieColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - start: int16_t, - end: int16_t, - color: uint32_t) - -> c_int; - pub fn pieRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - start: int16_t, - end: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn filledPieColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - start: int16_t, - end: int16_t, - color: uint32_t) - -> c_int; - pub fn filledPieRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - rad: int16_t, - start: int16_t, - end: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn trigonColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - x3: int16_t, - y3: int16_t, - color: uint32_t) - -> c_int; - pub fn trigonRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - x3: int16_t, - y3: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn aatrigonColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - x3: int16_t, - y3: int16_t, - color: uint32_t) - -> c_int; - pub fn aatrigonRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - x3: int16_t, - y3: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn filledTrigonColor(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - x3: int16_t, - y3: int16_t, - color: uint32_t) - -> c_int; - pub fn filledTrigonRGBA(renderer: *const SDL_Renderer, - x1: int16_t, - y1: int16_t, - x2: int16_t, - y2: int16_t, - x3: int16_t, - y3: int16_t, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn polygonColor(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - color: uint32_t) - -> c_int; - pub fn polygonRGBA(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn aapolygonColor(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - color: uint32_t) - -> c_int; - pub fn aapolygonRGBA(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn filledPolygonColor(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - color: uint32_t) - -> c_int; - pub fn filledPolygonRGBA(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn texturedPolygon(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - texture: *mut SDL_Surface, - texture_dx: c_int, - texture_dy: c_int) - -> c_int; - pub fn bezierColor(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - s: c_int, - color: uint32_t) - -> c_int; - pub fn bezierRGBA(renderer: *const SDL_Renderer, - vx: *const int16_t, - vy: *const int16_t, - n: c_int, - s: c_int, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn gfxPrimitivesSetFont(fontdata: *const c_void, cw: uint32_t, ch: uint32_t); - pub fn gfxPrimitivesSetFontRotation(rotation: uint32_t); - pub fn characterColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - c: c_char, - color: uint32_t) - -> c_int; - pub fn characterRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - c: c_char, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - pub fn stringColor(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - s: *mut c_char, - color: uint32_t) - -> c_int; - pub fn stringRGBA(renderer: *const SDL_Renderer, - x: int16_t, - y: int16_t, - s: *mut c_char, - r: uint8_t, - g: uint8_t, - b: uint8_t, - a: uint8_t) - -> c_int; - } -} +use super::ffi as ll; /// generic Color type pub trait ToColor { diff --git a/src/sdl2/gfx/rotozoom.rs b/src/sdl2/gfx/rotozoom.rs index 8ffe8d05444..eeb7477c591 100644 --- a/src/sdl2/gfx/rotozoom.rs +++ b/src/sdl2/gfx/rotozoom.rs @@ -4,37 +4,7 @@ use libc::c_int; use ::surface::Surface; use ::get_error; pub use std::f64::consts::PI; - - -mod ll { - /* automatically generated by rust-bindgen */ - - use libc::*; - use sys::SDL_Surface; - extern "C" { - pub fn rotozoomSurface(src: *mut SDL_Surface, angle: c_double, - zoom: c_double, smooth: c_int) -> *mut SDL_Surface; - pub fn rotozoomSurfaceXY(src: *mut SDL_Surface, angle: c_double, - zoomx: c_double, zoomy: c_double, smooth: c_int) - -> *mut SDL_Surface; - pub fn rotozoomSurfaceSize(width: c_int, height: c_int, angle: c_double, - zoom: c_double, dstwidth: *mut c_int, - dstheight: *mut c_int); - pub fn rotozoomSurfaceSizeXY(width: c_int, height: c_int, angle: c_double, - zoomx: c_double, zoomy: c_double, - dstwidth: *mut c_int, dstheight: *mut c_int); - pub fn zoomSurface(src: *mut SDL_Surface, zoomx: c_double, - zoomy: c_double, smooth: c_int) -> *mut SDL_Surface; - pub fn zoomSurfaceSize(width: c_int, height: c_int, zoomx: c_double, - zoomy: c_double, dstwidth: *mut c_int, - dstheight: *mut c_int); - pub fn shrinkSurface(src: *mut SDL_Surface, factorx: c_int, - factory: c_int) -> *mut SDL_Surface; - pub fn rotateSurface90Degrees(src: *mut SDL_Surface, - numClockwiseTurns: c_int) -> - *mut SDL_Surface; - } -} +use super::ffi as ll; /// `RotozoomSurface` for work with rust-sdl2 Surface type pub trait RotozoomSurface { diff --git a/src/sdl2/image/mod.rs b/src/sdl2/image/mod.rs index aa778146710..54c1eefdfc9 100755 --- a/src/sdl2/image/mod.rs +++ b/src/sdl2/image/mod.rs @@ -49,7 +49,7 @@ mod others { } #[allow(non_camel_case_types, dead_code)] -mod ffi; +pub mod ffi; /// InitFlags are passed to init() to control which subsystem /// functionality to load. diff --git a/src/sdl2/mixer/mod.rs b/src/sdl2/mixer/mod.rs index e7364da7e20..721eef87c59 100644 --- a/src/sdl2/mixer/mod.rs +++ b/src/sdl2/mixer/mod.rs @@ -56,7 +56,7 @@ mod others { } #[allow(non_camel_case_types, dead_code)] -mod ffi; +pub mod ffi; // This comes from SDL_audio.h #[allow(non_camel_case_types)] diff --git a/src/sdl2/ttf/mod.rs b/src/sdl2/ttf/mod.rs index f5463f3d862..64ec2d9ebde 100644 --- a/src/sdl2/ttf/mod.rs +++ b/src/sdl2/ttf/mod.rs @@ -21,7 +21,7 @@ //! ``` #[allow(non_camel_case_types, dead_code)] -mod ffi; +pub mod ffi; mod font; mod context;