Permalink
Browse files

we dont need to know if create_mortal_rect made a new rect

  • Loading branch information...
1 parent a6cddb9 commit 805903fefcf915a062353ef962947749d0a2c63c @FROGGS FROGGS committed Oct 16, 2011
Showing with 6 additions and 22 deletions.
  1. +4 −16 src/SDLx/Surface.xs
  2. +1 −4 src/SDLx/Validate.h
  3. +1 −2 src/SDLx/Validate.xs
View
@@ -187,17 +187,12 @@ surfacex_draw_rect ( surface, rt, color )
SDL_Rect r_rect;
if( SvOK(rt) )
- {
- int newly_created_rect = 0;
- SV* foo = create_mortal_rect( rt, &newly_created_rect );
- r_rect = *(SDL_Rect*)bag2obj(foo);
- SDL_FillRect(surface, &r_rect, m_color);
- }
+ r_rect = *(SDL_Rect*)bag2obj( create_mortal_rect( rt ) );
else
{
r_rect.x = 0; r_rect.y = 0; r_rect.w = surface->w; r_rect.h = surface->h;
- SDL_FillRect(surface, &r_rect, m_color);
}
+ SDL_FillRect(surface, &r_rect, m_color);
#ifdef HAVE_SDL_GFX_PRIMITIVES
@@ -247,13 +242,9 @@ surfacex_blit( src, dest, ... )
SDL_Rect _src_rect;
SDL_Rect _dest_rect;
int newly_created_rect = 0;
- SV* s_rect_sv, *d_rect_sv;
if( items > 2 && SvOK(ST(2)) )
- {
- s_rect_sv = create_mortal_rect(ST(2), &newly_created_rect);
- _src_rect = *(SDL_Rect *)bag2obj( s_rect_sv );
- }
+ _src_rect = *(SDL_Rect *)bag2obj( create_mortal_rect( ST(2) ) );
else
{
_src_rect.x = 0;
@@ -263,10 +254,7 @@ surfacex_blit( src, dest, ... )
}
if( items > 3 && SvOK(ST(3)) )
- {
- d_rect_sv = create_mortal_rect(ST(3), &newly_created_rect);
- _dest_rect = *(SDL_Rect *)bag2obj( d_rect_sv );
- }
+ _dest_rect = *(SDL_Rect *)bag2obj( create_mortal_rect( ST(3) ) );
else
{
_dest_rect.x = 0;
View
@@ -3,7 +3,7 @@
#include "helper.h"
/* SV input should be a mortal SV */
-SV *create_mortal_rect( SV *rect, int* new_rect_made)
+SV *create_mortal_rect( SV *rect )
{
SV *retval = NULL;
/*we hand this over to perl to handle */
@@ -12,7 +12,6 @@ SV *create_mortal_rect( SV *rect, int* new_rect_made)
{
/* create a new zero sized rectangle */
SDL_Rect* r = safemalloc( sizeof(SDL_Rect) );
- (*new_rect_made) = 1;
r->x = 0;
r->y = 0;
r->w = 0;
@@ -24,7 +23,6 @@ SV *create_mortal_rect( SV *rect, int* new_rect_made)
{
/* create a new rectangle from the array */
SDL_Rect* r = safemalloc( sizeof(SDL_Rect) );
- (*new_rect_made) = 1;
int ra[4];
int i = 0;
AV* recta = (AV*)SvRV(rect);
@@ -45,7 +43,6 @@ SV *create_mortal_rect( SV *rect, int* new_rect_made)
else if( sv_isobject(rect) && sv_derived_from(rect, "SDL::Rect") )
{
/* we already had a good mortal rect . Just pass it along */
- (*new_rect_made) = 0;
retval = rect;
// no need to inc REFCNT since we dont make the SV mortal twice
//SvREFCNT_inc(rect);
@@ -112,8 +112,7 @@ void
val_rect( r )
SV* r
PPCODE:
- int new_ = 0;
- ST(0) = create_mortal_rect( r, &new_ );
+ ST(0) = create_mortal_rect( r );
XSRETURN(1);
void *

0 comments on commit 805903f

Please sign in to comment.