From: buliabyak Date: Tue, 24 Jun 2008 02:30:47 +0000 (+0000) Subject: delivarotify, render with cairo X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2ae6d9d909752ae0c718453649c7e1de208e6c16;p=inkscape.git delivarotify, render with cairo --- diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index a3c7839c7..f14eddfc2 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -26,8 +26,8 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif -#include #include +#include "display/inkscape-cairo.h" static void sp_ctrlline_class_init (SPCtrlLineClass *klass); @@ -77,7 +77,6 @@ sp_ctrlline_init (SPCtrlLine *ctrlline) { ctrlline->rgba = 0x0000ff7f; ctrlline->s[NR::X] = ctrlline->s[NR::Y] = ctrlline->e[NR::X] = ctrlline->e[NR::Y] = 0.0; - ctrlline->shp=NULL; ctrlline->item=NULL; } @@ -89,11 +88,6 @@ sp_ctrlline_destroy (GtkObject *object) SPCtrlLine *ctrlline = SP_CTRLLINE (object); - if (ctrlline->shp) { - delete ctrlline->shp; - ctrlline->shp = NULL; - } - ctrlline->item=NULL; if (GTK_OBJECT_CLASS (parent_class)->destroy) @@ -103,45 +97,24 @@ sp_ctrlline_destroy (GtkObject *object) static void sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf) { - SPCtrlLine *ctrlline = SP_CTRLLINE (item); + SPCtrlLine *cl = SP_CTRLLINE (item); - NRRectL area; - area.x0=buf->rect.x0; - area.x1=buf->rect.x1; - area.y0=buf->rect.y0; - area.y1=buf->rect.y1; + if (!buf->ct) + return; -/* -// CAIRO FIXME: after SPCanvasBuf is switched to unpacked 32bit rgb, rendering can be done via cairo: - cairo_surface_t* cst = cairo_image_surface_create_for_data ( - buf->buf, - CAIRO_FORMAT_RGB24, - buf->rect.x1 - buf->rect.x0, - buf->rect.y1 - buf->rect.y0, - buf->buf_rowstride - ); - cairo_t *ct = cairo_create (cst); - - guint32 rgba = ctrlline->rgba; - cairo_set_source_rgba(ct, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba), SP_RGBA32_A_F(rgba)); - - cairo_set_line_width(ct, 0.5); - cairo_new_path(ct); - - cairo_move_to (ct, ctrlline->s.x - buf->rect.x0, ctrlline->s.y - buf->rect.y0); - cairo_line_to (ct, ctrlline->e.x - buf->rect.x0, ctrlline->e.y - buf->rect.y0); - - cairo_stroke(ct); - cairo_destroy (ct); - cairo_surface_finish (cst); - cairo_surface_destroy (cst); -*/ + guint32 rgba = cl->rgba; + cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba)); -// CAIRO FIXME: instead of this: - if (ctrlline->shp) { - sp_canvas_prepare_buffer (buf); - nr_pixblock_render_ctrl_rgba (ctrlline->shp,ctrlline->rgba,area,(char*)buf->buf, buf->buf_rowstride); - } + cairo_set_line_width(buf->ct, 1); + cairo_new_path(buf->ct); + + NR::Point s = cl->s * cl->affine; + NR::Point e = cl->e * cl->affine; + + cairo_move_to (buf->ct, s[NR::X] - buf->rect.x0, s[NR::Y] - buf->rect.y0); + cairo_line_to (buf->ct, e[NR::X] - buf->rect.x0, e[NR::Y] - buf->rect.y0); + + cairo_stroke(buf->ct); } static void @@ -156,59 +129,15 @@ sp_ctrlline_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int f sp_canvas_item_reset_bounds (item); -/* -// CAIRO FIXME: all that is needed for update with cairo: - NR::Point s = NR::Point(cl->s.x, cl->s.y) * affine; - NR::Point e = NR::Point(cl->e.x, cl->e.y) * affine; + cl->affine = affine; - cl->s.x = s[NR::X]; - cl->s.y = s[NR::Y]; - cl->e.x = e[NR::X]; - cl->e.y = e[NR::Y]; + NR::Point s = cl->s * affine; + NR::Point e = cl->e * affine; item->x1 = (int)(MIN(s[NR::X], e[NR::X]) - 1); item->y1 = (int)(MIN(s[NR::Y], e[NR::Y]) - 1); item->x2 = (int)(MAX(s[NR::X], e[NR::X]) + 1); item->y2 = (int)(MAX(s[NR::Y], e[NR::Y]) + 1); -*/ - -// CAIRO FIXME: instead of: - NRRect dbox; - dbox.x0=dbox.x1=dbox.y0=dbox.y1=0; - if (cl->shp) { - delete cl->shp; - cl->shp = NULL; - } - Path* thePath = new Path; - thePath->MoveTo(NR::Point(cl->s[NR::X], cl->s[NR::Y]) * affine); - thePath->LineTo(NR::Point(cl->e[NR::X], cl->e[NR::Y]) * affine); - - NRRectL area; - area.x0=(NR::ICoord)(double)item->x1; - area.x1=(NR::ICoord)(double)item->x2; - area.y0=(NR::ICoord)(double)item->y1; - area.y1=(NR::ICoord)(double)item->y2; - thePath->Convert(&area, 1.0); - if ( cl->shp == NULL ) cl->shp=new Shape; - thePath->Stroke(cl->shp,false,0.5,join_straight,butt_straight,20.0,false); - cl->shp->CalcBBox(); - if ( cl->shp->leftX < cl->shp->rightX ) { - if ( dbox.x0 >= dbox.x1 ) { - dbox.x0=cl->shp->leftX;dbox.x1=cl->shp->rightX; - dbox.y0=cl->shp->topY;dbox.y1=cl->shp->bottomY; - } else { - if ( cl->shp->leftX < dbox.x0 ) dbox.x0=cl->shp->leftX; - if ( cl->shp->rightX > dbox.x1 ) dbox.x1=cl->shp->rightX; - if ( cl->shp->topY < dbox.y0 ) dbox.y0=cl->shp->topY; - if ( cl->shp->bottomY > dbox.y1 ) dbox.y1=cl->shp->bottomY; - } - } - delete thePath; - - item->x1 = (int)dbox.x0; - item->y1 = (int)dbox.y0; - item->x2 = (int)dbox.x1; - item->y2 = (int)dbox.y1; sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); } diff --git a/src/display/sp-ctrlline.h b/src/display/sp-ctrlline.h index 3c83388d8..53d0d6ba0 100644 --- a/src/display/sp-ctrlline.h +++ b/src/display/sp-ctrlline.h @@ -15,8 +15,6 @@ */ #include "sp-canvas.h" -#include - struct SPItem; @@ -28,7 +26,7 @@ struct SPCtrlLine : public SPCanvasItem{ SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users guint32 rgba; NR::Point s, e; - Shape* shp; + NR::Matrix affine; }; struct SPCtrlLineClass : public SPCanvasItemClass{};