pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] rev 2299 - in trunk/src: . worldobjs


From: Ingo Ruhnke
Subject: [Pingus-CVS] rev 2299 - in trunk/src: . worldobjs
Date: Wed, 05 May 2004 22:30:41 +0200

Author: grumbel
Date: 2004-05-05 22:30:41 +0200 (Wed, 05 May 2004)
New Revision: 2299

Modified:
   trunk/src/alpha_button.cxx
   trunk/src/blitter.cxx
   trunk/src/blitter.hxx
   trunk/src/blitter_impl.hxx
   trunk/src/capture_rectangle.cxx
   trunk/src/spot_map.cxx
   trunk/src/spot_map.hxx
   trunk/src/string_format.cxx
   trunk/src/target_provider.hxx
   trunk/src/worldobjs/exit.cxx
   trunk/src/worldobjs/surface_background.cxx
   trunk/src/xmlgz_reader.cxx
Log:
- misc clanlib0.7 related fixes

Modified: trunk/src/alpha_button.cxx
===================================================================
--- trunk/src/alpha_button.cxx  2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/alpha_button.cxx  2004-05-05 20:30:41 UTC (rev 2299)
@@ -41,19 +41,21 @@
 void
 AlphaButton::draw(void)
 {
-#ifdef CLANLIB_0_6
+  CL_Font font = font_h;
+
+  font.set_alignment(origin_top_center);
+
   if (is_pressed()) {
-    CL_Display::fill_rect(x1_pos, y1_pos, x2_pos, y2_pos,
-                         1.0, 1.0, 1.0, 0.5);
-    font_h->print_center(x1_pos + (x2_pos - x1_pos)/2, y1_pos + (y2_pos - 
y1_pos)/2,
-                        name.c_str());
+    CL_Display::fill_rect(CL_Rect(x1_pos, y1_pos, x2_pos, y2_pos),
+                         CL_Color(255, 255, 255, 128));
+    font.draw(x1_pos + (x2_pos - x1_pos)/2, y1_pos + (y2_pos - y1_pos)/2,
+                        name);
   } else {
-    CL_Display::fill_rect(x1_pos, y1_pos, x2_pos, y2_pos,
-                         0.0, 0.0, 0.0, 0.5);
-    font->print_center(x1_pos + (x2_pos - x1_pos)/2, y1_pos + (y2_pos - 
y1_pos)/2,
-                      name.c_str());
+    CL_Display::fill_rect(CL_Rect(x1_pos, y1_pos, x2_pos, y2_pos),
+                         CL_Color(0, 0, 0, 128));
+    font.draw(x1_pos + (x2_pos - x1_pos)/2, y1_pos + (y2_pos - y1_pos)/2,
+              name);
   }
-#endif
 }
 
 bool

Modified: trunk/src/blitter.cxx
===================================================================
--- trunk/src/blitter.cxx       2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/blitter.cxx       2004-05-05 20:30:41 UTC (rev 2299)
@@ -20,7 +20,9 @@
 #include <config.h>
 #include <stdio.h>
 #include <assert.h>
+#include <ClanLib/Display/palette.h>
 #include <ClanLib/Display/pixel_buffer.h>
+#include <ClanLib/Display/pixel_format.h>
 
 #include "pingus_error.hxx"
 #include "color.hxx"
@@ -39,28 +41,17 @@
 namespace Pingus {
 
 void
-Blitter::put_surface(CL_PixelBuffer* canvas, const CL_Surface& sur,
+Blitter::put_surface(CL_PixelBuffer& canvas, const CL_Surface& sur,
                     int x, int y)
 {
-#ifdef CLANLIB_0_6
-  //Blitter::put_surface(canvas, sur->get_provider(), x, y);
-  /*  if (sur->get_provider()->get_depth() != 8)
-      sur->put_target(x, y, 0, canvas);
-      else*/
-  assert (sur);
-  assert (canvas);
-  Blitter::put_surface(canvas, sur.get_provider(), x, y);
-#endif
+  Blitter::put_surface(canvas, sur.get_pixeldata(), x, y);
 }
 
 void
-Blitter::put_surface(CL_PixelBuffer* canvas, CL_PixelBuffer* provider,
+Blitter::put_surface(CL_PixelBuffer& canvas, const CL_PixelBuffer& provider,
                     int x, int y)
 {
-#ifdef CLANLIB_0_6
-  assert (provider);
-  assert (canvas);
-  switch(provider->get_depth())
+  switch(provider.get_format().get_depth())
     {
     case  8:
       put_surface_8bit(canvas, provider, x, y);
@@ -69,14 +60,13 @@
       put_surface_32bit(canvas, provider, x, y);
       break;
     default:
-      PingusError::raise("Blitter:put_surface:Unknown color depth: " + 
to_string(provider->get_depth()));
+      PingusError::raise("Blitter:put_surface:Unknown color depth: " + 
to_string(provider.get_format().get_depth()));
       break;
     }
-#endif
 }
 
 void
-Blitter::put_surface_8bit(CL_PixelBuffer* provider, CL_PixelBuffer* sprovider,
+Blitter::put_surface_8bit(CL_PixelBuffer& provider, const CL_PixelBuffer& 
sprovider,
                          int x, int y)
 {
 #ifdef CLANLIB_0_6
@@ -104,7 +94,7 @@
   if (!cl_palette)
     {
       char str[128];
-      snprintf(str, 128, "Couldn't find palette: %d", sprovider->get_depth());
+      snprintf(str, 128, "Couldn't find palette: %d", 
sprovider->get_format().get_depth());
       PingusError::raise(str);
     }
 
@@ -175,7 +165,7 @@
     }
 
 #if COMPILE_WITH_MEMORY_HOLE
-#warning "FIXME: Blitter::put_surface_8bit(CL_PixelBuffer* provider, 
CL_PixelBuffer* sprovider, int x, int y) contains memory hole"
+#warning "FIXME: Blitter::put_surface_8bit(CL_PixelBuffer& provider, 
CL_PixelBuffer& sprovider, int x, int y) contains memory hole"
 #else
   sprovider->unlock();
   provider->unlock();
@@ -184,13 +174,10 @@
 }
 
 void
-Blitter::put_surface_32bit(CL_PixelBuffer* canvas, CL_PixelBuffer* provider,
+Blitter::put_surface_32bit(CL_PixelBuffer& canvas, const CL_PixelBuffer& 
provider,
                           const int x_pos, const int y_pos)
 {
 #ifdef CLANLIB_0_6
-  assert (canvas);
-  assert (provider);
-
   pout(PINGUS_DEBUG_BLITTER) << "Blitting: SurfaceProvider:" << 
provider->get_width ()
                              << "x" << provider->get_height () << ":" << 
provider
                             << " Canvas:" << canvas->get_width () << "x"
@@ -233,7 +220,7 @@
     }
 
 #if COMPILE_WITH_MEMORY_HOLE
-#warning "FIXME: Blitter::put_surface_32bit(CL_PixelBuffer* canvas, 
CL_PixelBuffer* provider, const int x_pos, const int y_pos) contains memory 
hole"
+#warning "FIXME: Blitter::put_surface_32bit(CL_PixelBuffer& canvas, 
CL_PixelBuffer& provider, const int x_pos, const int y_pos) contains memory 
hole"
 #else
   provider->unlock();
   canvas->unlock();
@@ -242,12 +229,10 @@
 }
 
 void
-Blitter::put_alpha_surface(CL_PixelBuffer* provider, CL_PixelBuffer* sprovider,
+Blitter::put_alpha_surface(CL_PixelBuffer& provider, const CL_PixelBuffer& 
sprovider,
                           int x, int y)
 {
 #ifdef CLANLIB_0_6
-  assert (provider);
-  assert (sprovider);
   int start_i;
   unsigned char* tbuffer; // Target buffer
   int twidth, theight, tpitch;
@@ -261,17 +246,17 @@
   provider->lock();
   sprovider->lock();
 
-  //  assert(sprovider->get_depth() == 8);
-  if (sprovider->get_depth() != 8)
+  //  assert(sprovider->get_format().get_depth() == 8);
+  if (sprovider->get_format().get_depth() != 8)
     {
       // FIXME: memory hole
 #if COMPILE_WITH_MEMORY_HOLE
-#warning "FIXME: Blitter::put_alpha_surface(CL_PixelBuffer* provider, 
CL_PixelBuffer* sprovider, int x, int y) contains memory hole"
+#warning "FIXME: Blitter::put_alpha_surface(CL_PixelBuffer& provider, 
CL_PixelBuffer& sprovider, int x, int y) contains memory hole"
 #else
       sprovider->unlock ();
       provider->unlock ();
 #endif
-      PingusError::raise("Image has wrong color depth: " + 
to_string(sprovider->get_depth()));
+      PingusError::raise("Image has wrong color depth: " + 
to_string(sprovider->get_format().get_depth()));
     }
   //  assert(provider->get_pixel_format() == RGBA8888);
 
@@ -311,7 +296,7 @@
   }
 
 #if COMPILE_WITH_MEMORY_HOLE
-#warning "FIXME: Blitter::put_alpha_surface(CL_PixelBuffer* provider, 
CL_PixelBuffer* sprovider, int x, int y) contains memory hole"
+#warning "FIXME: Blitter::put_alpha_surface(CL_PixelBuffer& provider, 
CL_PixelBuffer& sprovider, int x, int y) contains memory hole"
 #else
   sprovider->unlock();
   provider->unlock();
@@ -320,40 +305,31 @@
 #endif
 }
 
-CL_PixelBuffer*
-Blitter::clear_canvas(CL_PixelBuffer* canvas)
+CL_PixelBuffer
+Blitter::clear_canvas(CL_PixelBuffer& canvas)
 {
-#ifdef CLANLIB_0_6
-  assert (canvas);
   unsigned char* buffer;
 
-  canvas->lock();
-  buffer = static_cast<unsigned char*>(canvas->get_data());
-  memset(buffer, 0, sizeof(unsigned char) * canvas->get_pitch() * 
canvas->get_height());
-  // FIXME: memory hole
-  //canvas->unlock();
+  canvas.lock();
+  buffer = static_cast<unsigned char*>(canvas.get_data());
+  memset(buffer, 0, sizeof(unsigned char) * canvas.get_pitch() * 
canvas.get_height());
+  canvas.unlock();
 
   return canvas;
-#endif
-  return 0;
 }
 
-CL_PixelBuffer*
+CL_PixelBuffer
 Blitter::create_canvas(const CL_Surface& sur)
 {
-#ifdef CLANLIB_0_6
-  assert (sur);
-  return create_canvas(sur.get_provider());
-#endif
-  return 0;
+  return create_canvas(sur.get_pixeldata());
 }
 
-CL_PixelBuffer*
-Blitter::create_canvas(CL_PixelBuffer* prov)
+CL_PixelBuffer
+Blitter::create_canvas(const CL_PixelBuffer& prov)
 {
 #ifdef CLANLIB_0_6
   assert (prov);
-  CL_PixelBuffer* canvas = new CL_PixelBuffer(prov->get_width(), 
prov->get_height());
+  CL_PixelBuffer& canvas = new CL_PixelBuffer(prov->get_width(), 
prov->get_height());
 
   switch (prov->get_bytes_per_pixel())
     {
@@ -410,25 +386,22 @@
   return CL_Surface();
 }
 
-CL_PixelBuffer*
-Blitter::scale_surface_to_canvas (const CL_Surface& sur, int width, int height)
+CL_PixelBuffer
+Blitter::scale_surface_to_canvas(const CL_Surface& sur, int width, int height)
 {
-#ifdef CLANLIB_0_6
-  assert (sur);
-
   Color color;
-  CL_PixelBuffer* provider = sur.get_provider ();
-  CL_PixelBuffer* canvas = new CL_PixelBuffer (width, height);
+  CL_PixelBuffer provider = sur.get_pixeldata();
+  CL_PixelBuffer canvas(width, height, width*4, CL_PixelFormat::rgba8888);
 
-  provider->lock ();
-  canvas->lock ();
+  provider.lock ();
+  canvas.lock ();
 
-  unsigned char* sbuffer = static_cast<unsigned char*>(provider->get_data ());
-  unsigned char* tbuffer = static_cast<unsigned char*>(canvas->get_data ());
-  int pwidth = provider->get_width ();
-  int pheight = provider->get_height ();
+  unsigned char* sbuffer = static_cast<unsigned char*>(provider.get_data ());
+  unsigned char* tbuffer = static_cast<unsigned char*>(canvas.get_data ());
+  int pwidth = provider.get_width ();
+  int pheight = provider.get_height ();
 
-  if (provider->is_indexed ())
+  if (provider.get_format().get_type() ==  pixelformat_index)
     {
       // Slow but generic, using get_data () would be better, but would
       // require quite a bit of work
@@ -436,28 +409,31 @@
        {
          for (int x = 0; x < width; ++x)
            {
-             unsigned char pixel = *(static_cast<unsigned 
char*>(provider->get_data ())
-                                     + (y * pheight/height) * 
provider->get_pitch() + (x * pwidth/width));
+             unsigned char pixel = *(static_cast<unsigned 
char*>(provider.get_data ())
+                                     + (y * pheight/height) * 
provider.get_pitch() + (x * pwidth/width));
 
-             color.red   = provider->get_palette()->palette[pixel*3 +0] / 
255.0f;
-             color.green = provider->get_palette()->palette[pixel*3 +1] / 
255.0f;
-             color.blue  = provider->get_palette()->palette[pixel*3 +2] / 
255.0f;
+             color.red   = provider.get_palette().colors[pixel*3 +0] / 255.0f;
+             color.green = provider.get_palette().colors[pixel*3 +1] / 255.0f;
+             color.blue  = provider.get_palette().colors[pixel*3 +2] / 255.0f;
 
-             if (provider->get_src_colorkey () == pixel)
+             if (provider.get_format().has_colorkey()
+                  && provider.get_format().get_colorkey() == pixel)
                color.alpha = 0.0f;
              else
                color.alpha = 1.0f;
-
+              
              // FIXME: ignoring the source alpha due to get_pixel brokeness... 
no time to test the patch
-             canvas->draw_pixel (x, y, color.red, color.green, color.blue, 
color.alpha);
+#ifdef CLANLIB_0_6
+             canvas.draw_pixel (x, y, color.red, color.green, color.blue, 
color.alpha);
+#endif
            }
        }
     }
   else
     {
-      switch (provider->get_bytes_per_pixel ())
+      switch (provider.get_format().get_depth())
        {
-       case 3:
+       case 24:
          {
            // We assume that we have the data in RGB888, which might not be
            // the case
@@ -475,7 +451,7 @@
                }
          }
          break;
-       case 4:
+       case 32:
          {
            // We assume that we have the data in RGBA8888, which might not be
            // the case
@@ -499,27 +475,24 @@
          for (int y = 0; y < height; ++y)
            for (int x = 0; x < width; ++x)
              {
+#ifdef CLANLIB_0_6
                // std::cout << "X: " << x << " Y: " << y << std::endl;
-               provider->get_pixel (x * provider->get_width () / width,
-                                    y * provider->get_height () / height,
-                                    &color.red, &color.green, &color.blue, 
&color.alpha);
-               // FIXME: ignoring the source alpha due to get_pixel 
brokeness... no time to test the patch
-               canvas->draw_pixel (x, y, color.red, color.green, color.blue, 
color.alpha);
+               provider.get_pixel (x * provider.get_width () / width,
+                                    y * provider.get_height () / height,
+                                    &color.red, &color.green, &color.blue, 
&color.alpha);
+               // FIXME: ignoring the source alpha due to get_pixel
+               // brokeness... no time to test the patch
+               canvas.draw_pixel (x, y, color.red, color.green, color.blue, 
color.alpha);
+#endif
              }
          break;
        }
     }
 
-#if COMPILE_WITH_MEMORY_HOLE
-#warning "FIXME: Blitter::scale_surface_to_canvas (const CL_Surface& sur, int 
width, int height) contains memory leak"
-#else
-  canvas->unlock ();
-  provider->unlock ();
-#endif
+  canvas.unlock ();
+  provider.unlock ();
 
   return canvas;
-#endif
-  return 0;
 }
 
 /*
@@ -528,14 +501,14 @@
 CL_Surface
 Blitter::convert_to_emptyprovider(CL_Surface ssurf)
 {
-CL_PixelBuffer* tprov = convert_to_emptyprovider(ssurf->get_provider());
+CL_PixelBuffer& tprov = convert_to_emptyprovider(ssurf.get_provider());
 return CL_Surface::create(tprov, true);
 }
 
 // Converts a SurfaceProvider, to an Canvas and returns
 // the newly allocated provider, you need to delete it yourself.
-CL_PixelBuffer*
-Blitter::convert_to_emptyprovider(CL_PixelBuffer* sprov)
+CL_PixelBuffer&
+Blitter::convert_to_emptyprovider(CL_PixelBuffer& sprov)
 {
   CL_PixelBuffer* tprov;
   CL_Palette* palette;
@@ -544,7 +517,7 @@
   int i;
 
   sprov->lock();
-  switch(sprov->get_depth())
+  switch(sprov->get_format().get_depth())
     {
     case 32:
       tprov = new CL_PixelBuffer(sprov->get_width(),
@@ -582,7 +555,7 @@
       break;
     default:
       std::cout << "convert_to_emptyprovider(): Wrong source format: "
-               << static_cast<int>(sprov->get_depth()) << std::endl;
+               << static_cast<int>(sprov->get_format().get_depth()) << 
std::endl;
       assert(false);
       break;
     }
@@ -613,7 +586,7 @@
 #ifdef CLANLIB_0_6
   CL_PixelBuffer* prov = sur.get_provider ();
 
-  if (prov->is_indexed())
+  if (prov.get_type() ==  pixelformat_index)
     {
       //std::cout << "Using indexed blitter" << std::endl;
       int pwidth  = prov->get_width();

Modified: trunk/src/blitter.hxx
===================================================================
--- trunk/src/blitter.hxx       2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/blitter.hxx       2004-05-05 20:30:41 UTC (rev 2299)
@@ -34,10 +34,10 @@
 {
 private:
   ///
-  static void put_surface_8bit(CL_PixelBuffer*, CL_PixelBuffer*,
+  static void put_surface_8bit(CL_PixelBuffer& target, const CL_PixelBuffer& 
source,
                               int x, int y);
   ///
-  static void put_surface_32bit(CL_PixelBuffer*, CL_PixelBuffer*,
+  static void put_surface_32bit(CL_PixelBuffer& target, const CL_PixelBuffer& 
source,
                               int x, int y);
 public:
   /*void put_surface(CL_LockableSurface* provider, CL_Surface surface,
@@ -47,28 +47,28 @@
   */
 
   /// Puts a given surface to a given canvas at position x, y.
-  static void put_surface(CL_PixelBuffer*, const CL_Surface&,
+  static void put_surface(CL_PixelBuffer& target, const CL_Surface& source,
                          int x, int y);
 
   /// Puts a given surface provider to a given canvas at position x, y.
-  static void put_surface(CL_PixelBuffer*, CL_PixelBuffer*,
+  static void put_surface(CL_PixelBuffer& target, const CL_PixelBuffer& source,
                          int x, int y);
 
   /** Makes all pixels in canvas tranparent, when their indexed value
       in provider is larger than zero.*/
-  static void put_alpha_surface(CL_PixelBuffer* canvas, CL_PixelBuffer* 
provider,
+  static void put_alpha_surface(CL_PixelBuffer& target, const CL_PixelBuffer& 
source,
                                int x, int y);
 
   /** Returns a newly allocated canvas. The canvas contains the same
       image as the given surface. */
-  static CL_PixelBuffer* create_canvas(const CL_Surface&);
+  static CL_PixelBuffer create_canvas(const CL_Surface&);
 
   /** Returns a newly allocated canvas. The canvas contains the same
       image as the given surface provider */
-  static CL_PixelBuffer* create_canvas(CL_PixelBuffer*);
+  static CL_PixelBuffer create_canvas(const CL_PixelBuffer& );
 
   /** Sets all pixels of a canvas to zero */
-  static CL_PixelBuffer* clear_canvas(CL_PixelBuffer*);
+  static CL_PixelBuffer clear_canvas(CL_PixelBuffer& );
 
   /** Creates a new surface (based on a canvas) with the given width
       and height and stretches the source surface onto it
@@ -106,7 +106,7 @@
       @param width The new width of the surface.
       @param height The new height of the surface.
       @return A newly created surface, the caller is responsible to delete it. 
*/
-  static CL_PixelBuffer* scale_surface_to_canvas (const CL_Surface& sur, int 
width, int height);
+  static CL_PixelBuffer scale_surface_to_canvas (const CL_Surface& sur, int 
width, int height);
 
 private:
   Blitter (const Blitter&);

Modified: trunk/src/blitter_impl.hxx
===================================================================
--- trunk/src/blitter_impl.hxx  2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/blitter_impl.hxx  2004-05-05 20:30:41 UTC (rev 2299)
@@ -188,7 +188,7 @@
   int pwidth  = prov->get_width();
   int pheight = prov->get_height();
 
-  if (prov->is_indexed())
+  if (prov.get_type() ==  pixelformat_index)
     {
 #ifdef CLANLIB_0_6
       IndexedCanvas* canvas = new IndexedCanvas(TransF::get_width (pwidth, 
pheight),

Modified: trunk/src/capture_rectangle.cxx
===================================================================
--- trunk/src/capture_rectangle.cxx     2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/capture_rectangle.cxx     2004-05-05 20:30:41 UTC (rev 2299)
@@ -70,14 +70,13 @@
          // Draw the caputure rectangle
          sur->draw(pingu->get_center_pos() + Vector(x_offset,y_offset));
 
-#ifdef CLANLIB_0_6
-         font.print_center(static_cast<int>(pingu->get_center_pos().x) + 
x_offset,
-                            static_cast<int>(pingu->get_center_pos().y) + 
y_offset - 32,
-                            action_str.c_str());
-         /*font->print_center(pingu->get_center_pos().x + x_offset,
-                            pingu->get_center_pos().y + y_offset - 16 + 62,
-                            to_string(pingu->get_owner()).c_str());*/
-#endif
+          {
+            CL_Font myfont = font;
+            myfont.set_alignment(origin_top_center);
+            myfont.draw(static_cast<int>(pingu->get_center_pos().x) + x_offset,
+                        static_cast<int>(pingu->get_center_pos().y) + y_offset 
- 32,
+                        action_str);
+          }
 
          // Paint the direction arrow
          if (pingu->direction.is_left())

Modified: trunk/src/spot_map.cxx
===================================================================
--- trunk/src/spot_map.cxx      2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/spot_map.cxx      2004-05-05 20:30:41 UTC (rev 2299)
@@ -19,6 +19,7 @@
 
 #include <stdio.h>
 #include <ClanLib/Display/pixel_buffer.h>
+#include <ClanLib/Display/pixel_format.h>
 #include "gui/graphic_context.hxx"
 #include "plf.hxx"
 #include "pingus_error.hxx"
@@ -67,9 +68,8 @@
 void
 MapTileSurface::reload(void)
 {
-#ifdef CLANLIB_0_6
-  surface.reload();
-#endif
+  CL_PixelBuffer buf = surface.get_pixeldata();
+  surface = CL_Surface(&buf, false);
 }
 
 void
@@ -81,17 +81,16 @@
 void
 MapTileSurface::check_empty()
 {
-#ifdef CLANLIB_0_6
   // FIXME: obsolete
-  CL_PixelBuffer* provider = surface.get_provider();
+  CL_PixelBuffer provider = surface.get_pixeldata();
   unsigned char* buffer;
   int lenght;
 
   empty = true;
 
-  provider->lock();
-  lenght = provider->get_pitch() * provider->get_height();
-  buffer = static_cast<unsigned char*>(provider->get_data());
+  provider.lock();
+  lenght = provider.get_pitch() * provider.get_height();
+  buffer = static_cast<unsigned char*>(provider.get_data());
 
   // Jumping 4 steps because of RGBA
   for(int i=0; i < lenght; i += 4) {
@@ -101,8 +100,7 @@
     }
   }
 
-  surface.get_provider()->unlock();
-#endif
+  surface.get_pixeldata().unlock();
 }
 
 PingusSpotMap::PingusSpotMap(PLF* plf)
@@ -232,15 +230,14 @@
 }
 
 void
-PingusSpotMap::remove(CL_PixelBuffer* sprovider, int x, int y)
+PingusSpotMap::remove(const CL_PixelBuffer& sprovider, int x, int y)
 {
-#ifdef CLANLIB_0_6
   // Get the start tile and end tile
   int start_x = Math::max(x / tile_size, 0);
   int start_y = Math::max(y / tile_size, 0);
-  int end_x   = Math::min((x + sprovider->get_width()) / tile_size,
+  int end_x   = Math::min((x + sprovider.get_width()) / tile_size,
                           (width - 1) / tile_size);
-  int end_y   = Math::min((y + sprovider->get_height()) / tile_size,
+  int end_y   = Math::min((y + sprovider.get_height()) / tile_size,
                           (height - 1) / tile_size);
 
   for(int ix = start_x; ix <= end_x; ++ix)
@@ -249,7 +246,9 @@
        {
          if (!tile[ix][iy].is_empty())
            {
-             
put_alpha_surface(static_cast<CL_PixelBuffer*>(tile[ix][iy].surface.get_provider()),
+              CL_PixelBuffer target    = tile[ix][iy].surface.get_pixeldata();
+              CL_PixelBuffer sprovider = sprovider;
+             put_alpha_surface(target,
                                sprovider,
                                x - (ix * tile_size), y - (iy * tile_size),
                                // FIXME, I am broken
@@ -259,14 +258,12 @@
            }
        }
     }
-#endif
 }
 
 void
-PingusSpotMap::put_alpha_surface(CL_PixelBuffer* provider, CL_PixelBuffer* 
sprovider,
+PingusSpotMap::put_alpha_surface(CL_PixelBuffer& provider, CL_PixelBuffer& 
sprovider,
                                 int x, int y, int real_x_arg, int real_y_arg)
 {
-#ifdef CLANLIB_0_6
   int start_i;
   unsigned char* tbuffer; // Target buffer
   int twidth, theight, tpitch;
@@ -280,27 +277,27 @@
   int real_y;
 
   //  assert(sprovider->get_depth() == 8);
-  if (sprovider->get_depth() != 8)
+  if (sprovider.get_format().get_depth() != 8)
     {
       char str[128];
-      snprintf(str, 128, _("Image has wrong color depth: %d"), 
sprovider->get_depth());
+      snprintf(str, 128, _("Image has wrong color depth: %d"), 
sprovider.get_format().get_depth());
       PingusError::raise(str);
     }
   //  assert(provider->get_pixel_format() == RGBA8888);
 
-  provider->lock();
-  sprovider->lock();
+  provider.lock();
+  sprovider.lock();
 
-  tbuffer = static_cast<unsigned char*>(provider->get_data());
-  sbuffer = static_cast<unsigned char*>(sprovider->get_data());
+  tbuffer = static_cast<unsigned char*>(provider.get_data());
+  sbuffer = static_cast<unsigned char*>(sprovider.get_data());
 
-  twidth = provider->get_width();
-  theight = provider->get_height();
-  tpitch = provider->get_pitch();
+  twidth = provider.get_width();
+  theight = provider.get_height();
+  tpitch = provider.get_pitch();
 
-  swidth = sprovider->get_width();
-  sheight = sprovider->get_height();
-  spitch = sprovider->get_pitch();
+  swidth = sprovider.get_width();
+  sheight = sprovider.get_height();
+  spitch = sprovider.get_pitch();
 
   if (y < 0) {
     y_offset = 0-y;
@@ -357,19 +354,18 @@
       ++real_y;
     }
 
-  sprovider->unlock();
-  provider->unlock();
-#endif
+  sprovider.unlock();
+  provider.unlock();
 }
 
 void
-PingusSpotMap::put(CL_PixelBuffer* sprovider, int x, int y)
+PingusSpotMap::put(const CL_PixelBuffer& sprovider, int x, int y)
 {
   // Get the start tile and end tile
   int start_x = x / tile_size;
   int start_y = y / tile_size;
-  int end_x = (x + sprovider->get_width()) / tile_size;
-  int end_y = (y + sprovider->get_height()) / tile_size;
+  int end_x   = (x + sprovider.get_width())  / tile_size;
+  int end_y   = (y + sprovider.get_height()) / tile_size;
 
   if (start_x < 0)
     start_x = 0;
@@ -389,9 +385,9 @@
            {
              CL_PixelBuffer* canvas = Canvas::create_rgba8888(tile_size, 
tile_size);
 
-             Blitter::clear_canvas(canvas);
+             Blitter::clear_canvas(*canvas);
 
-             Blitter::put_surface(canvas, sprovider,
+             Blitter::put_surface(*canvas, sprovider,
                                   x - (ix * tile_size), y - (iy * tile_size));
 
              tile[ix][iy].surface = CL_Surface (canvas, true);

Modified: trunk/src/spot_map.hxx
===================================================================
--- trunk/src/spot_map.hxx      2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/spot_map.hxx      2004-05-05 20:30:41 UTC (rev 2299)
@@ -84,18 +84,18 @@
   int  get_width();
 
   /** Put the gives surface provider onto the given coordinates */
-  void put(CL_PixelBuffer*, int x, int y);
+  void put(const CL_PixelBuffer&, int x, int y);
 
   /** Remove the gives surface provider onto the given coordinates
       (everything non-transparent is removed from the map) */
-  void remove(CL_PixelBuffer*, int x, int y);
+  void remove(const CL_PixelBuffer&, int x, int y);
 
   float get_z_pos () const { return 0; }
 
 private:
   /** Low level version of the remove() call, acts on a single canvas
       instead on the complete map-tiles */
-  void put_alpha_surface(CL_PixelBuffer* provider, CL_PixelBuffer* sprovider,
+  void put_alpha_surface(CL_PixelBuffer& provider, CL_PixelBuffer& sprovider,
                         int x, int y, int real_x, int real_y);
 
   /** Draw the collision map onto the screen */

Modified: trunk/src/string_format.cxx
===================================================================
--- trunk/src/string_format.cxx 2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/string_format.cxx 2004-05-05 20:30:41 UTC (rev 2299)
@@ -63,28 +63,26 @@
   while ((pos = text.find("  ", pos)) != std::string::npos)
     text.replace(pos, 2, 1, ' ');
 
-#ifdef CLANLIB_0_6
   int start_pos      = 0;
   int previous_space = 0;
   pos = 0;
 
   while ((pos = text.find(' ', pos + 1)) != std::string::npos)
     {
-      if (font.get_text_width(text.substr(start_pos, pos - start_pos)) > 
length)
+      if (font.bounding_rect(0, 0, (text.substr(start_pos, pos - 
start_pos))).get_width() > length)
         {
          text[previous_space] = '\n';
          start_pos = previous_space + 1;
        }
-      else if (font.get_text_width(text.substr(start_pos, text.length())) <= 
length)
+      else if (font.bounding_rect(0, 0, text.substr(start_pos, 
text.length())).get_width() <= length)
         break;
 
       previous_space = pos;
     }
 
-  if (font->get_text_width(text.substr(start_pos, text.length() - start_pos)) 
> length)
+  if (font.bounding_rect(0, 0, text.substr(start_pos, text.length() - 
start_pos)).get_width() > length)
     text[text.rfind(' ')] = '\n';
 
-#endif
   return text;
 }
 

Modified: trunk/src/target_provider.hxx
===================================================================
--- trunk/src/target_provider.hxx       2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/target_provider.hxx       2004-05-05 20:30:41 UTC (rev 2299)
@@ -42,7 +42,7 @@
   void lock () { target->lock(); }
   void unlock () { target->unlock(); }
   void* get_data () const { return target->get_data (); }
-  bool  is_indexed () const { return target->is_indexed (); }
+  bool  is_indexed () const { return target->get_type() ==  pixelformat_index; 
}
   unsigned int get_num_frames () const { return target->get_num_frames (); }
   unsigned int get_width () const { return target->get_width (); }
   unsigned int get_height () const { return target->get_height (); }

Modified: trunk/src/worldobjs/exit.cxx
===================================================================
--- trunk/src/worldobjs/exit.cxx        2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/worldobjs/exit.cxx        2004-05-05 20:30:41 UTC (rev 2299)
@@ -62,11 +62,10 @@
 void
 Exit::on_startup ()
 {
-#ifdef CLANLIB_0_6
-  world->get_colmap()->remove(sprite.get_surface(),
+  CL_PixelBuffer pixelbuffer = 
sprite.get_sprite().get_frame_surface(0).get_pixeldata();
+  world->get_colmap()->remove(pixelbuffer,
                              static_cast<int>(data->pos.x) - 
sprite.get_width()/2,
                              static_cast<int>(data->pos.y) - 
sprite.get_height());
-#endif
 }
 
 void

Modified: trunk/src/worldobjs/surface_background.cxx
===================================================================
--- trunk/src/worldobjs/surface_background.cxx  2004-04-28 20:10:28 UTC (rev 
2298)
+++ trunk/src/worldobjs/surface_background.cxx  2004-05-05 20:30:41 UTC (rev 
2299)
@@ -45,7 +45,7 @@
 
   CL_Surface source_surface = PingusResource::load_surface(data->desc);
 
-  CL_PixelBuffer* canvas;
+  CL_PixelBuffer canvas;
 
   // Scaling Code
   if (data->stretch_x && data->stretch_y)
@@ -102,7 +102,7 @@
     }
 #endif
 
-  bg_surface = CL_Surface(canvas, true);
+  bg_surface = CL_Surface(&canvas, false);
 
 #ifdef CLANLIB_0_6
   //bg_surface = CAImageManipulation::changeHSV(bg_surface, 150, 100, 0);

Modified: trunk/src/xmlgz_reader.cxx
===================================================================
--- trunk/src/xmlgz_reader.cxx  2004-04-28 20:10:28 UTC (rev 2298)
+++ trunk/src/xmlgz_reader.cxx  2004-05-05 20:30:41 UTC (rev 2299)
@@ -77,4 +77,4 @@
     return doc;
 }
 
-} // namespace Pingus
\ No newline at end of file
+} // namespace Pingus





reply via email to

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