Author: mordante
Date: Mon Apr 28 17:58:29 2008
New Revision: 26208
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26208&view=rev
Log:
Change the calling converion of blit_surface so it can use the normal locker
class.
Modified:
trunk/src/sdl_utils.cpp
trunk/src/sdl_utils.hpp
Modified: trunk/src/sdl_utils.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.cpp?rev=26208&r1=26207&r2=26208&view=diff
==============================================================================
--- trunk/src/sdl_utils.cpp (original)
+++ trunk/src/sdl_utils.cpp Mon Apr 28 17:58:29 2008
@@ -1232,36 +1232,6 @@
surf->format->Rmask,surf->format->Gmask,surf->format->Bmask,surf->format->Amask);
}
-namespace {
-
-// Surface locker class based on surface_locker in sdl_utils.hpp.
-// FIXME maybe use a template class.
-struct sdl_surface_lock
-{
- sdl_surface_lock(SDL_Surface* surf) : surface_(surf), locked_(false)
- {
- if(SDL_MUSTLOCK(surface_)) {
- const int res = SDL_LockSurface(surface_);
- if(res == 0) {
- locked_ = true;
- }
- }
- }
-
- ~sdl_surface_lock()
- {
- if(locked_) {
- SDL_UnlockSurface(surface_);
- }
- }
-
- Uint32* pixels() { return reinterpret_cast<Uint32*>(surface_->pixels); }
-private:
- SDL_Surface* surface_;
- bool locked_;
-};
-
-} // namespace
//! Replacement for SDL_BlitSurface.
//!
//! SDL_BlitSurface has problems with blitting partly transparent surfaces so
@@ -1275,8 +1245,8 @@
//! are used.
//! @param dst The surface to blit on.
//! @param dstrect The offset to blit the surface on, only x and y are
used.
-void blit_surface(SDL_Surface* src,
- const SDL_Rect* srcrect, SDL_Surface* dst, const SDL_Rect* dstrect)
+void blit_surface(const surface& src,
+ const SDL_Rect* srcrect, surface& dst, const SDL_Rect* dstrect)
{
assert(src);
assert(dst);
@@ -1311,8 +1281,8 @@
{
// Extra scoping used for the surface_lock.
- sdl_surface_lock src_lock(src);
- sdl_surface_lock dst_lock(dst);
+ surface_lock src_lock(src);
+ surface_lock dst_lock(dst);
Uint32* const src_pixels =
reinterpret_cast<Uint32*>(src_lock.pixels());
Uint32* dst_pixels =
reinterpret_cast<Uint32*>(dst_lock.pixels());
Modified: trunk/src/sdl_utils.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.hpp?rev=26208&r1=26207&r2=26208&view=diff
==============================================================================
--- trunk/src/sdl_utils.hpp (original)
+++ trunk/src/sdl_utils.hpp Mon Apr 28 17:58:29 2008
@@ -147,8 +147,8 @@
surface flop_surface(surface const &surf);
surface create_compatible_surface(surface const &surf, int width = -1, int
height = -1);
//! Replacement for SDL_BlitSurface.
-void blit_surface(SDL_Surface* src,
- const SDL_Rect* srcrect, SDL_Surface* dst, const SDL_Rect* dstrect);
+void blit_surface(const surface& src,
+ const SDL_Rect* srcrect, surface& dst, const SDL_Rect* dstrect);
void fill_rect_alpha(SDL_Rect &rect, Uint32 colour, Uint8 alpha, surface const
&target);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits