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.
This commit is contained in:
Michael Natterer 2010-10-15 12:53:58 +02:00
parent dc39857238
commit 1cc27bcef7
4 changed files with 23 additions and 29 deletions

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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 */