diff options
author | David Robillard <d@drobilla.net> | 2011-12-10 18:34:17 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-12-10 18:34:17 +0000 |
commit | 103de1c0a236eaa7cc7a20986d32aa7739c4976c (patch) | |
tree | a727381eb9786da92daef8aa54f83c306657a91f /src | |
parent | a7a3bce6d878c1150946a99f85bc58fc4fcd6256 (diff) | |
download | ganv-103de1c0a236eaa7cc7a20986d32aa7739c4976c.tar.gz ganv-103de1c0a236eaa7cc7a20986d32aa7739c4976c.tar.bz2 ganv-103de1c0a236eaa7cc7a20986d32aa7739c4976c.zip |
Make item draw method take a cairo_t instead of GdkDrawable.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@3856 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/box.c | 7 | ||||
-rw-r--r-- | src/canvas-base.c | 12 | ||||
-rw-r--r-- | src/circle.c | 5 | ||||
-rw-r--r-- | src/edge.c | 29 | ||||
-rw-r--r-- | src/text.c | 5 | ||||
-rw-r--r-- | src/widget.c | 2 |
6 files changed, 26 insertions, 34 deletions
@@ -218,13 +218,12 @@ ganv_box_update(GanvItem* item, static void ganv_box_draw(GanvItem* item, - GdkDrawable* drawable, + cairo_t* cr, int cx, int cy, int width, int height) { GanvBox* box = GANV_BOX(item); GanvBoxImpl* impl = box->impl; - cairo_t* cr = gdk_cairo_create(drawable); double x1 = impl->coords.x1; double y1 = impl->coords.y1; @@ -286,9 +285,7 @@ ganv_box_draw(GanvItem* item, } GanvItemClass* item_class = GANV_ITEM_CLASS(parent_class); - item_class->draw(item, drawable, cx, cy, width, height); - - cairo_destroy(cr); + item_class->draw(item, cr, cx, cy, width, height); } static double diff --git a/src/canvas-base.c b/src/canvas-base.c index 2cff987..51bd7cb 100644 --- a/src/canvas-base.c +++ b/src/canvas-base.c @@ -1264,7 +1264,7 @@ static void ganv_group_realize(GanvItem* item); static void ganv_group_unrealize(GanvItem* item); static void ganv_group_map(GanvItem* item); static void ganv_group_unmap(GanvItem* item); -static void ganv_group_draw(GanvItem* item, GdkDrawable* drawable, +static void ganv_group_draw(GanvItem* item, cairo_t* cr, int x, int y, int width, int height); static double ganv_group_point(GanvItem* item, double x, double y, int cx, int cy, @@ -1555,7 +1555,7 @@ ganv_group_unmap(GanvItem* item) /* Draw handler for canvas groups */ static void -ganv_group_draw(GanvItem* item, GdkDrawable* drawable, +ganv_group_draw(GanvItem* item, cairo_t* cr, int x, int y, int width, int height) { GanvGroup* group; @@ -1579,7 +1579,7 @@ ganv_group_draw(GanvItem* item, GdkDrawable* drawable, && (child->y2 > child->canvas->redraw_y2))) { if (GANV_ITEM_GET_CLASS(child)->draw) { (*GANV_ITEM_GET_CLASS(child)->draw)( - child, drawable, x, y, width, height); + child, cr, x, y, width, height); } } } @@ -2816,13 +2816,17 @@ ganv_canvas_base_paint_rect(GanvCanvasBase* canvas, gint x0, gint y0, gint x1, g g_signal_emit(G_OBJECT(canvas), canvas_signals[DRAW_BACKGROUND], 0, pixmap, draw_x1, draw_y1, draw_width, draw_height); + cairo_t* cr = gdk_cairo_create(pixmap); + if (canvas->root->object.flags & GANV_ITEM_VISIBLE) { (*GANV_ITEM_GET_CLASS(canvas->root)->draw)( - canvas->root, pixmap, + canvas->root, cr, draw_x1, draw_y1, draw_width, draw_height); } + cairo_destroy(cr); + /* Copy the pixmap to the window and clean up */ gdk_draw_drawable(canvas->layout.bin_window, diff --git a/src/circle.c b/src/circle.c index 4f4675d..edc3ae3 100644 --- a/src/circle.c +++ b/src/circle.c @@ -248,13 +248,12 @@ ganv_circle_update(GanvItem* item, static void ganv_circle_draw(GanvItem* item, - GdkDrawable* drawable, + cairo_t* cr, int x, int y, int width, int height) { GanvCircle* circle = GANV_CIRCLE(item); GanvCircleImpl* impl = circle->impl; - cairo_t* cr = gdk_cairo_create(drawable); double r, g, b, a; @@ -285,8 +284,6 @@ ganv_circle_draw(GanvItem* item, cairo_set_dash(cr, &dash_length, 1, circle->node.impl->dash_offset); } cairo_stroke(cr); - - cairo_destroy(cr); } static double @@ -183,16 +183,16 @@ request_redraw(GanvCanvasBase* canvas, const double r1x2 = MAX(MAX(src_x, join_x), src_x1); const double r1y2 = MAX(MAX(src_y, join_y), src_y1); ganv_canvas_base_request_redraw(canvas, - r1x1 - w, r1y1 - w, - r1x2 + w, r1y2 + w); + r1x1 - w, r1y1 - w, + r1x2 + w, r1y2 + w); const double r2x1 = MIN(MIN(dst_x, join_x), dst_x1); const double r2y1 = MIN(MIN(dst_y, join_y), dst_y1); const double r2x2 = MAX(MAX(dst_x, join_x), dst_x1); const double r2y2 = MAX(MAX(dst_y, join_y), dst_y1); ganv_canvas_base_request_redraw(canvas, - r2x1 - w, r2y1 - w, - r2x2 + w, r2y2 + w); + r2x1 - w, r2y1 - w, + r2x2 + w, r2y2 + w); } else { const double x1 = MIN(coords->x1, coords->x2); @@ -201,15 +201,15 @@ request_redraw(GanvCanvasBase* canvas, const double y2 = MAX(coords->y1, coords->y2); ganv_canvas_base_request_redraw(canvas, - x1 - w, y1 - w, - x2 + w, y2 + w); + x1 - w, y1 - w, + x2 + w, y2 + w); } ganv_canvas_base_request_redraw(canvas, - coords->handle_x - coords->handle_radius, - coords->handle_y - coords->handle_radius, - coords->handle_x + coords->handle_radius, - coords->handle_y + coords->handle_radius); + coords->handle_x - coords->handle_radius, + coords->handle_y - coords->handle_radius, + coords->handle_x + coords->handle_radius, + coords->handle_y + coords->handle_radius); if (coords->arrowhead) { ganv_canvas_base_request_redraw( @@ -296,13 +296,12 @@ ganv_edge_update(GanvItem* item, static void ganv_edge_draw(GanvItem* item, - GdkDrawable* drawable, + cairo_t* cr, int x, int y, int width, int height) { GanvEdge* edge = GANV_EDGE(item); GanvEdgeImpl* impl = edge->impl; - cairo_t* cr = gdk_cairo_create(drawable); double src_x = impl->coords.x1 - x; double src_y = impl->coords.y1 - y; @@ -408,8 +407,6 @@ ganv_edge_draw(GanvItem* item, cairo_move_to(cr, join_x, join_y); cairo_arc(cr, join_x, join_y, impl->coords.handle_radius, 0, 2 * M_PI); cairo_fill(cr); - - cairo_destroy(cr); } static double @@ -590,8 +587,8 @@ ganv_edge_new(GanvCanvas* canvas, va_list args; va_start(args, first_prop_name); ganv_item_construct(&edge->item, - ganv_canvas_get_root(canvas), - first_prop_name, args); + ganv_canvas_get_root(canvas), + first_prop_name, args); va_end(args); edge->impl->tail = tail; @@ -288,13 +288,12 @@ ganv_text_point(GanvItem* item, static void ganv_text_draw(GanvItem* item, - GdkDrawable* drawable, + cairo_t* cr, int x, int y, int width, int height) { GanvText* text = GANV_TEXT(item); GanvTextImpl* impl = text->impl; - cairo_t* cr = gdk_cairo_create(drawable); double wx = impl->coords.x; double wy = impl->coords.y; @@ -306,8 +305,6 @@ ganv_text_draw(GanvItem* item, cairo_set_source_surface(cr, impl->surface, wx, wy); cairo_paint(cr); - - cairo_destroy(cr); } static void diff --git a/src/widget.c b/src/widget.c index d11a2e6..d958093 100644 --- a/src/widget.c +++ b/src/widget.c @@ -317,7 +317,7 @@ ganv_widget_update(GanvItem* item, double* affine, ArtSVP* clip_path, int flags) static void ganv_widget_draw(GanvItem* item, - GdkDrawable* drawable, + cairo_t* cr, int x, int y, int width, int height) { |