[gimp/soc-2010-cage-2] libgimpwidgets: port gimppreviewarea from deprecated gdk to cairo
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage-2] libgimpwidgets: port gimppreviewarea from deprecated gdk to cairo
- Date: Thu, 30 Dec 2010 18:15:17 +0000 (UTC)
commit 663677942212d1fb6d08b4841bad494c4b965ac8
Author: Mikael Magnusson <mikachu src gnome org>
Date: Fri Dec 17 22:24:56 2010 +0100
libgimpwidgets: port gimppreviewarea from deprecated gdk to cairo
Backported from the gtk3-port branch.
libgimpwidgets/gimppreviewarea.c | 40 +++++++++++++++++++-------------------
1 files changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/libgimpwidgets/gimppreviewarea.c b/libgimpwidgets/gimppreviewarea.c
index fa9a1d8..bc60563 100644
--- a/libgimpwidgets/gimppreviewarea.c
+++ b/libgimpwidgets/gimppreviewarea.c
@@ -231,8 +231,9 @@ gimp_preview_area_expose (GtkWidget *widget,
{
GimpPreviewArea *area = GIMP_PREVIEW_AREA (widget);
GtkAllocation allocation;
+ GdkPixbuf *pixbuf;
GdkRectangle rect;
- GdkRectangle render;
+ cairo_t *cr;
if (! area->buf)
return FALSE;
@@ -244,25 +245,24 @@ gimp_preview_area_expose (GtkWidget *widget,
rect.width = area->width;
rect.height = area->height;
- if (gdk_rectangle_intersect (&rect, &event->area, &render))
- {
- GtkStyle *style = gtk_widget_get_style (widget);
- gint x = render.x - rect.x;
- gint y = render.y - rect.y;
- guchar *buf = area->buf + x * 3 + y * area->rowstride;
-
- gdk_draw_rgb_image_dithalign (gtk_widget_get_window (widget),
- style->fg_gc[gtk_widget_get_state (widget)],
- render.x,
- render.y,
- render.width,
- render.height,
- GDK_RGB_DITHER_MAX,
- buf,
- area->rowstride,
- area->offset_x - render.x,
- area->offset_y - render.y);
- }
+ pixbuf = gdk_pixbuf_new_from_data (area->buf,
+ GDK_COLORSPACE_RGB,
+ FALSE,
+ 8,
+ rect.width,
+ rect.height,
+ area->rowstride,
+ NULL, NULL);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+
+ gdk_cairo_region (cr, event->region);
+ cairo_clip (cr);
+
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, rect.x, rect.y);
+ cairo_paint (cr);
+
+ cairo_destroy (cr);
+ g_object_unref (pixbuf);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]