forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL HWSURFACE freeing patch

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Archaemic



Joined: 18 Mar 2007
Posts: 38

PostPosted: Sun Mar 02, 2008 9:39 am    Post subject: SDL HWSURFACE freeing patch Reply with quote

While trying to do some fancy stuff using the GU in conjunction with SDL, I noticed that it was impossible to SDL_FreeSurface a hardware surface. After doing some research, I noticed that SDL will only call PSP_FreeHWSurface if surface->hwdata is non-zero. It will also call free on surface->pixels if it is non-zero after calling FreeHWSurface, which obviously won't work if the pixels pointer points to something that isn't in the heap. Therefore, I have created this small patch:
Code:
--- src/video/psp/SDL_pspvideo.c        (revision 2361)
+++ src/video/psp/SDL_pspvideo.c        (working copy)
@@ -515,11 +515,13 @@
 
        surface->pitch = pitch;
        surface->flags |= SDL_HWSURFACE;
+       surface->hwdata = (void*)1; /* Hack to make SDL realize it's a HWSURFACE when freeing */
        return 0;
 }
 static void PSP_FreeHWSurface(_THIS, SDL_Surface *surface)
 {
        vidmem_free(surface->pixels);
+       surface->pixels = NULL;
        return;
 }
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Sun Mar 02, 2008 5:57 pm    Post subject: Reply with quote

applie in rev 2366, thanks
Back to top
View user's profile Send private message
danzel



Joined: 04 Nov 2005
Posts: 182

PostPosted: Sun Mar 02, 2008 7:25 pm    Post subject: Reply with quote

Thanks Archaemic!!!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group