pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src blitter.cxx,1.20,1.21 blitter_impl.hx


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src blitter.cxx,1.20,1.21 blitter_impl.hxx,1.3,1.4 pingus_resource.cxx,1.19,1.20 screen_manager.cxx,1.21,1.22
Date: 19 Oct 2002 23:23:46 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv19017

Modified Files:
        blitter.cxx blitter_impl.hxx pingus_resource.cxx 
        screen_manager.cxx 
Log Message:
- speeded up the surfaces modifier a bit, a level which uses them now loads in 
600ms instead of in 2000ms :)

Index: blitter.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/blitter.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- blitter.cxx 19 Oct 2002 19:40:34 -0000      1.20
+++ blitter.cxx 19 Oct 2002 23:23:44 -0000      1.21
@@ -569,46 +569,14 @@
 CL_Surface
 Blitter::flip_horizontal (const CL_Surface& sur)
 {
-  CL_SurfaceProvider* prov = sur.get_provider ();
-  CL_Canvas* canvas = new CL_Canvas (sur.get_width (), sur.get_height ());
-
-  prov->lock ();
-  canvas->lock ();
-
-  float r, b, g, a;
-  for (unsigned int y = 0; y < sur.get_height (); ++y)
-    for (unsigned int x = 0; x < sur.get_width (); ++x)
-      {
-       prov->get_pixel (sur.get_width () - x - 1, y, &r, &g, &b, &a);
-       canvas->draw_pixel (x, y, r, g, b, a);
-      }
-
-  canvas->unlock ();
-  prov->unlock ();
-  return CL_Surface(canvas, true);
+  return BlitterImpl::modify<BlitterImpl::transform_flip>(sur);
 }
 
 /** Flip a surface vertical */
 CL_Surface
 Blitter::flip_vertical (const CL_Surface& sur)
 {
-  CL_SurfaceProvider* prov = sur.get_provider ();
-  CL_Canvas* canvas = new CL_Canvas (sur.get_width (), sur.get_height ());
-
-  prov->lock ();
-  canvas->lock ();
-
-  float r, b, g, a;
-  for (unsigned int y = 0; y < sur.get_height (); ++y)
-    for (unsigned int x = 0; x < sur.get_width (); ++x)
-      {
-       prov->get_pixel (x, sur.get_height () - y - 1, &r, &g, &b, &a);
-       canvas->draw_pixel (x, y, r, g, b, a);
-      }
-
-  canvas->unlock ();
-  prov->unlock ();
-  return CL_Surface(canvas, true);
+  return BlitterImpl::modify<BlitterImpl::transform_rot180_flip>(sur);
 }
 
 /** Rotate a surface 90 degrees */
@@ -682,19 +650,22 @@
 CL_Surface
 Blitter::rotate_90_flip (const CL_Surface& sur)
 {
-  return Blitter::flip_horizontal(Blitter::rotate_90(sur));
+  return BlitterImpl::modify<BlitterImpl::transform_rot90_flip>(sur);
+  //return Blitter::flip_horizontal(Blitter::rotate_90(sur));
 }
 
 CL_Surface
 Blitter::rotate_180_flip (const CL_Surface& sur)
 {
-  return Blitter::flip_horizontal(Blitter::rotate_180(sur));
+  return BlitterImpl::modify<BlitterImpl::transform_rot180_flip>(sur);
+  //return Blitter::flip_horizontal(Blitter::rotate_180(sur));
 }
 
 CL_Surface
 Blitter::rotate_270_flip (const CL_Surface& sur)
 {
-  return Blitter::flip_horizontal(Blitter::rotate_270(sur));
+  return BlitterImpl::modify<BlitterImpl::transform_rot270_flip>(sur);
+  //return Blitter::flip_horizontal(Blitter::rotate_270(sur));
 }
 
 /* EOF */

Index: blitter_impl.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/blitter_impl.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- blitter_impl.hxx    19 Oct 2002 22:22:48 -0000      1.3
+++ blitter_impl.hxx    19 Oct 2002 23:23:44 -0000      1.4
@@ -24,6 +24,7 @@
 namespace BlitterImpl
 {
 
+/** Rotate a surface 90 degree */
 struct transform_rot90
 {
   static inline int get_index(int width, int height, int x, int y) {
@@ -42,6 +43,7 @@
   static inline int get_height(int width, int height) { return width; }
 };
 
+/** Rotate a surface 180 degree */
 struct transform_rot180
 {
   static inline int get_index(int width, int height, int x, int y) {
@@ -60,18 +62,109 @@
   static inline int get_height(int width, int height) { UNUSED_ARG(width);  
return height; }
 };
 
+/** Rotate a surface 270 degree */
 struct transform_rot270
 {
-  static inline int get_index(int width, int height, int x, int y) { 
UNUSED_ARG(height);
+  static inline int get_index(int width, int height, int x, int y) { 
+    return ((width - x - 1) * height) + y;
+  }
+
+  static inline int get_x(int width, int height, int x, int y) { 
+    UNUSED_ARG(width); UNUSED_ARG(height); UNUSED_ARG(x);
+    return y;
+  }
+
+  static inline int get_y(int width, int height, int x, int y) {
+    UNUSED_ARG(height);
+    UNUSED_ARG(y);
+
+    return width - x - 1;
+  }
+
+  static inline int get_width (int width, int height) { UNUSED_ARG(width);  
return height; }
+  static inline int get_height(int width, int height) { UNUSED_ARG(height); 
return width; }
+};
+
+/** flip a surface  */
+struct transform_flip
+{
+  static inline int get_index(int width, int height, int x, int y) {
+    UNUSED_ARG(height);
+    return (y * width) + (width - x - 1);
+  }
+
+  static inline int get_x(int width, int height, int x, int y) { 
+    UNUSED_ARG(height); UNUSED_ARG(y);
+    return width - x - 1;
+  }
+
+  static inline int get_y(int width, int height, int x, int y) { 
+    UNUSED_ARG(width); UNUSED_ARG(height); UNUSED_ARG(x);
+    return y;
+  }
+
+  static inline int get_width (int width, int height) { UNUSED_ARG(height);  
return width; }
+  static inline int get_height(int width, int height) { UNUSED_ARG(width); 
return height; }
+};
+
+/** Rotate a surface 90 degree and then flip it */
+struct transform_rot90_flip
+{
+  static inline int get_index(int width, int height, int x, int y) {
+    UNUSED_ARG(width);
     return (x * height) + y;
   }
 
-  static inline int get_x(int width, int height, int x, int y) { 
UNUSED_ARG(width); UNUSED_ARG(height); UNUSED_ARG(x);
+  static inline int get_x(int width, int height, int x, int y) { 
+    UNUSED_ARG(width); UNUSED_ARG(height); UNUSED_ARG(x);
     return y;
   }
 
-  static inline int get_y(int width, int height, int x, int y) { 
UNUSED_ARG(width); UNUSED_ARG(y);
-    return height - x - 1;
+  static inline int get_y(int width, int height, int x, int y) { 
+    UNUSED_ARG(width); UNUSED_ARG(height); UNUSED_ARG(y);
+    return x;
+  }
+
+  static inline int get_width (int width, int height) { UNUSED_ARG(width);  
return height; }
+  static inline int get_height(int width, int height) { UNUSED_ARG(height); 
return width; }
+};
+
+/** Rotate a surface 180 degree and then flip it */
+struct transform_rot180_flip
+{
+  static inline int get_index(int width, int height, int x, int y) { 
+    return ((height - y - 1) * width) + x;
+  }
+
+  static inline int get_x(int width, int height, int x, int y) { 
+    UNUSED_ARG(width); UNUSED_ARG(height); UNUSED_ARG(y);
+    return x;
+  }
+
+  static inline int get_y(int width, int height, int x, int y) { 
+    UNUSED_ARG(width); UNUSED_ARG(x);
+    return height - y - 1;
+  }
+
+  static inline int get_width (int width, int height) { UNUSED_ARG(height);  
return width; }
+  static inline int get_height(int width, int height) { UNUSED_ARG(width); 
return height; }
+};
+
+/** Rotate a surface 270 degree and then flip it */
+struct transform_rot270_flip
+{
+  static inline int get_index(int width, int height, int x, int y) {
+    return ((width - x - 1) * height) + height - y - 1;
+  }
+
+  static inline int get_x(int width, int height, int x, int y) { 
+    UNUSED_ARG(width); UNUSED_ARG(x);
+    return height - y - 1;
+  }
+
+  static inline int get_y(int width, int height, int x, int y) { 
+    UNUSED_ARG(height); UNUSED_ARG(y);
+    return width - x - 1;
   }
 
   static inline int get_width (int width, int height) { UNUSED_ARG(width);  
return height; }
@@ -133,7 +226,6 @@
       prov->unlock ();
       return CL_Surface(canvas, true);
     }
-
 }
 
 } // namespace BlitterImpl

Index: pingus_resource.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_resource.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- pingus_resource.cxx 16 Oct 2002 09:14:45 -0000      1.19
+++ pingus_resource.cxx 19 Oct 2002 23:23:44 -0000      1.20
@@ -170,9 +170,6 @@
 CL_Surface
 PingusResource::apply_modifier (const CL_Surface& surf, const ResDescriptor& 
res_desc)
 {
-  if (res_desc.modifier != ResourceModifierNS::ROT0)
-    pout << "PingusResource::apply_modifier: Using expensive blitting" << 
std::endl;
-  
   switch (res_desc.modifier)
     {
       // FIXME: muahhhaa... I write slower code than you....

Index: screen_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen_manager.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- screen_manager.cxx  3 Oct 2002 12:33:08 -0000       1.21
+++ screen_manager.cxx  19 Oct 2002 23:23:44 -0000      1.22
@@ -99,6 +99,8 @@
        {
          if (get_current_screen()->draw (display_gc))
            Display::flip_display ();
+
+          //CL_Display::put_display(CL_Rect(0, 0, 100, 100));
        }
       else
        {





reply via email to

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