[gtk-engines/rendering-cleanup: 1/10] support: Fix the support lib to work with new GTK3



commit c4b2919926fedc7f7eaf0ce7e7442c64783dad15
Author: Benjamin Otte <otte redhat com>
Date:   Sun Aug 29 22:41:17 2010 +0200

    support: Fix the support lib to work with new GTK3
    
    Breaks various themes that use these APIs, but the following commits
    will fix those.

 engines/support/cairo-support.c   |   46 +++++++++++++------------------------
 engines/support/cairo-support.h   |    2 +-
 engines/support/general-support.h |    7 ++++-
 3 files changed, 22 insertions(+), 33 deletions(-)
---
diff --git a/engines/support/cairo-support.c b/engines/support/cairo-support.c
index 4344a72..3b12545 100644
--- a/engines/support/cairo-support.c
+++ b/engines/support/cairo-support.c
@@ -760,19 +760,13 @@ ge_cairo_color_pattern(CairoColor *base)
 CairoPattern*
 ge_cairo_pixbuf_pattern(GdkPixbuf *pixbuf)
 {
-	CairoPattern * result = g_new0(CairoPattern, 1);
+	CairoPattern * result;
+        cairo_pattern_t *pattern;
 
 	cairo_t *canvas;
 	cairo_surface_t * surface;
 	gint width, height;
 
-	#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
-		result->type = CAIRO_PATTERN_TYPE_SURFACE;
-	#endif
-
-	result->scale = GE_DIRECTION_NONE;
-	result->translate = GE_DIRECTION_BOTH;
-
 	width = gdk_pixbuf_get_width(pixbuf);
 	height = gdk_pixbuf_get_height(pixbuf);
 	
@@ -785,38 +779,30 @@ ge_cairo_pixbuf_pattern(GdkPixbuf *pixbuf)
 	cairo_fill (canvas);
 	cairo_destroy(canvas);
 
-	result->handle = cairo_pattern_create_for_surface (surface);
+	pattern = cairo_pattern_create_for_surface (surface);
 	cairo_surface_destroy(surface);
 
-	cairo_pattern_set_extend (result->handle, CAIRO_EXTEND_REPEAT);
+	cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
 
-	result->operator = CAIRO_OPERATOR_SOURCE;
+        result = ge_cairo_pattern_pattern (pattern);
+        cairo_pattern_destroy (pattern);
 
 	return result;
 }
 
-/***********************************************
- * ge_cairo_pixmap_pattern -
- *  
- *   Create A Tiled Pixmap Pattern
- ***********************************************/
 CairoPattern*
-ge_cairo_pixmap_pattern(GdkPixmap *pixmap)
-{	
-	CairoPattern * result = NULL;
-
-	GdkPixbuf * pixbuf;
-	gint width, height;
-
-	gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &width, &height);
+ge_cairo_pattern_pattern(cairo_pattern_t *pattern)
+{
+	CairoPattern * result = g_new0(CairoPattern, 1);
 
-	pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE (pixmap), 
-	         gdk_drawable_get_colormap(GDK_DRAWABLE (pixmap)), 
-	         0, 0, 0, 0, width, height);
+	#if ((CAIRO_VERSION_MAJOR < 1) || ((CAIRO_VERSION_MAJOR == 1) && (CAIRO_VERSION_MINOR < 2)))
+		result->type = CAIRO_PATTERN_TYPE_SURFACE;
+	#endif
 
-	result = ge_cairo_pixbuf_pattern(pixbuf);
-	
-	g_object_unref (pixbuf);
+	result->scale = GE_DIRECTION_NONE;
+	result->translate = GE_DIRECTION_BOTH;
+        result->handle = cairo_pattern_reference (pattern);
+	result->operator = CAIRO_OPERATOR_SOURCE;
 
 	return result;
 }
diff --git a/engines/support/cairo-support.h b/engines/support/cairo-support.h
index 4e15c40..6189e11 100644
--- a/engines/support/cairo-support.h
+++ b/engines/support/cairo-support.h
@@ -144,7 +144,7 @@ GE_INTERNAL void ge_cairo_pattern_fill(cairo_t *canvas, CairoPattern *pattern, g
 
 GE_INTERNAL CairoPattern *ge_cairo_color_pattern(CairoColor *base);
 GE_INTERNAL CairoPattern *ge_cairo_pixbuf_pattern(GdkPixbuf *pixbuf);
-GE_INTERNAL CairoPattern *ge_cairo_pixmap_pattern(GdkPixmap *pixmap);
+GE_INTERNAL CairoPattern *ge_cairo_pattern_pattern(cairo_pattern_t *pattern);
 GE_INTERNAL CairoPattern *ge_cairo_linear_shade_gradient_pattern(CairoColor *base, gdouble shade1, gdouble shade2, gboolean vertical);
 GE_INTERNAL void ge_cairo_pattern_destroy(CairoPattern *pattern);
 
diff --git a/engines/support/general-support.h b/engines/support/general-support.h
index 212931c..42e898b 100644
--- a/engines/support/general-support.h
+++ b/engines/support/general-support.h
@@ -36,8 +36,11 @@
 #define CHECK_DETAIL(detail, value) ((detail) && (!strcmp(value, detail)))
 
 #define CHECK_ARGS					\
-  g_return_if_fail (window != NULL);			\
-  g_return_if_fail (style != NULL);
+  g_return_if_fail (cr != NULL);			\
+  g_return_if_fail (style != NULL);                     \
+  cairo_set_line_width (cr, 1.0);                       \
+  cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);       \
+  cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);      \
 
 #define SANITIZE_SIZE					\
   g_return_if_fail (width  >= -1);			\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]