summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2005-05-11 19:16:19 +0000
committerOwen Taylor <otaylor@src.gnome.org>2005-05-11 19:16:19 +0000
commitdda40ca71a669d7ba39261cb94d78772f5803b42 (patch)
treeb85adf32e9bc73bd6c6879110e7aa73131eda622 /gdk
parent846972ba1486f694291c788cb113453a40b8104d (diff)
downloadgtk+-dda40ca71a669d7ba39261cb94d78772f5803b42.tar.gz
Use a GtkAlignment rather than a GtkDrawingArea to draw the swatch in to
2005-05-11 Owen Taylor <otaylor@redhat.com> * gtk/gtkcolorbutton.c: Use a GtkAlignment rather than a GtkDrawingArea to draw the swatch in to avoid having an extraneous window. * gtk/gtkcolorsel.c (color_sample_draw_sample): Actually se tthe color when !has_opacity. 2005-05-10 Owen Taylor <otaylor@redhat.com> * gdk/gdkcairo.[ch] gdk/gdkcolor.[ch] gdk/Makefile.am: Add source files for Cairo convenience functionality. * gdk/gdkcairo.h (gdk_cairo_rectangle, gdk_cairo_region): Add a convenience functions to add GdkRectangle, GdkRegion to a cairo path. * gdk/gdkwindow.c gdk/gdkgc.c gtk/gtkcolorsel.c gtk/gtkiconview.c gtk/gtkstyle.c: Use gdk_cairo_rectangle/region(). * gdk/gdkcairo.[ch] gdk/gdkdrawable.h gdk/gdkdraw.c: Rename gdk_drawable_create_cairo_context() to gdk_cairo_create(). * gdk/gdkcairo.c gdk/gdkpixbuf.h gdk/gdkpixbuf-render.c: Rename gdk_pixbuf_set_as_cairo_source() to gdk_cairo_set_source_pixbuf(). * gdk/gdkdraw.c gdk/gdkpango.c gtk/gtkcolorsel.c gtk/gtkhruler.c gtk/gtkhsv.c gtk/gtkiconview.c gtk/gtkstyle.c gtk/gtkvruler.c: Adjust for renames. * gdk/gdk.symbols: Update. * gtk/gtkwidget.c (gtk_widget_queue_shallow_draw): Fix coordinate system problem that was causing the wrong portions to be invalidated. * gtk/gtkcellrenderer.c (gtk_cell_renderer_render) gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_render) gtk/gtkcellrendererprogress.c (gtk_cell_renderer_progress_render) gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render) gtk/gtkcellview.c (gtk_cell_view_expose) gtk/gtkdnd.c (gtk_drag_highlight_expose) gtk/gtkentry.c (gtk_entry_draw_text) gtk/gtktextview.c (text_window_invalidate_rect): Some cairoization. * gtk/gtkcalendar.[ch]: Beat into something roughly resembling GTK+ style ... use instance-private data and standard names for private structure, etc. Move function docs inline. * gtk/gtkcalendar.[ch]: Switch to drawing everything in expose. Switch drawing to Cairo. * gtk/gtkcalendar.c (gtk_calendar_freeze): Deprecate gtk_calendar_freeze/thaw
Diffstat (limited to 'gdk')
-rw-r--r--gdk/Makefile.am4
-rw-r--r--gdk/gdk.h1
-rw-r--r--gdk/gdk.symbols13
-rw-r--r--gdk/gdkcairo.c221
-rw-r--r--gdk/gdkcairo.h45
-rw-r--r--gdk/gdkcolor.c20
-rw-r--r--gdk/gdkcolor.h3
-rw-r--r--gdk/gdkdraw.c30
-rw-r--r--gdk/gdkdrawable.h2
-rw-r--r--gdk/gdkgc.c16
-rw-r--r--gdk/gdkpango.c2
-rw-r--r--gdk/gdkpixbuf-render.c99
-rw-r--r--gdk/gdkpixbuf.h5
-rw-r--r--gdk/gdkwindow.c19
14 files changed, 288 insertions, 192 deletions
diff --git a/gdk/Makefile.am b/gdk/Makefile.am
index a66938a7a5..0fcb35c865 100644
--- a/gdk/Makefile.am
+++ b/gdk/Makefile.am
@@ -50,6 +50,7 @@ LDADD = \
#
gdk_public_h_sources = \
gdk.h \
+ gdkcairo.h \
gdkcolor.h \
gdkcursor.h \
gdkdisplay.h \
@@ -85,6 +86,7 @@ gdk_headers = \
gdk_c_sources = \
gdk.c \
+ gdkcairo.c \
gdkcolor.c \
gdkcursor.c \
gdkdisplay.c \
@@ -240,7 +242,7 @@ stamp-gdkenumtypes.h: @REBUILD@ $(gdk_public_h_sources) Makefile
gdkenumtypes.c: @REBUILD@ $(gdk_public_h_sources) Makefile
( cd $(srcdir) && glib-mkenums \
--fhead "#define GDK_ENABLE_BROKEN\n#include \"gdk.h\"\n#include \"gdkalias.h\"\n" \
- --fprod "\n/* enumerations from \"@filename@\" */" \
+ --fprod "\n/* enumerations from \"@filename@\" */" \
--ftail "\n#define __GDK_ENUM_TYPES_C__\n#include \"gdkaliasdef.c\"\n" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
diff --git a/gdk/gdk.h b/gdk/gdk.h
index bbc1967dfc..4cbe1068e5 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -27,6 +27,7 @@
#ifndef __GDK_H__
#define __GDK_H__
+#include <gdk/gdkcairo.h>
#include <gdk/gdkcolor.h>
#include <gdk/gdkcursor.h>
#include <gdk/gdkdisplay.h>
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 93448836dc..8e70365ba0 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -288,6 +288,16 @@ gdk_fontset_load_for_display
#endif
#endif
+#if IN_HEADER(__GDK_CAIRO_H__)
+#if IN_FILE(__GDK_CAIRO_C__)
+gdk_cairo_create
+gdk_cairo_set_source_color
+gdk_cairo_set_source_pixbuf
+gdk_cairo_rectangle
+gdk_cairo_region
+#endif
+#endif
+
#if IN_HEADER(__GDK_COLOR_H__)
#if IN_FILE(__GDK_COLOR_C__)
#ifndef GDK_DISABLE_DEPRECATED
@@ -301,7 +311,6 @@ gdk_color_equal
gdk_color_free
gdk_color_get_type G_GNUC_CONST
gdk_color_hash
-gdk_cairo_set_source_color
gdk_colormap_alloc_color
gdk_colormap_get_system
gdk_colormap_get_visual
@@ -510,7 +519,6 @@ gdk_drag_get_protocol
#if IN_HEADER(__GDK_DRAWABLE_H__)
#if IN_FILE(__GDK_DRAW_C__)
-gdk_drawable_create_cairo_context
gdk_drawable_copy_to_image
gdk_drawable_get_clip_region
gdk_drawable_get_colormap
@@ -853,7 +861,6 @@ gdk_pixbuf_get_from_image
gdk_pixbuf_render_pixmap_and_mask
gdk_pixbuf_render_pixmap_and_mask_for_colormap
gdk_pixbuf_render_threshold_alpha
-gdk_pixbuf_set_as_cairo_source
#ifndef GDK_DISABLE_DEPRECATED
gdk_pixbuf_render_to_drawable
gdk_pixbuf_render_to_drawable_alpha
diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c
new file mode 100644
index 0000000000..4e498546fa
--- /dev/null
+++ b/gdk/gdkcairo.c
@@ -0,0 +1,221 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 "gdkcairo.h"
+#include "gdkdrawable.h"
+#include "gdkinternals.h"
+#include "gdkregion-generic.h"
+#include "gdkalias.h"
+
+/**
+ * gdk_cairo_create:
+ * @drawable: a #GdkDrawable
+ *
+ * Creates a Cairo context for drawing to @drawable.
+ *
+ * Return value: A newly created Cairo context. Free with
+ * cairo_destroy() when you are done drawing.
+ *
+ * Since: 2.10
+ **/
+cairo_t *
+gdk_cairo_create (GdkDrawable *drawable)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
+
+ surface = _gdk_drawable_ref_cairo_surface (drawable);
+ cr = cairo_create (surface);
+ cairo_surface_destroy (surface);
+
+ return cr;
+}
+
+/**
+ * gdk_cairo_set_source_color:
+ * @cr: a #cairo_t
+ * @color: a #GdkColor
+ *
+ * Sets the specified #GdkColor as the source color of @cr.
+ *
+ * Since: 2.8
+ **/
+void
+gdk_cairo_set_source_color (cairo_t *cr,
+ GdkColor *color)
+{
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (color != NULL);
+
+ cairo_set_source_rgb (cr,
+ color->red / 65535.,
+ color->green / 65535.,
+ color->blue / 65535.);
+}
+
+/**
+ * gdk_cairo_rectangle:
+ * @cr: a #cairo_t
+ * @rectangle: a #GdkRectangle
+ *
+ * Adds the given rectangle to the current path of @cr.
+ **/
+void
+gdk_cairo_rectangle (cairo_t *cr,
+ GdkRectangle *rectangle)
+{
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (rectangle != NULL);
+
+ cairo_rectangle (cr,
+ rectangle->x, rectangle->y,
+ rectangle->width, rectangle->height);
+}
+
+/**
+ * gdk_cairo_region:
+ * @cr: a #cairo_t
+ * @region: a #GdkRegion
+ *
+ * Adds the given region to the current path of @cr.
+ **/
+void
+gdk_cairo_region (cairo_t *cr,
+ GdkRegion *region)
+{
+ GdkRegionBox *boxes;
+ gint n_boxes, i;
+
+ g_return_if_fail (cr != NULL);
+ g_return_if_fail (region != NULL);
+
+ boxes = region->rects;
+ n_boxes = region->numRects;
+
+ for (i = 0; i < n_boxes; i++)
+ cairo_rectangle (cr,
+ boxes[i].x1,
+ boxes[i].y1,
+ boxes[i].x2 - boxes[i].x1,
+ boxes[i].y2 - boxes[i].y1);
+}
+
+/**
+ * gdk_cairo_set_source_pixbuf:
+ * @cr: a #Cairo context
+ * @pixbuf: a #GdkPixbuf
+ * @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
+ * @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
+ *
+ * Sets the given pixbuf as the source pattern for the Cairo context.
+ * The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
+ * so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
+ **/
+void
+gdk_cairo_set_source_pixbuf (cairo_t *cr,
+ GdkPixbuf *pixbuf,
+ double pixbuf_x,
+ double pixbuf_y)
+{
+ gint width = gdk_pixbuf_get_width (pixbuf);
+ gint height = gdk_pixbuf_get_height (pixbuf);
+ guchar *gdk_pixels = gdk_pixbuf_get_pixels (pixbuf);
+ int gdk_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
+ guchar *cairo_pixels;
+ cairo_format_t format;
+ cairo_surface_t *surface;
+ static const cairo_user_data_key_t key;
+ int j;
+
+ if (n_channels == 3)
+ format = CAIRO_FORMAT_RGB24;
+ else
+ format = CAIRO_FORMAT_ARGB32;
+
+ cairo_pixels = g_malloc (4 * width * height);
+ surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels,
+ format,
+ width, height, 4 * width);
+ cairo_surface_set_user_data (surface, &key,
+ cairo_pixels, (cairo_destroy_func_t)g_free);
+
+ for (j = height; j; j--)
+ {
+ guchar *p = gdk_pixels;
+ guchar *q = cairo_pixels;
+
+ if (n_channels == 3)
+ {
+ guchar *end = p + 3 * width;
+
+ while (p < end)
+ {
+#if G_BYTE_ORDER == GDK_LSB_FIRST
+ q[0] = p[2];
+ q[1] = p[1];
+ q[2] = p[2];
+#else
+ q[0] = p[0];
+ q[1] = p[1];
+ q[2] = p[2];
+#endif
+ p += 3;
+ q += 4;
+ }
+ }
+ else
+ {
+ guchar *end = p + 4 * width;
+ guint t1,t2,t3;
+
+#define MULT(d,c,a,t) G_STMT_START { t = c * a; d = ((t >> 8) + t) >> 8; } G_STMT_END
+
+ while (p < end)
+ {
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ MULT(q[0], p[2], p[3], t1);
+ MULT(q[1], p[1], p[3], t2);
+ MULT(q[2], p[0], p[3], t3);
+ q[3] = p[3];
+#else
+ q[0] = p[3];
+ MULT(q[1], p[0], p[3], t1);
+ MULT(q[2], p[1], p[3], t2);
+ MULT(q[3], p[2], p[3], t3);
+#endif
+
+ p += 4;
+ q += 4;
+ }
+
+#undef MULT
+ }
+
+ gdk_pixels += gdk_rowstride;
+ cairo_pixels += 4 * width;
+ }
+
+ cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
+}
+
+#define __GDK_CAIRO_C__
+#include "gdkaliasdef.c"
diff --git a/gdk/gdkcairo.h b/gdk/gdkcairo.h
new file mode 100644
index 0000000000..3918f2381e
--- /dev/null
+++ b/gdk/gdkcairo.h
@@ -0,0 +1,45 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2005 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ */
+
+#ifndef __GDK_CAIRO_H__
+#define __GDK_CAIRO_H__
+
+#include <gdk/gdkcolor.h>
+#include <gdk/gdkpixbuf.h>
+#include <pango/pangocairo.h>
+
+G_BEGIN_DECLS
+
+cairo_t *gdk_cairo_create (GdkDrawable *drawable);
+
+void gdk_cairo_set_source_color (cairo_t *cr,
+ GdkColor *color);
+void gdk_cairo_set_source_pixbuf (cairo_t *cr,
+ GdkPixbuf *pixbuf,
+ double pixbuf_x,
+ double pixbuf_y);
+
+void gdk_cairo_rectangle (cairo_t *cr,
+ GdkRectangle *rectangle);
+void gdk_cairo_region (cairo_t *cr,
+ GdkRegion *region);
+
+G_END_DECLS
+
+#endif /* __GDK_CAIRO_H__ */
diff --git a/gdk/gdkcolor.c b/gdk/gdkcolor.c
index 27bdf19460..d2a4a55cab 100644
--- a/gdk/gdkcolor.c
+++ b/gdk/gdkcolor.c
@@ -371,25 +371,5 @@ gdk_colormap_get_system (void)
return gdk_screen_get_system_colormap (gdk_screen_get_default ());
}
-/**
- * gdk_cairo_set_source_color:
- * @cr: a #cairo_t
- * @color: a #GdkColor
- *
- * Convenience function to set the specified GdkColor as the
- * source color of the given Cairo context.
- *
- * Since: 2.8
- **/
-void
-gdk_cairo_set_source_color (cairo_t *cr,
- GdkColor *color)
-{
- cairo_set_source_rgb (cr,
- color->red / 65535.,
- color->green / 65535.,
- color->blue / 65535.);
-}
-
#define __GDK_COLOR_C__
#include "gdkaliasdef.c"
diff --git a/gdk/gdkcolor.h b/gdk/gdkcolor.h
index bbf7bd83f4..4d8a7e6df2 100644
--- a/gdk/gdkcolor.h
+++ b/gdk/gdkcolor.h
@@ -111,9 +111,6 @@ gboolean gdk_color_equal (const GdkColor *colora,
GType gdk_color_get_type (void) G_GNUC_CONST;
-void gdk_cairo_set_source_color (cairo_t *cr,
- GdkColor *color);
-
/* The following functions are deprecated */
#ifndef GDK_DISABLE_DEPRECATED
void gdk_colors_store (GdkColormap *colormap,
diff --git a/gdk/gdkdraw.c b/gdk/gdkdraw.c
index f956a5bedd..93e3e9f8f3 100644
--- a/gdk/gdkdraw.c
+++ b/gdk/gdkdraw.c
@@ -879,7 +879,7 @@ real_draw_glyphs (GdkDrawable *drawable,
{
cairo_t *cr;
- cr = gdk_drawable_create_cairo_context (drawable);
+ cr = gdk_cairo_create (drawable);
_gdk_gc_update_context (gc, cr, NULL, NULL);
if (matrix)
@@ -1003,7 +1003,7 @@ gdk_draw_trapezoids (GdkDrawable *drawable,
g_return_if_fail (GDK_IS_GC (gc));
g_return_if_fail (n_trapezoids == 0 || trapezoids != NULL);
- cr = gdk_drawable_create_cairo_context (drawable);
+ cr = gdk_cairo_create (drawable);
_gdk_gc_update_context (gc, cr, NULL, NULL);
for (i = 0; i < n_trapezoids; i++)
@@ -1285,32 +1285,6 @@ _gdk_drawable_ref_cairo_surface (GdkDrawable *drawable)
return GDK_DRAWABLE_GET_CLASS (drawable)->ref_cairo_surface (drawable);
}
-/**
- * gdk_drawable_create_cairo_context:
- * @drawable: a #GdkDrawable
- *
- * Creates a Cairo context for drawing to @drawable.
- *
- * Return value: A newly created Cairo context. Free with
- * cairo_destroy() when you are done drawing.
- *
- * Since: 2.10
- **/
-cairo_t *
-gdk_drawable_create_cairo_context (GdkDrawable *drawable)
-{
- cairo_surface_t *surface;
- cairo_t *cr;
-
- g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
-
- surface = _gdk_drawable_ref_cairo_surface (drawable);
- cr = cairo_create (surface);
- cairo_surface_destroy (surface);
-
- return cr;
-}
-
static void
composite (guchar *src_buf,
gint src_rowstride,
diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h
index 19344954f1..1e9194e4d1 100644
--- a/gdk/gdkdrawable.h
+++ b/gdk/gdkdrawable.h
@@ -391,8 +391,6 @@ GdkImage *gdk_drawable_copy_to_image (GdkDrawable *drawable,
GdkRegion *gdk_drawable_get_clip_region (GdkDrawable *drawable);
GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable);
-cairo_t *gdk_drawable_create_cairo_context (GdkDrawable *drawable);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gdk/gdkgc.c b/gdk/gdkgc.c
index 72115eec27..b29fecb608 100644
--- a/gdk/gdkgc.c
+++ b/gdk/gdkgc.c
@@ -27,10 +27,10 @@
#include <config.h>
#include <string.h>
+#include "gdkcairo.h"
#include "gdkgc.h"
#include "gdkinternals.h"
#include "gdkpixmap.h"
-#include "gdkregion-generic.h"
#include "gdkrgb.h"
#include "gdkprivate.h"
#include "gdkalias.h"
@@ -1225,21 +1225,13 @@ _gdk_gc_update_context (GdkGC *gc,
cairo_reset_clip (cr);
if (priv->clip_region)
{
- GdkRegionBox *boxes = priv->clip_region->rects;
- gint n_boxes = priv->clip_region->numRects;
- int i;
-
cairo_save (cr);
cairo_identity_matrix (cr);
-
+ cairo_translate (cr, gc->clip_x_origin, gc->clip_y_origin);
+
cairo_new_path (cr);
- for (i=0; i < n_boxes; i++)
- cairo_rectangle (cr,
- boxes[i].x1 + gc->clip_x_origin,
- boxes[i].y1 + gc->clip_y_origin,
- boxes[i].x2 - boxes[i].x1,
- boxes[i].y2 - boxes[i].y1);
+ gdk_cairo_region (cr, priv->clip_region);
cairo_restore (cr);
diff --git a/gdk/gdkpango.c b/gdk/gdkpango.c
index 4a266762b5..a160511dc7 100644
--- a/gdk/gdkpango.c
+++ b/gdk/gdkpango.c
@@ -141,7 +141,7 @@ get_cairo_context (GdkPangoRenderer *gdk_renderer,
{
const PangoMatrix *matrix;
- priv->cr = gdk_drawable_create_cairo_context (priv->drawable);
+ priv->cr = gdk_cairo_create (priv->drawable);
matrix = pango_renderer_get_matrix (renderer);
if (matrix)
diff --git a/gdk/gdkpixbuf-render.c b/gdk/gdkpixbuf-render.c
index d8eda5eb69..31dcb62cc8 100644
--- a/gdk/gdkpixbuf-render.c
+++ b/gdk/gdkpixbuf-render.c
@@ -329,105 +329,6 @@ gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf,
}
}
-/**
- * gdk_pixbuf_set_as_cairo_source:
- * @pixbuf: a #GdkPixbuf
- * @cr: a #Cairo context
- * @pixbuf_x: X coordinate of location to place upper left corner of @pixbuf
- * @pixbuf_y: Y coordinate of location to place upper left corner of @pixbuf
- *
- * Sets the given pixbuf as the source pattern for the Cairo context.
- * The pattern has an extend mode of %CAIRO_EXTEND_NONE and is aligned
- * so that the origin of @pixbuf is @pixbuf_x, @pixbuf_y
- **/
-void
-gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
- cairo_t *cr,
- double pixbuf_x,
- double pixbuf_y)
-{
- gint width = gdk_pixbuf_get_width (pixbuf);
- gint height = gdk_pixbuf_get_height (pixbuf);
- guchar *gdk_pixels = gdk_pixbuf_get_pixels (pixbuf);
- int gdk_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
- int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
- guchar *cairo_pixels;
- cairo_format_t format;
- cairo_surface_t *surface;
- static const cairo_user_data_key_t key;
- int j;
-
- if (n_channels == 3)
- format = CAIRO_FORMAT_RGB24;
- else
- format = CAIRO_FORMAT_ARGB32;
-
- cairo_pixels = g_malloc (4 * width * height);
- surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels,
- format,
- width, height, 4 * width);
- cairo_surface_set_user_data (surface, &key,
- cairo_pixels, (cairo_destroy_func_t)g_free);
-
- for (j = height; j; j--)
- {
- guchar *p = gdk_pixels;
- guchar *q = cairo_pixels;
-
- if (n_channels == 3)
- {
- guchar *end = p + 3 * width;
-
- while (p < end)
- {
-#if G_BYTE_ORDER == GDK_LSB_FIRST
- q[0] = p[2];
- q[1] = p[1];
- q[2] = p[2];
-#else
- q[0] = p[0];
- q[1] = p[1];
- q[2] = p[2];
-#endif
- p += 3;
- q += 4;
- }
- }
- else
- {
- guchar *end = p + 4 * width;
- guint t1,t2,t3;
-
-#define MULT(d,c,a,t) G_STMT_START { t = c * a; d = ((t >> 8) + t) >> 8; } G_STMT_END
-
- while (p < end)
- {
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- MULT(q[0], p[2], p[3], t1);
- MULT(q[1], p[1], p[3], t2);
- MULT(q[2], p[0], p[3], t3);
- q[3] = p[3];
-#else
- q[0] = p[3];
- MULT(q[1], p[0], p[3], t1);
- MULT(q[2], p[1], p[3], t2);
- MULT(q[3], p[2], p[3], t3);
-#endif
-
- p += 4;
- q += 4;
- }
-
-#undef MULT
- }
-
- gdk_pixels += gdk_rowstride;
- cairo_pixels += 4 * width;
- }
-
- cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y);
-}
-
#define __GDK_PIXBUF_RENDER_C__
#include "gdkaliasdef.c"
diff --git a/gdk/gdkpixbuf.h b/gdk/gdkpixbuf.h
index aa5b4acba2..ed297135c7 100644
--- a/gdk/gdkpixbuf.h
+++ b/gdk/gdkpixbuf.h
@@ -80,11 +80,6 @@ GdkPixbuf *gdk_pixbuf_get_from_image (GdkPixbuf *dest,
int width,
int height);
-void gdk_pixbuf_set_as_cairo_source (GdkPixbuf *pixbuf,
- cairo_t *cr,
- double pixbuf_x,
- double pixbuf_y);
-
G_END_DECLS
#endif /* __GDK_PIXBUF_H__ */
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 87280a5052..85326aef65 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -1764,23 +1764,6 @@ gdk_window_set_bg_pattern (GdkWindow *window,
}
static void
-region_path (cairo_t *cr,
- GdkRegion *region)
-{
- GdkRectangle *rectangles;
- int n_rectangles, i;
-
- gdk_region_get_rectangles (region, &rectangles, &n_rectangles);
- for (i = 0; i < n_rectangles; i++)
- {
- cairo_rectangle (cr,
- rectangles[i].x, rectangles[i].y,
- rectangles[i].width, rectangles[i].height);
- }
- g_free (rectangles);
-}
-
-static void
gdk_window_clear_backing_rect (GdkWindow *window,
gint x,
gint y,
@@ -1801,7 +1784,7 @@ gdk_window_clear_backing_rect (GdkWindow *window,
cairo_rectangle (cr, x, y, width, height);
cairo_clip (cr);
- region_path (cr, paint->region);
+ gdk_cairo_region (cr, paint->region);
cairo_fill (cr);
cairo_destroy (cr);