[maemo-commits] [maemo-commits] r11137 - in projects/haf/trunk/sapwood: . demos demos/images src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Apr 18 18:53:05 EEST 2007
Author: tko
Date: 2007-04-18 18:53:03 +0300 (Wed, 18 Apr 2007)
New Revision: 11137

Added:
   projects/haf/trunk/sapwood/demos/gradient.c
   projects/haf/trunk/sapwood/demos/gradient.gtkrc
   projects/haf/trunk/sapwood/demos/images/gradient.png
Modified:
   projects/haf/trunk/sapwood/ChangeLog
   projects/haf/trunk/sapwood/demos/Makefile.am
   projects/haf/trunk/sapwood/src/sapwood-server.c
Log:
MB#1216 - paint the pixmap white before compositing images with alpha

2007-04-18  Tommi Komulainen  <tommi.komulainen at nokia.com>

	* demos/Makefile.am
	* demos/gradient.c
	* demos/gradient.gtkrc
	* demos/images/gradient.png: Add testcase for gradient

	* src/sapwood-server.c (extract_pixmap_single): To avoid uninitialized
	pixels when loading images with alpha channel, paint the pixmap white
	first. MB#1216


Modified: projects/haf/trunk/sapwood/ChangeLog
===================================================================
--- projects/haf/trunk/sapwood/ChangeLog	2007-04-18 15:36:23 UTC (rev 11136)
+++ projects/haf/trunk/sapwood/ChangeLog	2007-04-18 15:53:03 UTC (rev 11137)
@@ -1,4 +1,15 @@
 2007-04-18  Tommi Komulainen  <tommi.komulainen at nokia.com>
+
+	* demos/Makefile.am
+	* demos/gradient.c
+	* demos/gradient.gtkrc
+	* demos/images/gradient.png: Add testcase for gradient
+
+	* src/sapwood-server.c (extract_pixmap_single): To avoid uninitialized
+	pixels when loading images with alpha channel, paint the pixmap white
+	first. MB#1216
+
+2007-04-18  Tommi Komulainen  <tommi.komulainen at nokia.com>
 	
 	* demos/Makefile.am
 	* demos/images/hbbox.png: remove ugly solid black image

Modified: projects/haf/trunk/sapwood/demos/Makefile.am
===================================================================
--- projects/haf/trunk/sapwood/demos/Makefile.am	2007-04-18 15:36:23 UTC (rev 11136)
+++ projects/haf/trunk/sapwood/demos/Makefile.am	2007-04-18 15:53:03 UTC (rev 11137)
@@ -3,6 +3,7 @@
 
 noinst_PROGRAMS = \
 	buttonbox \
+	gradient \
 	treeview
 
 CLEANFILES = engines
@@ -15,6 +16,9 @@
 	images/hbbox-tb.png \
 	images/hbbox-tlb.png \
 	images/hbbox-tlbr.png \
+	gradient.c \
+	gradient.gtkrc \
+	images/gradient.png \
 	treeview.c \
 	treeview.gtkrc \
 	images/treeview-active.png \

Added: projects/haf/trunk/sapwood/demos/gradient.c
===================================================================
--- projects/haf/trunk/sapwood/demos/gradient.c	2007-04-18 15:36:23 UTC (rev 11136)
+++ projects/haf/trunk/sapwood/demos/gradient.c	2007-04-18 15:53:03 UTC (rev 11137)
@@ -0,0 +1,50 @@
+/*
+ * This file is part of sapwood
+ *
+ * Copyright (C) 2007 Nokia Corporation. 
+ *
+ * Contact: Tommi Komulainen <tommi.komulainen at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#include <gtk/gtk.h>
+
+int
+main (int argc, char **argv)
+{
+  GtkWidget *window;
+  GtkWidget *align;
+  GtkWidget *button;
+
+  gtk_rc_add_default_file ("gradient.gtkrc");
+  gtk_init (&argc, &argv);
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+  button = gtk_button_new_with_label ("OK");
+
+  gtk_container_add (GTK_CONTAINER (window), align);
+  gtk_container_add (GTK_CONTAINER (align), button);
+
+  gtk_widget_set_size_request (button, 100, 100);
+
+  gtk_widget_show_all (window);
+
+  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+  gtk_main ();
+
+  return 0;
+}

Added: projects/haf/trunk/sapwood/demos/gradient.gtkrc
===================================================================
--- projects/haf/trunk/sapwood/demos/gradient.gtkrc	2007-04-18 15:36:23 UTC (rev 11136)
+++ projects/haf/trunk/sapwood/demos/gradient.gtkrc	2007-04-18 15:53:03 UTC (rev 11137)
@@ -0,0 +1,13 @@
+# vim:set ft=gtkrc sw=2 sts=2 expandtab:
+pixmap_path "images"
+
+style "button" {
+  engine "sapwood" {
+    image {
+      function = BOX
+      file = "gradient.png"
+    }
+  }
+}
+
+class "GtkButton" style "button"

Added: projects/haf/trunk/sapwood/demos/images/gradient.png
===================================================================
--- projects/haf/trunk/sapwood/demos/images/gradient.png	2007-04-18 15:36:23 UTC (rev 11136)
+++ projects/haf/trunk/sapwood/demos/images/gradient.png	2007-04-18 15:53:03 UTC (rev 11137)
@@ -0,0 +1,20 @@
+‰PNG
+
+   
IHDR   d   d   pâ•T   bKGD   ÊѸ   	pHYs     šœ   tIME×&+¨A‚º   tEXtComment Created with GIMPW  IDATxÚ­mrë¸Dì•osƒù“šç«èÓP\•r[Eâ£Ñ ÉŒèÿEÄWDü¾¾¾NŸ>;ý¿‡ëÿ¼lÿkhÇiïóó¯ásò_ÏýÏãýûóüë¾ß;"òû=¾ÿ|åã÷ÿC{yéC~n÷ÊËõ§¶Èwn÷Œá^)ú]s;jB>,qÃ|tˆÉI0qh÷ym]þ¾	Q>¾Ã=oýŸžå6éÓ`ñԐ’þפ †kSH]<´”<øíš\DÂk7““B@Bý4Ey™ÔÛ$œÞŸÚƒæ¥)ñ')‚¦îKþ¦ÙrRj<5€áÞH
+ÌúÂ\Q“†‰s­Œœ×æ e'Í›T½L{ì¬c2ŸÂ$
qwìœs&¨À)I–JgC at QbRN‚VâYû`âsãCÊt”ùèÀm•óTNa¾NSF[	&0Ìörc²è@՝®%æîoúÄ í’þ(­N Lö:¨…|?ÃG+LŸÓ™&Ík˜Æ%H–SEÑè” …b¶—‡»õú1gâò?ú^“¾ŠC|§‡kúÑ)o#X ¦üS‹þ)†)tØ€+Ò*00>GI{›ZXJD!2·oÊÜ*?"–æ·Œ´óÊ·$¼çíÞm’€Ô¹Ç¾FWëÕBÂHTíÂX2¨ÚO TÄ'6ðÔ¿!À>D¡‡‰%Q­Ë8Ñ9	pËfi`ý1v?ýH­
+ºH Ò‚‚<˜ês˜>#‡ ×á°Â@Ò‡dpÔ@ì.X2€”R¡”
--̘2׫¾¸;Â# I6Î¥'Ú`¤©IÌ`>“ú…›¹«ÉG•€jtÀ§@Íqô§®ÐYË
ÿ•@›i:ù°^ –1‚u™×ø*‚n,Îà°•NýņÏ,Ãߎ½à,~ª™Jâú(šK¨]hõ„‡˜¤M¼qK\ÍVAîi’ê6YÏ
•®¸,bHҪų3I ð5(/S
+º"à`« Ã¨AÊÁW)^N™Ú4-ÀQp
+LF	m šPʼn8f†  ‰n§Ñ>y~‰8I Fà)©¿rªDRÄ9§A£yô2 :œŽ¹>A˜Ùÿ;ö2ÕÎ¥8\Z݉Yb1Á)ÈÉÉ'M¹£2PÜh^Š3Q
+M•*´Ú‘°Ä´\‰ð\i\Oó-WA.#p
+ ¶×sN,äÔèÒR$Ê—9P‡nEM½æRÒhÜAx¡6ò9„Ú'õÌsþ\úà2hJËGîTÛŠA·äh3é·ÏH½VüϘh¡Áá“°
¤Ò™Ð¯&€X—A úi•Á–ák¬,ÙBB#»©r.Iꦉß+3üWŽ‹bï&²Ì +­šžíVžÓaìð_Tƒdɨ¢¦©	¢š@¾ÓXdœŸä©¢ø²Ã4Žúëû¸ÿ4¨–¼8­[¥û”ûˆ!b'ù‡ôS¨hcBùßä—I
+ÒèSAQ
+•'bЁ¬›u+4ßïä“„éí,ʪÎ$|à© €\K¡ð&ˆ¤ío3ÿý¸©É߀´Ìà&F¸±µ­pL•ŸÅ…aïD¢Q2’á=…ÓÉ9P™˜…Óüãe’‚½È](ˆšñse¯SG=…²g¦FãØ¥Ì‡Þ–Žª²›‚>‡c4²žx=ZÏK…Q9÷¾†øçPåN§I‡yVRÛB›*Øb"ú~LŸœù/ßí ¤Í}œÜöoÔL e­ŸõZÇLg-˜\"mGå0.“°É(º“í<“Zýû#Ц(‚€€2¤é-óJ©w²‡iš'œÌ
+^úXÐ$9Ÿ»”8 €¾	Ñe˜ÖæØF¢eJY8S›†h ‚˜.Ç”*O¢ô£¦Ôz Â[§"ؤAµÿ¬"„`c³Ii9‡¸³ƒ›<‹;@>œ/óþ”%šS·|ˆÊR	US¼þ›ïˆ—ZB›B˜o“Œ@¤J#†d¤Q{~ˇœ‚
+@Á Vù³XhÙWìTÐÔ85WÔÌ¤ÑÆ$µ
X'iD£q¢cßU 2’% ÈÄM òð„™¥vÝ韻t/&¤8%¨öށ)}‘uÝ
+::;œžx:g×ÊB8Ì/ªVå‘sâÀijæ>'™Æ.[PÐoö—¼š¿°;i ÙÛV
+Kl{.îé°Ñ›•Å×{• ¢]GµIÌ8‘tļêÉ…œ!ib‡"Ê)Rƒå7EŽm%	­
+»ÂiI!x><¶'ûKŸ´ð!îýÛêޝLjHM¸K
(ƒK×®Ëvi.¹†è´îÈÍ‘¼Ý4Œ®÷kƒÆ§È«^Z‚cô8=D
˜³°†H,qŠt]ù)V¾ë46eäd\
‰ˆ¨A‚*²:×Y[èÐizMP]™é›• þ4#¢éˆ¹|؉‹
+ Š-hHc¼a­äW{¶XÔLf ¡j†1¨j ·ÔC Ú àUÛol‹°éêá¿ÐšªËjȼºpÏÕ@‡Ð+ —o«Äz‡ ší‚•(³ O•õw8£·;[;±“2)	™‹„i{êZÐæI VN&’DÔC—b»9sÅH·2w´TÇ¡Úú+ô»°ÈNÄ»ÞÍ2nöu ¨·ö{‚geØHõPt÷ҍÿ½7p¦„G£¹Ž†ý-OA©8h„ê%u±l¥mÄ|È˜Ò ºþ8Éå:ƒoSs
+H‹Bso÷Ê¢¦ÅYvÝ}#}RÊ‚0°4@wåQå97§ýf3õºMÒ«5?eÞp»On„Î'Ÿ$YÁru¾â67±™@ºÍÈØN-\Ïk´ÖºQ]†	ÛÑf¬TÐ}…½JE2~;(Ž\×/¤ÔÙPÓé¯&ˆÙnŒÿ›E™`’9$}¿][ ½)Ö{œ,êCnU쥲Å% l€Á£ÊYC´Äe²å&˜nçÜ5'÷Þ‚¢¬Q'NÛ¡çÉ1Qáø)*HHgïóZPÙ1ô« ¦70Ñd„çŒá¤p§Ž›&ÈÔb¡©z]í³HËLæg6éÝ >„JÌoPîÄé«­@ÔrhçH$g»CÂuFxu¢
	¾˜AçA2U|W±Ïí;¹˜[ÿ§
Ö°™ ß›£ëÔý¨…!¹”·›üŒá?a܆š,ÊæÞÚR‹îÕòj¼½‘9]*~ê!@û ‚$ÛëP4*uèr‡Þ¸9ú
+¶˜´“I|S.…ù5A´Óo’\'Þç¶{Ðm¢œ#c7eJCo}ÈÄÀª¼À4 >ÅÿyíÄ[5DNt«õ7ÅãV—hˆãOœHœHÙôY-'Óááܨ}³Ê¸·‘úm7Ão6ÌwБ»ï!¡Ê	}Ôb£’¦
+ïuƒn©HsΑÞwNöÙVÞL09Ô>ý~“’Š9™ä-(†wRý†ù…\˜A—ÃJÁÙ8N½M4¥´‚fõ¦¸¤
³çfÿ(=òö¨½ ùjB(±Hsä|BµÕ¸Ý7HjHË]Œ¨Éš¾ÜŽ¶Ø¬ù£üñtr (^ÍY{8ië:õ\LÚ›õO§Wñ;1Ûœ#Á©ð¥NH@åBåHEÛOõÁjÀ˜”7ôˆS?Ñ:+
I€tܦøö,vbö:h÷ØW+©·Ñ'N1a”ÏÙ’êІfÆ­À! Á-²ËE†a/䧸    IEND®B`‚
\ No newline at end of file

Modified: projects/haf/trunk/sapwood/src/sapwood-server.c
===================================================================
--- projects/haf/trunk/sapwood/src/sapwood-server.c	2007-04-18 15:36:23 UTC (rev 11136)
+++ projects/haf/trunk/sapwood/src/sapwood-server.c	2007-04-18 15:53:03 UTC (rev 11137)
@@ -82,6 +82,11 @@
 		       int width, int height,
 		       PixbufOpenResponse *rep)
 {
+  /* This function is almost a copy of gdk_pixbuf_render_pixmap_and_mask() with
+   * the exception that it draws only a part of the pixbuf (could be achieved
+   * with gdk_pixbuf_new_subpixbuf()) and initializes the destination pixmap
+   * with white background to avoid uninitialized pixels when using alpha.
+   */
   GdkPixmap    *pixmap;
   static GdkGC *tmp_gc = NULL;
   gboolean      need_mask;
@@ -89,8 +94,15 @@
   pixmap = gdk_pixmap_new (NULL, width, height, server_depth);
 
   if (!tmp_gc)
-    tmp_gc = gdk_gc_new (pixmap);
+    {
+      const GdkColor white = {0, 0xffff, 0xffff, 0xffff};
 
+      tmp_gc = gdk_gc_new (pixmap);
+
+      gdk_gc_set_rgb_fg_color (tmp_gc, &white);
+    }
+
+  gdk_draw_rectangle (pixmap, tmp_gc, TRUE, 0, 0, width, height);
   gdk_draw_pixbuf (pixmap, tmp_gc, pixbuf,
 		   x, y, 0, 0,
 		   width, height,


More information about the maemo-commits mailing list