Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#9426) simplification of drawn sprites
Home

[Freeciv-Dev] (PR#9426) simplification of drawn sprites

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9426) simplification of drawn sprites
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 18 Jul 2004 20:37:34 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9426 >

This patch removes the width and offset parameters from 
pixmap_put_drawn_sprite and pixmap_put_overlay_tile_draw.

Neither are needed anymore.

This is a prelude toward merging some of these functions and their 
callers into mapview_common.

jason

? confdefs.h
? conftest.c
? conftest.er1
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.225
diff -u -r1.225 mapview.c
--- client/gui-gtk/mapview.c    10 Jul 2004 18:48:18 -0000      1.225
+++ client/gui-gtk/mapview.c    19 Jul 2004 03:34:25 -0000
@@ -60,8 +60,6 @@
 static void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
                                         int canvas_x, int canvas_y,
                                         struct Sprite *ssprite,
-                                        int offset_x, int offset_y,
-                                        int width, int height,
                                         bool fog);
 static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
                                int canvas_x, int canvas_y,
@@ -625,8 +623,9 @@
                                    int canvas_x, int canvas_y,
                                    struct Sprite *ssprite)
 {
-  if (!ssprite)
+  if (!ssprite) {
     return;
+  }
       
   gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
   gdk_gc_set_clip_mask(civ_gc, ssprite->mask);
@@ -740,15 +739,14 @@
 static void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
                                         int canvas_x, int canvas_y,
                                         struct Sprite *ssprite,
-                                        int offset_x, int offset_y,
-                                        int width, int height,
                                         bool fog)
 {
-  if (!ssprite || !width || !height)
+  if (!ssprite) {
     return;
+  }
 
   pixmap_put_sprite(pixmap, canvas_x, canvas_y, ssprite,
-                   offset_x, offset_y, width, height);
+                   0, 0, ssprite->width, ssprite->height);
 
   /* I imagine this could be done more efficiently. Some pixels We first
      draw from the sprite, and then draw black afterwards. It would be much
@@ -761,9 +759,7 @@
     gdk_gc_set_stipple(fill_tile_gc, black50);
 
     gdk_draw_rectangle(pixmap, fill_tile_gc, TRUE,
-                      canvas_x+offset_x, canvas_y+offset_y,
-                      MIN(width, MAX(0, ssprite->width-offset_x)),
-                      MIN(height, MAX(0, ssprite->height-offset_y)));
+                      canvas_x, canvas_y, ssprite->width, ssprite->height);
     gdk_gc_set_clip_mask(fill_tile_gc, NULL);
   }
 }
@@ -901,16 +897,12 @@
 static void pixmap_put_drawn_sprite(GdkDrawable *pixmap,
                                    int canvas_x, int canvas_y,
                                    struct drawn_sprite *pdsprite,
-                                   int offset_x, int offset_y,
-                                   int width, int height,
                                    bool fog)
 {
   int ox = pdsprite->offset_x, oy = pdsprite->offset_y;
 
   pixmap_put_overlay_tile_draw(pixmap, canvas_x + ox, canvas_y + oy,
                               pdsprite->sprite,
-                              offset_x - ox, offset_y - oy,
-                              width, height,
                               fog);
 }
 
@@ -994,14 +986,12 @@
       switch (tile_sprs[i].style) {
       case DRAW_NORMAL:
        pixmap_put_drawn_sprite(pm, canvas_x, canvas_y, &tile_sprs[i],
-                               0, 0, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT,
                                fog && tile_sprs[i].foggable);
        break;
       case DRAW_FULL:
        pixmap_put_drawn_sprite(pm, canvas_x,
                                canvas_y - NORMAL_TILE_HEIGHT / 2,
                                &tile_sprs[i],
-                               0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
                                fog && tile_sprs[i].foggable);
        break;
       }
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.131
diff -u -r1.131 mapview.c
--- client/gui-gtk-2.0/mapview.c        10 Jul 2004 18:48:18 -0000      1.131
+++ client/gui-gtk-2.0/mapview.c        19 Jul 2004 03:34:25 -0000
@@ -61,8 +61,6 @@
 static void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
                                         int canvas_x, int canvas_y,
                                         struct Sprite *ssprite,
-                                        int offset_x, int offset_y,
-                                        int width, int height,
                                         bool fog);
 static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
                                int canvas_x, int canvas_y,
@@ -647,8 +645,9 @@
                                    int canvas_x, int canvas_y,
                                    struct Sprite *ssprite)
 {
-  if (!ssprite)
+  if (!ssprite) {
     return;
+  }
       
   gdk_gc_set_clip_origin(civ_gc, canvas_x, canvas_y);
   gdk_gc_set_clip_mask(civ_gc, ssprite->mask);
@@ -804,15 +803,14 @@
 static void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
                                         int canvas_x, int canvas_y,
                                         struct Sprite *ssprite,
-                                        int offset_x, int offset_y,
-                                        int width, int height,
                                         bool fog)
 {
-  if (!ssprite || !width || !height)
+  if (!ssprite) {
     return;
+  }
 
   pixmap_put_sprite(pixmap, canvas_x, canvas_y, ssprite,
-                   offset_x, offset_y, width, height);
+                   0, 0, ssprite->width, ssprite->height);
 
   /* I imagine this could be done more efficiently. Some pixels We first
      draw from the sprite, and then draw black afterwards. It would be much
@@ -825,9 +823,7 @@
     gdk_gc_set_stipple(fill_tile_gc, black50);
 
     gdk_draw_rectangle(pixmap, fill_tile_gc, TRUE,
-                      canvas_x+offset_x, canvas_y+offset_y,
-                      MIN(width, MAX(0, ssprite->width-offset_x)),
-                      MIN(height, MAX(0, ssprite->height-offset_y)));
+                      canvas_x, canvas_y, ssprite->width, ssprite->height);
     gdk_gc_set_clip_mask(fill_tile_gc, NULL);
   }
 }
@@ -965,16 +961,12 @@
 static void pixmap_put_drawn_sprite(GdkDrawable *pixmap,
                                    int canvas_x, int canvas_y,
                                    struct drawn_sprite *pdsprite,
-                                   int offset_x, int offset_y,
-                                   int width, int height,
                                    bool fog)
 {
   int ox = pdsprite->offset_x, oy = pdsprite->offset_y;
 
   pixmap_put_overlay_tile_draw(pixmap, canvas_x + ox, canvas_y + oy,
                               pdsprite->sprite,
-                              offset_x - ox, offset_y - oy,
-                              width, height,
                               fog);
 }
 
@@ -1058,14 +1050,12 @@
       switch (tile_sprs[i].style) {
       case DRAW_NORMAL:
        pixmap_put_drawn_sprite(pm, canvas_x, canvas_y, &tile_sprs[i],
-                               0, 0, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT,
                                fog && tile_sprs[i].foggable);
        break;
       case DRAW_FULL:
        pixmap_put_drawn_sprite(pm, canvas_x,
                                canvas_y - NORMAL_TILE_HEIGHT / 2,
                                &tile_sprs[i],
-                               0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
                                fog && tile_sprs[i].foggable);
        break;
       }
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.125
diff -u -r1.125 mapview.c
--- client/gui-win32/mapview.c  18 Jul 2004 04:50:23 -0000      1.125
+++ client/gui-win32/mapview.c  19 Jul 2004 03:34:25 -0000
@@ -731,8 +731,6 @@
 static void pixmap_put_overlay_tile_draw(HDC hdc,
                                          int canvas_x, int canvas_y,
                                          struct Sprite *ssprite,
-                                         int offset_x, int offset_y,
-                                         int width, int height,
                                          bool fog)
 {
   if (!ssprite || !width || !height)
@@ -806,9 +804,8 @@
   } else {
     hdc = pcanvas->hdc;
   }
-  pixmap_put_overlay_tile_draw(hdc, canvas_x, canvas_y,
-                              sprite, offset_x, offset_y,
-                              width, height, 0);
+  draw_sprite_part(sprite, hdx, canvas_x, canvas_y,
+                  sprite->width, sprite->height, 0, 0, sprite);
   if (pcanvas->bitmap) {
     SelectObject(hdc, old);
     DeleteDC(hdc);
@@ -901,19 +898,13 @@
 static void pixmap_put_drawn_sprite(HDC hdc,
                                     int canvas_x, int canvas_y,
                                     struct drawn_sprite *pdsprite,
-                                    int offset_x, int offset_y,
-                                    int width, int height,
                                     bool fog)
 {
-   
   int ox = pdsprite->offset_x, oy = pdsprite->offset_y;
   
   
   pixmap_put_overlay_tile_draw(hdc, canvas_x + ox, canvas_y + oy,
-                               pdsprite->sprite,
-                               offset_x - ox, offset_y - oy,
-                               width, height,
-                               fog);
+                               pdsprite->sprite, fog);
   
 }
 
@@ -968,14 +959,12 @@
       switch (tile_sprs[i].style) {
       case DRAW_NORMAL:
        pixmap_put_drawn_sprite(hdc, canvas_x, canvas_y, &tile_sprs[i],
-                               0, 0, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT,
                                fog && tile_sprs[i].foggable);
        break;
       case DRAW_FULL:
        pixmap_put_drawn_sprite(hdc,
                                canvas_x, canvas_y - NORMAL_TILE_HEIGHT / 2,
                                &tile_sprs[i],
-                               0, 0, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
                                fog && tile_sprs[i].foggable);
        break;
       }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9426) simplification of drawn sprites, Jason Short <=