From a7bbc5b2fe3c5fd4af4865a4bc91fad501e01ce2 Mon Sep 17 00:00:00 2001 From: Greg M Date: Sun, 11 May 2014 18:38:55 -0400 Subject: [PATCH] Implement SDL_UpperBlit as upper_blit --- src/sdl2/surface.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index 483f0992..1e3ef0f1 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -247,6 +247,22 @@ impl Surface { Err(get_error()) } } + + pub fn upper_blit( &self, src: &Surface, dstrect: Option, srcrect: Option ) -> bool { + unsafe { + match( srcrect, dstrect ) { + (Some( srcrect ), Some( dstrect )) => + ll::SDL_UpperBlit( src.raw, &srcrect, self.raw, &dstrect ) == 0, + (Some( srcrect ), None) => + ll::SDL_UpperBlit( src.raw, &srcrect, self.raw, ptr::null() ) == 0, + (None, Some( dstrect )) => + ll::SDL_UpperBlit( src.raw, ptr::null(), self.raw, &dstrect ) == 0, + (None, None) => + ll::SDL_UpperBlit( src.raw, ptr::null(), self.raw, ptr::null() ) == 0 + } + } + } + /* pub fn SDL_SetSurfaceAlphaMod(surface: *SDL_Surface, alpha: uint8_t) -> c_int; pub fn SDL_GetSurfaceAlphaMod(surface: *SDL_Surface, alpha: *uint8_t ) -> c_int; @@ -259,7 +275,6 @@ impl Surface { pub fn SDL_ConvertPixels(width: c_int, height: c_int, src_format: uint32_t, src: *c_void, src_pitch: c_int, dst_format: uint32_t, dst: *c_void, dst_pitch: c_int) -> c_int; pub fn SDL_FillRect(dst: *SDL_Surface, rect: *SDL_Rect, color: uint32_t) -> c_int; pub fn SDL_FillRects(dst: *SDL_Surface, rects: *SDL_Rect, count: c_int, color: uint32_t) -> c_int; - pub fn SDL_UpperBlit(src: *SDL_Surface, srcrect: *SDL_Rect, dst: *SDL_Surface, dstrect: *SDL_Rect) -> c_int; pub fn SDL_LowerBlit(src: *SDL_Surface, srcrect: *SDL_Rect, dst: *SDL_Surface, dstrect: *SDL_Rect) -> c_int; pub fn SDL_SoftStretch(src: *SDL_Surface, srcrect: *SDL_Rect, dst: *SDL_Surface, dstrect: *SDL_Rect) -> c_int; pub fn SDL_UpperBlitScaled(src: *SDL_Surface, srcrect: *SDL_Rect, dst: *SDL_Surface, dstrect: *SDL_Rect) -> c_int;