From a7bbc5b2fe3c5fd4af4865a4bc91fad501e01ce2 Mon Sep 17 00:00:00 2001 From: Greg M Date: Sun, 11 May 2014 18:38:55 -0400 Subject: [PATCH 1/4] 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; From 4dd3be87fa59ca5a0e3fa9d9ce6d33c1599681d9 Mon Sep 17 00:00:00 2001 From: Greg M Date: Mon, 12 May 2014 15:02:47 -0400 Subject: [PATCH 2/4] Make upper_blit use transmute instead of match --- src/sdl2/surface.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index 1e3ef0f1..ea2ed9cc 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -250,16 +250,9 @@ impl Surface { 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 - } + let dstrect_ptr = mem::transmute( dstrect.as_ref() ); + let srcrect_ptr = mem::transmute( srcrect.as_ref() ); + ll::SDL_UpperBlit( src.raw, srcrect_ptr, self.raw, dstrect_ptr ) == 0 } } From f679a5573c8c7af1c189689b1af40e6c28e02259 Mon Sep 17 00:00:00 2001 From: Greg M Date: Wed, 14 May 2014 15:46:30 -0400 Subject: [PATCH 3/4] Change from upper_blit to blit_surface --- src/sdl2/surface.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index 39d4ca4e..6fd58221 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -248,7 +248,7 @@ impl Surface { } } - pub fn upper_blit( &self, src: &Surface, dstrect: Option, srcrect: Option ) -> bool { + pub fn blit_surface( &self, src: &Surface, dstrect: Option, srcrect: Option ) -> bool { unsafe { let dstrect_ptr = mem::transmute( dstrect.as_ref() ); let srcrect_ptr = mem::transmute( srcrect.as_ref() ); From be45cdd0f3705af83b23df8bc6af0e48cba4bc99 Mon Sep 17 00:00:00 2001 From: Greg M Date: Thu, 15 May 2014 08:25:23 -0400 Subject: [PATCH 4/4] Change blit_surface to blit --- src/sdl2/surface.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl2/surface.rs b/src/sdl2/surface.rs index 6fd58221..726280e1 100644 --- a/src/sdl2/surface.rs +++ b/src/sdl2/surface.rs @@ -248,7 +248,7 @@ impl Surface { } } - pub fn blit_surface( &self, src: &Surface, dstrect: Option, srcrect: Option ) -> bool { + pub fn blit( &self, src: &Surface, dstrect: Option, srcrect: Option ) -> bool { unsafe { let dstrect_ptr = mem::transmute( dstrect.as_ref() ); let srcrect_ptr = mem::transmute( srcrect.as_ref() );