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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Jun 18 14:19:14 EEST 2008
Author: herzi
Date: 2008-06-18 14:19:08 +0300 (Wed, 18 Jun 2008)
New Revision: 15666

Modified:
   projects/haf/trunk/sapwood/ChangeLog
   projects/haf/trunk/sapwood/src/sapwood-draw.c
   projects/haf/trunk/sapwood/src/sapwood-main.c
   projects/haf/trunk/sapwood/src/sapwood-pixmap.c
   projects/haf/trunk/sapwood/src/sapwood-pixmap.h
   projects/haf/trunk/sapwood/src/sapwood-render.c
   projects/haf/trunk/sapwood/src/theme-pixbuf.h
Log:
2008-06-18  Sven Herzberg  <herzi at imendio.com>

	Debug pixmap size mismatches

	* src/sapwood-draw.c (draw_simple_image), (draw_gap_image),
	(draw_hline), (draw_vline): added a widget pointer
	* src/sapwood-main.c (theme_init): added SAPWOOD_DEBUG=scaling support
	* src/sapwood-pixmap.c (sapwood_pixmap_render_rects): debug pixmap
	scaling
	* src/sapwood-pixmap.h: added a variable to indicate whether we debug
	the sacling
	* src/sapwood-render.c (theme_pixbuf_render): added a widget pointer
	* src/theme-pixbuf.h: added a widget pointer



Modified: projects/haf/trunk/sapwood/ChangeLog
===================================================================
--- projects/haf/trunk/sapwood/ChangeLog	2008-06-18 10:53:16 UTC (rev 15665)
+++ projects/haf/trunk/sapwood/ChangeLog	2008-06-18 11:19:08 UTC (rev 15666)
@@ -1,3 +1,17 @@
+2008-06-18  Sven Herzberg  <herzi at imendio.com>
+
+	Debug pixmap size mismatches
+
+	* src/sapwood-draw.c (draw_simple_image), (draw_gap_image),
+	(draw_hline), (draw_vline): added a widget pointer
+	* src/sapwood-main.c (theme_init): added SAPWOOD_DEBUG=scaling support
+	* src/sapwood-pixmap.c (sapwood_pixmap_render_rects): debug pixmap
+	scaling
+	* src/sapwood-pixmap.h: added a variable to indicate whether we debug
+	the sacling
+	* src/sapwood-render.c (theme_pixbuf_render): added a widget pointer
+	* src/theme-pixbuf.h: added a widget pointer
+
 2007-09-25  Tommi Komulainen  <tommi.komulainen at nokia.com>
 
 	* === Release 3.0.0 ===

Modified: projects/haf/trunk/sapwood/src/sapwood-draw.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-draw.c	2008-06-18 10:53:16 UTC (rev 15665)
+++ projects/haf/trunk/sapwood/src/sapwood-draw.c	2008-06-18 11:19:08 UTC (rev 15666)
@@ -284,7 +284,7 @@
 	  if (maskwin)
 	    mask = gdk_pixmap_new (maskwin, width, height, 1);
 
-	  valid = theme_pixbuf_render (image->background,
+	  valid = theme_pixbuf_render (image->background, widget,
 				       window, mask, area,
 				       draw_center ? COMPONENT_ALL : COMPONENT_ALL | COMPONENT_CENTER,
 				       FALSE,
@@ -299,7 +299,7 @@
 	}
       
       if (image->overlay && draw_center)
-	theme_pixbuf_render (image->overlay,
+	theme_pixbuf_render (image->overlay, widget,
 			     window, NULL, area, COMPONENT_ALL,
 			     TRUE, 
 			     x, y, width, height);
@@ -439,19 +439,19 @@
 	}
 
       if (image->background)
-	theme_pixbuf_render (image->background,
+	theme_pixbuf_render (image->background, widget,
 			     window, NULL, area, components, FALSE,
 			     x, y, width, height);
       if (image->gap_start)
-	theme_pixbuf_render (image->gap_start,
+	theme_pixbuf_render (image->gap_start, widget,
 			     window, NULL, area, COMPONENT_ALL, FALSE,
 			     r1.x, r1.y, r1.width, r1.height);
       if (image->gap)
-	theme_pixbuf_render (image->gap,
+	theme_pixbuf_render (image->gap, widget,
 			     window, NULL, area, COMPONENT_ALL, FALSE,
 			     r2.x, r2.y, r2.width, r2.height);
       if (image->gap_end)
-	theme_pixbuf_render (image->gap_end,
+	theme_pixbuf_render (image->gap_end, widget,
 			     window, NULL, area, COMPONENT_ALL, FALSE,
 			     r3.x, r3.y, r3.width, r3.height);
 
@@ -488,7 +488,7 @@
   if (image)
     {
       if (image->background)
-	theme_pixbuf_render (image->background,
+	theme_pixbuf_render (image->background, widget,
 			     window, NULL, area, COMPONENT_ALL, FALSE,
 			     x1, y, (x2 - x1) + 1, 2);
     }
@@ -524,7 +524,7 @@
   if (image)
     {
       if (image->background)
-	theme_pixbuf_render (image->background,
+	theme_pixbuf_render (image->background, widget,
 			     window, NULL, area, COMPONENT_ALL, FALSE,
 			     x, y1, 2, (y2 - y1) + 1);
     }

Modified: projects/haf/trunk/sapwood/src/sapwood-main.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-main.c	2008-06-18 10:53:16 UTC (rev 15665)
+++ projects/haf/trunk/sapwood/src/sapwood-main.c	2008-06-18 11:19:08 UTC (rev 15666)
@@ -28,11 +28,22 @@
 #include "sapwood-rc-style.h"
 #include <gmodule.h>
 
+gboolean sapwood_debug_scaling = FALSE;
+
 G_MODULE_EXPORT void
 theme_init (GTypeModule *module)
 {
+  GDebugKey keys[] = {
+    {"scaling", TRUE}
+  };
+  const gchar* debug;
+
   sapwood_rc_style_register_type (module);
   sapwood_style_register_type (module);
+
+  debug = g_getenv ("SAPWOOD_DEBUG");
+  if (debug)
+    sapwood_debug_scaling = g_parse_debug_string (debug, keys, G_N_ELEMENTS (keys));
 }
 
 G_MODULE_EXPORT void

Modified: projects/haf/trunk/sapwood/src/sapwood-pixmap.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-pixmap.c	2008-06-18 10:53:16 UTC (rev 15665)
+++ projects/haf/trunk/sapwood/src/sapwood-pixmap.c	2008-06-18 11:19:08 UTC (rev 15666)
@@ -398,6 +398,7 @@
 
 void
 sapwood_pixmap_render_rects (SapwoodPixmap *self,
+			     GtkWidget     *widget,
                              GdkDrawable   *draw,
                              gint           draw_x,
                              gint           draw_y,
@@ -471,9 +472,25 @@
   cairo_clip (cr);
 
   cairo_translate (cr, draw_x, draw_y);
-  cairo_scale (cr, (double)width / (double)tmp_width,
-		   (double)height / (double)tmp_height);
 
+  if (width != tmp_width || height != tmp_height)
+    {
+      cairo_scale (cr, (double)width / (double)tmp_width,
+		       (double)height / (double)tmp_height);
+
+      if (sapwood_debug_scaling)
+        {
+	  g_warning ("scaling pixmap for %s: requested %dx%d; real %dx%d",
+		     G_OBJECT_TYPE_NAME (widget),
+		     width, height,
+		     self->width, self->height);
+	  cairo_save (tmp_cr);
+	  cairo_set_source_rgba (tmp_cr, 1.0, 1.0, 0.0, 0.25);
+	  cairo_paint (tmp_cr);
+	  cairo_restore (tmp_cr);
+        }
+    }
+
   cairo_set_source_surface (cr, cairo_get_target (tmp_cr), 0, 0);
   if (mask_cr)
     cairo_mask_surface (cr, cairo_get_target (mask_cr), 0, 0);

Modified: projects/haf/trunk/sapwood/src/sapwood-pixmap.h
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-pixmap.h	2008-06-18 10:53:16 UTC (rev 15665)
+++ projects/haf/trunk/sapwood/src/sapwood-pixmap.h	2008-06-18 11:19:08 UTC (rev 15666)
@@ -23,7 +23,7 @@
 #define SAPWOOD_PIXMAP_H 1
 
 #include <glib/gerror.h>
-#include <gdk/gdk.h>
+#include <gtk/gtk.h>
 
 G_BEGIN_DECLS
 
@@ -61,6 +61,7 @@
 				       GdkBitmap    **ret_pixmask) G_GNUC_INTERNAL;
 
 void      sapwood_pixmap_render_rects (SapwoodPixmap *self,
+				      GtkWidget      *widget,
 				      GdkDrawable  *draw,
 				      gint          draw_x,
 				      gint          draw_y,
@@ -74,6 +75,8 @@
 				      gint          n_rects,
 				      SapwoodRect   *rects) G_GNUC_INTERNAL;
 
+extern gboolean sapwood_debug_scaling;
+
 G_END_DECLS
 
 #endif

Modified: projects/haf/trunk/sapwood/src/sapwood-render.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-render.c	2008-06-18 10:53:16 UTC (rev 15665)
+++ projects/haf/trunk/sapwood/src/sapwood-render.c	2008-06-18 11:19:08 UTC (rev 15666)
@@ -273,6 +273,7 @@
  */
 gboolean
 theme_pixbuf_render (ThemePixbuf  *theme_pb,
+		     GtkWidget    *widget,
 		     GdkWindow    *window,
 		     GdkBitmap    *mask,
 		     GdkRectangle *clip_rect,
@@ -404,7 +405,7 @@
 	  mask_required = TRUE;
 	}
 
-      sapwood_pixmap_render_rects (pixmap,
+      sapwood_pixmap_render_rects (pixmap, widget,
                                    window, x, y, width, height,
                                    mask, mask_x, mask_y, mask_required,
                                    clip_rect, n_rect, rect);
@@ -439,7 +440,7 @@
       else if (mask)
 	g_object_ref (mask);
 
-      sapwood_pixmap_render_rects (pixmap,
+      sapwood_pixmap_render_rects (pixmap, widget,
                                    window, x, y, draw_width, draw_height,
                                    mask, mask_x, mask_y, FALSE,
                                    clip_rect, 1, rect);

Modified: projects/haf/trunk/sapwood/src/theme-pixbuf.h
===================================================================
--- projects/haf/trunk/sapwood/src/theme-pixbuf.h	2008-06-18 10:53:16 UTC (rev 15665)
+++ projects/haf/trunk/sapwood/src/theme-pixbuf.h	2008-06-18 11:19:08 UTC (rev 15666)
@@ -194,6 +194,7 @@
 void         theme_pixbuf_set_stretch  (ThemePixbuf  *theme_pb,
 					gboolean      stretch) G_GNUC_INTERNAL;
 gboolean     theme_pixbuf_render       (ThemePixbuf  *theme_pb,
+					GtkWidget    *widget,
 					GdkWindow    *window,
 					GdkBitmap    *mask,
 					GdkRectangle *clip_rect,


More information about the maemo-commits mailing list