[cairo-commit] cairo-gtk-engine/src cge-draw.c, 1.18, 1.19 cge-style.c, 1.8, 1.9 cge.h, 1.3, 1.4

Carl Worth commit at pdx.freedesktop.org
Thu Feb 3 14:24:02 PST 2005


Committed by: cworth

Update of /cvs/cairo/cairo-gtk-engine/src
In directory gabe:/tmp/cvs-serv18665/src

Modified Files:
	cge-draw.c cge-style.c cge.h 
Log Message:

        * src/cge.h:
        * src/cge-draw.c: (debug_msg), (cge_create_gradient),
        (cge_draw_box), (cge_draw_circle), (cge_draw_box_gap),
        (cge_draw_notebook_tab), (cge_create_gradient_from_rc),
        (cge_draw_filled_box_from_rc), (draw_shadow_gap), (draw_box_gap),
        (draw_extension): Ripped out old transformed-surface-as-gradient
        hack in favor of new linear_pattern support now in cairo. Updated
        to compile against latest (0.3.0) cairo without
        warnings. Eliminated other minor warnings. Seems basically
        functional now.


Index: cge-draw.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/cge-draw.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cge-draw.c	3 Feb 2005 20:03:59 -0000	1.18
+++ cge-draw.c	3 Feb 2005 22:24:00 -0000	1.19
@@ -24,12 +24,13 @@
 
 /*#define DEBUG*/
 
-void debug_msg(gchar *fun,
-	       const gchar *detail,
-	       gdouble x,
-	       gdouble y, 
-	       gdouble w,
-	       gdouble h)
+static void
+debug_msg(gchar *fun,
+	  const gchar *detail,
+	  gdouble x,
+	  gdouble y, 
+	  gdouble w,
+	  gdouble h)
 {
 #ifdef DEBUG
     printf("cge:%s(%s) at %ix%ix%ix%i\n",fun,detail,(int)x,(int)y,(int)w,(int)h);
@@ -62,7 +63,7 @@
 static cge_style *
 cge_get_style(GtkStyle *style,const gchar *detail);
 
-static cairo_surface_t *
+static cairo_pattern_t *
 cge_create_gradient(cairo_t *xrs,
 		    gint ncols,
 		    GdkColor *colors,
@@ -114,7 +115,7 @@
 static void
 cge_draw_box (cairo_t *xrs,
 	      GdkColor c,
-	      cairo_surface_t *pattern,
+	      cairo_pattern_t *pattern,
 	      gdouble alpha,
 	      gdouble x,
 	      gdouble y,
@@ -127,7 +128,7 @@
 static void
 cge_draw_circle (cairo_t *xrs,
 		 GdkColor c,
-		 cairo_surface_t *pattern,
+		 cairo_pattern_t *pattern,
 		 gdouble alpha,
 		 gint x,
 		 gint y,
@@ -138,7 +139,7 @@
 static void
 cge_draw_box_gap (cairo_t *xrs,
 		  GdkColor c,
-		  cairo_surface_t *pattern,
+		  cairo_pattern_t *pattern,
 		  gdouble alpha,
 		  gdouble x,
 		  gdouble y,
@@ -153,7 +154,7 @@
 static void
 cge_draw_notebook_tab(cairo_t *xrs,
 		      GdkColor c,
-		      cairo_surface_t *pattern,
+		      cairo_pattern_t *pattern,
 		      gdouble alpha,
 		      gdouble x,
 		      gdouble y,
@@ -163,7 +164,7 @@
 		      gboolean fill,
 		      gdouble line_width);
 
-static cairo_surface_t *
+static cairo_pattern_t *
 cge_create_gradient_from_rc(cairo_t *xrs,
 			    GtkStyle * style,
 			    GtkStateType state_type,
@@ -303,6 +304,7 @@
 	      gint gap_x,
 	      gint gap_width);
 
+#if 0
 static void
 draw_flat_box (GtkStyle * style,
 	       GdkWindow * window,
@@ -312,6 +314,7 @@
 	       GtkWidget * widget,
 	       const gchar * detail,
 	       gint x, gint y, gint width, gint height);
+#endif
 
 static void
 draw_check (GtkStyle * style,
@@ -496,7 +499,7 @@
     cairo_restore(xrs);
 }
 
-static cairo_surface_t *
+static cairo_pattern_t *
 cge_create_gradient(cairo_t *xrs,
 		    gint ncols,
 		    GdkColor *colors,
@@ -507,52 +510,26 @@
 		    gint width,
 		    gint height)
 {
-    cairo_surface_t *sur;
-    cairo_matrix_t *matrix;
+    cairo_pattern_t *pattern;
     gint i;
 
-    /*  sur=cairo_surface_create_similar(cairo_current_target_surface(xrs),
-    				   CAIRO_FORMAT_ARGB32,
-    				   ncols,ncols);
-    */
-
-    sur=cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
-				   ncols,ncols);
-    cairo_save(xrs);
-    cairo_set_target_surface(xrs,sur);
-
-    cairo_translate(xrs,(double)x_off,(double)y_off);
-
+    if (d == CGE_DIRECTION_HORIZONTAL)
+	pattern = cairo_pattern_create_linear (x_off, y_off,
+					       x_off + width, y_off);
+    else
+	pattern = cairo_pattern_create_linear (x_off, y_off,
+					       x_off, y_off + height);
+					   
     for(i=0;i<ncols;i++)
     {
 	gdouble r,g,b;	
 
 	color_gdk_to_rgb(colors[i],&r,&g,&b);     
-	cairo_set_rgb_color(xrs, r, g, b);	
-	cairo_set_alpha(xrs,alpha);
-	switch (d)
-	{
-	case CGE_DIRECTION_VERTICAL:
-	    cairo_rectangle(xrs,0,i,ncols,1);  
-	    break;
-	case CGE_DIRECTION_HORIZONTAL:	  	
-	    cairo_rectangle(xrs,i,0,1,ncols);	  
-	    break;
-	}
 
-	cairo_fill(xrs);
+	cairo_pattern_add_color_stop (pattern, i * 1.0 / ncols, r, g, b, alpha);
     } 
 
-    cairo_restore(xrs);
- 
-    matrix=cairo_matrix_create();
-    cairo_matrix_scale(matrix,(double)(ncols-1)/width,(double)(ncols-1)/height);
-    cairo_surface_set_matrix(sur,matrix);
-
-    cairo_surface_set_filter(sur, CAIRO_FILTER_BILINEAR);
-    cairo_matrix_destroy(matrix);
-
-    return sur;
+    return pattern;
 }
 
 /*
@@ -795,7 +772,7 @@
 static void
 cge_draw_box(cairo_t *xrs,
 	     GdkColor c,
-	     cairo_surface_t *pattern,
+	     cairo_pattern_t *pattern,
 	     gdouble alpha,
 	     gdouble x,
 	     gdouble y,
@@ -870,7 +847,7 @@
 static void
 cge_draw_circle(cairo_t *xrs,
 		GdkColor c,
-		cairo_surface_t *pattern,
+		cairo_pattern_t *pattern,
 		gdouble alpha,
 		gint x,
 		gint y,
@@ -934,7 +911,7 @@
 static void
 cge_draw_box_gap(cairo_t *xrs,
 		 GdkColor c,
-		 cairo_surface_t *pattern,
+		 cairo_pattern_t *pattern,
 		 gdouble alpha,
 		 gdouble x,
 		 gdouble y,
@@ -1007,7 +984,7 @@
 static void
 cge_draw_notebook_tab(cairo_t *xrs,
 		      GdkColor c,
-		      cairo_surface_t *pattern,
+		      cairo_pattern_t *pattern,
 		      gdouble alpha,
 		      gdouble x,
 		      gdouble y,
@@ -1065,16 +1042,17 @@
     cairo_restore(xrs);
 }
 
-cairo_surface_t *cge_create_gradient_from_rc(cairo_t *xrs,
-					     GtkStyle * style,
-					     GtkStateType state_type,
-					     const gchar *detail,
-					     gint x_off,
-					     gint y_off,
-					     gint width,
-					     gint height)
+cairo_pattern_t *
+cge_create_gradient_from_rc(cairo_t *xrs,
+			    GtkStyle * style,
+			    GtkStateType state_type,
+			    const gchar *detail,
+			    gint x_off,
+			    gint y_off,
+			    gint width,
+			    gint height)
 {
-    cairo_surface_t *gradient;
+    cairo_pattern_t *gradient;
     GdkColor *colors;
     gint i;
     cge_style *cstyle;
@@ -1143,7 +1121,7 @@
 			    gint height)
 
 {
-    cairo_surface_t *gradient;
+    cairo_pattern_t *gradient;
     GdkColor color;
     cge_style *cstyle;
 
@@ -1215,7 +1193,7 @@
     }
 
     if(gradient)
-	cairo_surface_destroy(gradient);
+	cairo_pattern_destroy(gradient);
 }
 
 
@@ -1527,7 +1505,7 @@
     cairo_t *xrs;
     gint x_off=0,y_off=0;
     GdkColor color;
-    cairo_surface_t *gradient;
+    cairo_pattern_t *gradient;
     cge_style *cstyle;
 
     debug_msg("draw_shadow_gap",detail,x,y,width,height);
@@ -1571,7 +1549,7 @@
 		     cstyle->line_style.line_width);
 
     if(gradient)
-	cairo_surface_destroy(gradient);
+	cairo_pattern_destroy(gradient);
   
     cairo_destroy(xrs);
 }
@@ -1740,7 +1718,7 @@
     cairo_t *xrs;
     gint x_off=0,y_off=0;
     GdkColor color;
-    cairo_surface_t *gradient;
+    cairo_pattern_t *gradient;
     cge_style *cstyle;
 
     debug_msg("draw_box_gap",detail,x,y,width,height);
@@ -1788,11 +1766,12 @@
 		     cstyle->line_style.line_width);
   
     if(gradient)
-	cairo_surface_destroy(gradient);
+	cairo_pattern_destroy(gradient);
   
     cairo_destroy(xrs);
 }
 
+#if 0
 static void
 draw_flat_box (GtkStyle * style,
 	       GdkWindow * window,
@@ -1837,6 +1816,7 @@
 
     cairo_destroy(xrs);
 }
+#endif
 
 static void
 draw_check (GtkStyle * style,
@@ -1996,7 +1976,7 @@
 		GtkPositionType gap_side)
 {
     cairo_t *xrs;
-    cairo_surface_t *gradient;
+    cairo_pattern_t *gradient;
     GdkColor color;
     gint x_off,y_off;
     cge_style *cstyle;
@@ -2040,7 +2020,7 @@
 			  cstyle->line_style.line_width);
 
     if(gradient)
-	cairo_surface_destroy(gradient);
+	cairo_pattern_destroy(gradient);
   
     cairo_destroy(xrs);
 
@@ -2191,6 +2171,7 @@
 }
 
 /* should work */
+#if 0
 static void
 set_background (GtkStyle      *style,
 		GdkWindow     *window,
@@ -2247,7 +2228,7 @@
 
     cairo_destroy(xrs);
 }
-
+#endif
 
 GType cge_type_style = 0;
 

Index: cge-style.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/cge-style.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cge-style.c	3 Feb 2005 20:03:59 -0000	1.8
+++ cge-style.c	3 Feb 2005 22:24:00 -0000	1.9
@@ -149,7 +149,7 @@
                          GTokenType wanted_token, 
 			 CgeTranslateEnumFunc translate_enum,
 			 guint return_default,
-			 cge_fill_mode *retval)
+			 int *retval)
 {
     guint token;
    
@@ -264,10 +264,10 @@
     while (token != G_TOKEN_RIGHT_CURLY) {
 	switch (token) {
 	case TOKEN_MODE:
-	    token = theme_parse_custom_enum(scanner, TOKEN_MODE, TranslateFillStyleMode, CGE_FILL_SOLID,  &retval->fill_mode);
+	    token = theme_parse_custom_enum(scanner, TOKEN_MODE, TranslateFillStyleMode, CGE_FILL_SOLID,  (int*)&retval->fill_mode);
 	    break;
 	case TOKEN_GRADIENT_DIRECTION:
-	    token = theme_parse_custom_enum(scanner, TOKEN_GRADIENT_DIRECTION, TranslateGradientDirection, CGE_DIRECTION_VERTICAL,  &retval->gradient_direction);
+	    token = theme_parse_custom_enum(scanner, TOKEN_GRADIENT_DIRECTION, TranslateGradientDirection, CGE_DIRECTION_VERTICAL, (int*)&retval->gradient_direction);
 	case TOKEN_COLOR:
 	{
 	    GtkStateType state;
@@ -343,7 +343,7 @@
     while (token != G_TOKEN_RIGHT_CURLY) {
 	switch (token) {
 	case TOKEN_MODE:
-	    token = theme_parse_custom_enum(scanner, TOKEN_MODE, TranslateLineStyleMode, CGE_LINE_SOLID,  &retval->line_mode);
+	    token = theme_parse_custom_enum(scanner, TOKEN_MODE, TranslateLineStyleMode, CGE_LINE_SOLID,  (int*)&retval->line_mode);
 	    break;
 	case TOKEN_LINE_WIDTH:
 	    token = theme_parse_double (scanner, TOKEN_LINE_WIDTH, 1.0, &retval->line_width, 0.0, 10.0);
@@ -570,7 +570,7 @@
 	    token = theme_parse_line (settings, scanner, TOKEN_LINE, &cge_style->styles[0].line_style);      
 	    break;
 	case TOKEN_ARROW:
-	    token = theme_parse_custom_enum(scanner, TOKEN_ARROW, TranslateArrowStyle, CGE_ARROW_NORMAL,  &cge_style->arrow_style);
+	    token = theme_parse_custom_enum(scanner, TOKEN_ARROW, TranslateArrowStyle, CGE_ARROW_NORMAL,  (int*)&cge_style->arrow_style);
 	    break;
 	default:
 	    g_scanner_get_next_token (scanner);

Index: cge.h
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/cge.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cge.h	3 Feb 2005 20:03:59 -0000	1.3
+++ cge.h	3 Feb 2005 22:24:00 -0000	1.4
@@ -26,7 +26,9 @@
 
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
+
 #include <cairo.h>
+#include <cairo-xlib.h>
 
 #include "cge-style.h"
 




More information about the cairo-commit mailing list