[maemo-commits] [maemo-commits] r9301 - in projects/haf/trunk/sapwood: . src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Jan 24 16:00:57 EET 2007
Author: tko
Date: 2007-01-24 16:00:54 +0200 (Wed, 24 Jan 2007)
New Revision: 9301

Modified:
   projects/haf/trunk/sapwood/ChangeLog
   projects/haf/trunk/sapwood/src/sapwood-pixmap.c
   projects/haf/trunk/sapwood/src/sapwood-pixmap.h
   projects/haf/trunk/sapwood/src/sapwood-render.c
Log:
Pass pixmaps directly instead of reverse engineering them from coordinates

2007-01-24  Tommi Komulainen  <tommi.komulainen at nokia.com>

	Pass pixmaps directly instead of reverse engineering them from
	coordinates

	* src/sapwood-pixmap.h (sapwood_pixmap_get_pixmap)
	* src/sapwood-pixmap.c (get_pixmaps, sapwood_pixmap_get_pixmap):
	Export a function for getting pixmap and mask for each square
	* src/sapwood-pixmap.c (sapwood_pixmap_render_rects)
	* src/sapwood-pixmap.h (SapwoodRect)
	* src/sapwood-render.c (theme_pixbuf_render): replace source rectangle
	with pixmap and mask pointers


Modified: projects/haf/trunk/sapwood/ChangeLog
===================================================================
--- projects/haf/trunk/sapwood/ChangeLog	2007-01-24 14:00:50 UTC (rev 9300)
+++ projects/haf/trunk/sapwood/ChangeLog	2007-01-24 14:00:54 UTC (rev 9301)
@@ -1,5 +1,18 @@
 2007-01-24  Tommi Komulainen  <tommi.komulainen at nokia.com>
 
+	Pass pixmaps directly instead of reverse engineering them from
+	coordinates
+
+	* src/sapwood-pixmap.h (sapwood_pixmap_get_pixmap)
+	* src/sapwood-pixmap.c (get_pixmaps, sapwood_pixmap_get_pixmap):
+	Export a function for getting pixmap and mask for each square
+	* src/sapwood-pixmap.c (sapwood_pixmap_render_rects)
+	* src/sapwood-pixmap.h (SapwoodRect)
+	* src/sapwood-render.c (theme_pixbuf_render): replace source rectangle
+	with pixmap and mask pointers
+
+2007-01-24  Tommi Komulainen  <tommi.komulainen at nokia.com>
+
 	* src/sapwood-draw.c (draw_simple_image,draw_gap_image): remove unused
 	allow_setbg parameter
 	(draw_shadow,draw_arrow,draw_arrow,draw_arrow,draw_diamond,draw_box,

Modified: projects/haf/trunk/sapwood/src/sapwood-pixmap.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-pixmap.c	2007-01-24 14:00:50 UTC (rev 9300)
+++ projects/haf/trunk/sapwood/src/sapwood-pixmap.c	2007-01-24 14:00:54 UTC (rev 9301)
@@ -427,31 +427,10 @@
     g_object_unref (tmp_mask);
 }
 
-static void
-get_pixmaps (SapwoodPixmap *self, const GdkRectangle *area,
-	     GdkPixmap **pixmap, GdkBitmap **pixmask)
+void
+sapwood_pixmap_get_pixmap (SapwoodPixmap *self, gint i, gint j,
+			   GdkPixmap **pixmap, GdkBitmap **pixmask)
 {
-  gint i;
-  gint j;
-
-  if (area->y == 0 && area->height == self->height)
-    i = 1;
-  else if (area->y == self->border_top)
-    i = 1;
-  else if (area->y == 0)
-    i = 0;
-  else
-    i = 2;
-
-  if (area->x == 0 && area->width == self->width)
-    j = 1;
-  else if (area->x == self->border_left)
-    j = 1;
-  else if (area->x == 0)
-    j = 0;
-  else
-    j = 2;
-
   *pixmap  = self->pixmap[i][j];
   *pixmask = self->pixmask[i][j];
 }
@@ -472,8 +451,6 @@
   static GdkGC *mask_gc = NULL;
   static GdkGC *draw_gc = NULL;
   GdkGCValues   values;
-  GdkPixmap    *pixmap;
-  GdkBitmap    *pixmask;
   gint          xofs;
   gint          yofs;
   gint          n;
@@ -490,7 +467,6 @@
 
   for (n = 0; n < n_rect; n++)
     {
-      const GdkRectangle       *src  = &rect[n].src;
       /* const */ GdkRectangle *dest = &rect[n].dest;
       GdkRectangle              area;
 
@@ -502,10 +478,9 @@
       else
 	area = *dest;
 
-      get_pixmaps (self, src, &pixmap, &pixmask);
-      if (pixmap && pixmask)
+      if (rect[n].pixmap && rect[n].pixmask)
 	{
-	  values.tile = pixmask;
+	  values.tile = rect[n].pixmask;
 	  values.ts_x_origin = dest->x - xofs;
 	  values.ts_y_origin = dest->y - yofs;
 	  gdk_gc_set_values (mask_gc, &values, GDK_GC_TILE|GDK_GC_TS_X_ORIGIN|GDK_GC_TS_Y_ORIGIN);
@@ -530,7 +505,6 @@
 
   for (n = 0; n < n_rect; n++)
     {
-      const GdkRectangle       *src  = &rect[n].src;
       /* const */ GdkRectangle *dest = &rect[n].dest;
       GdkRectangle              area;
 
@@ -542,10 +516,9 @@
       else
 	area = *dest;
 
-      get_pixmaps (self, src, &pixmap, &pixmask);
-      if (pixmap)
+      if (rect[n].pixmap)
 	{
-	  values.tile = pixmap;
+	  values.tile = rect[n].pixmap;
 	  values.ts_x_origin = dest->x;
 	  values.ts_y_origin = dest->y;
 	  gdk_gc_set_values (draw_gc, &values, GDK_GC_TILE|GDK_GC_TS_X_ORIGIN|GDK_GC_TS_Y_ORIGIN);

Modified: projects/haf/trunk/sapwood/src/sapwood-pixmap.h
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-pixmap.h	2007-01-24 14:00:50 UTC (rev 9300)
+++ projects/haf/trunk/sapwood/src/sapwood-pixmap.h	2007-01-24 14:00:54 UTC (rev 9301)
@@ -36,7 +36,8 @@
 typedef struct _SapwoodPixmap SapwoodPixmap;
 
 typedef struct {
-    GdkRectangle src;
+    GdkPixmap *pixmap;
+    GdkPixmap *pixmask;
     GdkRectangle dest;
 } SapwoodRect;
 
@@ -53,6 +54,12 @@
 				      gint         *width,
 				      gint         *height) G_GNUC_INTERNAL;
 
+void      sapwood_pixmap_get_pixmap   (SapwoodPixmap *self,
+				       gint           x,
+				       gint           y,
+				       GdkPixmap    **ret_pixmap,
+				       GdkBitmap    **ret_pixmask) G_GNUC_INTERNAL;
+
 void      sapwood_pixmap_render       (SapwoodPixmap *self,
 				      GdkWindow    *window,
 				      GdkBitmap    *mask,

Modified: projects/haf/trunk/sapwood/src/sapwood-render.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-render.c	2007-01-24 14:00:50 UTC (rev 9300)
+++ projects/haf/trunk/sapwood/src/sapwood-render.c	2007-01-24 14:00:54 UTC (rev 9301)
@@ -264,6 +264,8 @@
 
   if (theme_pb->stretch)
     {
+      SapwoodPixmap *pixmap;
+
       src_x[0] = 0;
       src_x[1] = theme_pb->border_left;
       src_x[2] = pixbuf_width - theme_pb->border_right;
@@ -287,18 +289,18 @@
       if (component_mask & COMPONENT_ALL)
 	component_mask = (COMPONENT_ALL - 1) & ~component_mask;
 
-#define RENDER_COMPONENT(X,Y) do {			\
-    rect[n_rect].src.x = src_x[X];			\
-    rect[n_rect].src.y = src_y[Y];			\
-    rect[n_rect].src.width = src_x[X+1] - src_x[X];	\
-    rect[n_rect].src.height = src_y[Y+1] - src_y[Y];	\
-							\
-    rect[n_rect].dest.x = dest_x[X];			\
-    rect[n_rect].dest.y = dest_y[Y];			\
-    rect[n_rect].dest.width = dest_x[X+1] - dest_x[X];	\
-    rect[n_rect].dest.height = dest_y[Y+1] - dest_y[Y];	\
-							\
-    n_rect++;						\
+      pixmap = theme_pixbuf_get_pixmap (theme_pb);
+
+#define RENDER_COMPONENT(X,Y) do {			           \
+    sapwood_pixmap_get_pixmap (pixmap, X, Y, &rect[n_rect].pixmap, \
+			       &rect[n_rect].pixmask);	           \
+							           \
+    rect[n_rect].dest.x = dest_x[X];			           \
+    rect[n_rect].dest.y = dest_y[Y];			           \
+    rect[n_rect].dest.width = dest_x[X+1] - dest_x[X];	           \
+    rect[n_rect].dest.height = dest_y[Y+1] - dest_y[Y];	           \
+							           \
+    n_rect++;						           \
 } while(0)
       
       n_rect = 0;


More information about the maemo-commits mailing list