[gimp] app: port gimp_view_renderer_draw() to take a cairo_t* instead of GdkWindow*
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: port gimp_view_renderer_draw() to take a cairo_t* instead of GdkWindow*
- Date: Fri, 15 Oct 2010 10:54:43 +0000 (UTC)
commit 1cc27bcef7c61fb018b59bef924e0403cbf7b271
Author: Michael Natterer <mitch gimp org>
Date: Fri Oct 15 12:53:58 2010 +0200
app: port gimp_view_renderer_draw() to take a cairo_t* instead of GdkWindow*
and pass in the cr with clipping set up from the callers instead.
app/widgets/gimpcellrendererviewable.c | 11 +++++++++--
app/widgets/gimpview.c | 13 +++++++++----
app/widgets/gimpviewrenderer.c | 23 +++--------------------
app/widgets/gimpviewrenderer.h | 5 ++---
4 files changed, 23 insertions(+), 29 deletions(-)
---
diff --git a/app/widgets/gimpcellrendererviewable.c b/app/widgets/gimpcellrendererviewable.c
index ff78558..9a181aa 100644
--- a/app/widgets/gimpcellrendererviewable.c
+++ b/app/widgets/gimpcellrendererviewable.c
@@ -293,6 +293,8 @@ gimp_cell_renderer_viewable_render (GtkCellRenderer *cell,
if (cellviewable->renderer)
{
+ cairo_t *cr;
+
if (! (flags & GTK_CELL_RENDERER_SELECTED))
{
/* this is an ugly hack. The cell state should be passed to
@@ -305,8 +307,13 @@ gimp_cell_renderer_viewable_render (GtkCellRenderer *cell,
gimp_view_renderer_remove_idle (cellviewable->renderer);
}
- gimp_view_renderer_draw (cellviewable->renderer, window, widget,
- cell_area, expose_area);
+ cr = gdk_cairo_create (window);
+ gdk_cairo_rectangle (cr, expose_area);
+ cairo_clip (cr);
+
+ gimp_view_renderer_draw (cellviewable->renderer, widget, cr, cell_area);
+
+ cairo_destroy (cr);
}
}
diff --git a/app/widgets/gimpview.c b/app/widgets/gimpview.c
index 823cc9c..39d6846 100644
--- a/app/widgets/gimpview.c
+++ b/app/widgets/gimpview.c
@@ -389,14 +389,19 @@ gimp_view_expose_event (GtkWidget *widget,
{
if (gtk_widget_is_drawable (widget))
{
- GtkAllocation allocation;
+ GtkAllocation allocation;
+ cairo_t *cr;
gtk_widget_get_allocation (widget, &allocation);
+ cr = gdk_cairo_create (event->window);
+ gdk_cairo_region (cr, event->region);
+ cairo_clip (cr);
+
gimp_view_renderer_draw (GIMP_VIEW (widget)->renderer,
- gtk_widget_get_window (widget), widget,
- &allocation,
- &event->area);
+ widget, cr, &allocation);
+
+ cairo_destroy (cr);
}
return FALSE;
diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c
index 2171932..3dae375 100644
--- a/app/widgets/gimpviewrenderer.c
+++ b/app/widgets/gimpviewrenderer.c
@@ -572,19 +572,14 @@ gimp_view_renderer_remove_idle (GimpViewRenderer *renderer)
void
gimp_view_renderer_draw (GimpViewRenderer *renderer,
- GdkWindow *window,
GtkWidget *widget,
- const GdkRectangle *draw_area,
- const GdkRectangle *expose_area)
+ cairo_t *cr,
+ const GdkRectangle *draw_area)
{
- cairo_t *cr;
- GdkRectangle render_rect;
-
g_return_if_fail (GIMP_IS_VIEW_RENDERER (renderer));
- g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (cr != NULL);
g_return_if_fail (draw_area != NULL);
- g_return_if_fail (expose_area != NULL);
if (G_UNLIKELY (renderer->context == NULL))
g_warning ("%s: renderer->context is NULL", G_STRFUNC);
@@ -592,16 +587,6 @@ gimp_view_renderer_draw (GimpViewRenderer *renderer,
if (! gtk_widget_is_drawable (widget))
return;
- if (! gdk_rectangle_intersect ((GdkRectangle *) draw_area,
- (GdkRectangle *) expose_area,
- &render_rect))
- return;
-
- cr = gdk_cairo_create (window);
-
- gdk_cairo_rectangle (cr, &render_rect);
- cairo_clip (cr);
-
if (renderer->viewable)
{
cairo_save (cr);
@@ -642,8 +627,6 @@ gimp_view_renderer_draw (GimpViewRenderer *renderer,
cairo_rectangle (cr, x, y, width, height);
cairo_stroke (cr);
}
-
- cairo_destroy (cr);
}
diff --git a/app/widgets/gimpviewrenderer.h b/app/widgets/gimpviewrenderer.h
index 5d60d28..d56912d 100644
--- a/app/widgets/gimpviewrenderer.h
+++ b/app/widgets/gimpviewrenderer.h
@@ -132,10 +132,9 @@ void gimp_view_renderer_update_idle (GimpViewRenderer *renderer);
void gimp_view_renderer_remove_idle (GimpViewRenderer *renderer);
void gimp_view_renderer_draw (GimpViewRenderer *renderer,
- GdkWindow *window,
GtkWidget *widget,
- const GdkRectangle *draw_area,
- const GdkRectangle *expose_area);
+ cairo_t *cr,
+ const GdkRectangle *draw_area);
/* protected */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]