pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3400 - trunk/pingus/src


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3400 - trunk/pingus/src
Date: Tue, 30 Oct 2007 09:20:37 +0100

Author: grumbel
Date: 2007-10-30 09:20:36 +0100 (Tue, 30 Oct 2007)
New Revision: 3400

Modified:
   trunk/pingus/src/smallmap_image.cpp
   trunk/pingus/src/surface.cpp
Log:
- fixed Surface::clone()

Modified: trunk/pingus/src/smallmap_image.cpp
===================================================================
--- trunk/pingus/src/smallmap_image.cpp 2007-10-30 07:44:42 UTC (rev 3399)
+++ trunk/pingus/src/smallmap_image.cpp 2007-10-30 08:20:36 UTC (rev 3400)
@@ -150,12 +150,9 @@
 
   canvas.unlock();
 
-  // Manually clone the Surface due to the way SDL handle RGBA->RGBA blits
-  Surface s(canvas.get_width(), canvas.get_height());
-  SDL_SetAlpha(canvas.get_surface(), 0, 0);
-  s.blit(canvas, 0, 0);
-
-  sur = Sprite(s);
+  // FIXME: surface -> clone -> displayFormat leaves room for
+  // optimizations, clone isn't really needed
+  sur = Sprite(canvas.clone());
 }
 
 /* EOF */

Modified: trunk/pingus/src/surface.cpp
===================================================================
--- trunk/pingus/src/surface.cpp        2007-10-30 07:44:42 UTC (rev 3399)
+++ trunk/pingus/src/surface.cpp        2007-10-30 08:20:36 UTC (rev 3400)
@@ -289,7 +289,17 @@
 {
   SDL_Surface* new_surface = 
Blitter::create_surface_from_format(impl->surface, 
                                                                  
impl->surface->w, impl->surface->h);
-  std::cout << "Blit: " << SDL_BlitSurface(impl->surface, NULL, new_surface, 
NULL) << std::endl;
+  if (impl->surface->flags & SDL_SRCALPHA)
+    {
+      Uint8 alpha = impl->surface->format->alpha;
+      SDL_SetAlpha(impl->surface, 0, 0);
+      SDL_BlitSurface(impl->surface, NULL, new_surface, NULL);
+      SDL_SetAlpha(impl->surface, SDL_SRCALPHA, alpha);
+    }
+  else
+    {
+      SDL_BlitSurface(impl->surface, NULL, new_surface, NULL);
+    }
  
   return Surface(boost::shared_ptr<SurfaceImpl>(new SurfaceImpl(new_surface, 
true)));
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]