diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-08-27 13:20:17 +0000 |
|---|---|---|
| committer | Krzysztof Kosinski <tweenk.pl@gmail.com> | 2011-08-27 13:20:17 +0000 |
| commit | 79012ca437ff3d7c25e4d164b1b9c3dccc2b4b7f (patch) | |
| tree | 9cc58ddb8d243fd9f78e7a57024bb929a2362404 /src | |
| parent | Update 2Geom. Remove all use of NRRectL. (diff) | |
| download | inkscape-79012ca437ff3d7c25e4d164b1b9c3dccc2b4b7f.tar.gz inkscape-79012ca437ff3d7c25e4d164b1b9c3dccc2b4b7f.zip | |
Remove NRRect from paint servers and temporary calculations
(bzr r10582.1.4)
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop.cpp | 1 | ||||
| -rw-r--r-- | src/display/nr-style.cpp | 6 | ||||
| -rw-r--r-- | src/sp-gradient.cpp | 12 | ||||
| -rw-r--r-- | src/sp-paint-server.cpp | 6 | ||||
| -rw-r--r-- | src/sp-paint-server.h | 5 | ||||
| -rw-r--r-- | src/sp-pattern.cpp | 8 | ||||
| -rw-r--r-- | src/widgets/desktop-widget.cpp | 10 |
7 files changed, 22 insertions, 26 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp index b622d1080..f1a63d22c 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -871,6 +871,7 @@ Geom::Rect SPDesktop::get_display_area() const double const scale = _d2w[0]; + /// @fixme hardcoded desktop transform return Geom::Rect(Geom::Point(viewbox.min()[Geom::X] / scale, viewbox.max()[Geom::Y] / -scale), Geom::Point(viewbox.max()[Geom::X] / scale, viewbox.min()[Geom::Y] / -scale)); } diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index fa5dd0d98..9db52ea7e 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -150,8 +150,7 @@ bool NRStyle::prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &pai if (!fill_pattern) { switch (fill.type) { case PAINT_SERVER: { - NRRect pb(paintbox); - fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), &pb, fill.opacity); + fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), paintbox, fill.opacity); } break; case PAINT_COLOR: { SPColor const &c = fill.color; @@ -176,8 +175,7 @@ bool NRStyle::prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &p if (!stroke_pattern) { switch (stroke.type) { case PAINT_SERVER: { - NRRect pb(paintbox); - stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), &pb, stroke.opacity); + stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), paintbox, stroke.opacity); } break; case PAINT_COLOR: { SPColor const &c = stroke.color; diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 3aa14dc45..94ad0bb25 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1155,7 +1155,7 @@ static void sp_lineargradient_build(SPObject *object, static void sp_lineargradient_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_lineargradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +static cairo_pattern_t *sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); static SPGradientClass *lg_parent_class; @@ -1318,7 +1318,7 @@ static void sp_radialgradient_build(SPObject *object, static void sp_radialgradient_set(SPObject *object, unsigned key, gchar const *value); static Inkscape::XML::Node *sp_radialgradient_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +static cairo_pattern_t *sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); static SPGradientClass *rg_parent_class; @@ -1494,7 +1494,7 @@ sp_radialgradient_set_position(SPRadialGradient *rg, static void sp_gradient_pattern_common_setup(cairo_pattern_t *cp, SPGradient *gr, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { // set spread type @@ -1523,7 +1523,7 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, // set pattern matrix Geom::Affine gs2user = gr->gradientTransform; if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { - Geom::Affine bbox2user(bbox->x1 - bbox->x0, 0, 0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top()); gs2user *= bbox2user; } ink_cairo_pattern_set_matrix(cp, gs2user.inverse()); @@ -1532,7 +1532,7 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, static cairo_pattern_t * sp_radialgradient_create_pattern(SPPaintServer *ps, cairo_t */* ct */, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { SPRadialGradient *rg = SP_RADIALGRADIENT(ps); @@ -1552,7 +1552,7 @@ sp_radialgradient_create_pattern(SPPaintServer *ps, static cairo_pattern_t * sp_lineargradient_create_pattern(SPPaintServer *ps, cairo_t */* ct */, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { SPLinearGradient *lg = SP_LINEARGRADIENT(ps); diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index 2ed556b23..be7494908 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -22,7 +22,7 @@ static void sp_paint_server_class_init(SPPaintServerClass *psc); -static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +static cairo_pattern_t *sp_paint_server_create_dummy_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); static SPObjectClass *parent_class; @@ -70,7 +70,7 @@ void SPPaintServer::init(SPPaintServer * /*ps*/) cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { // NOTE: the ct argument is used for when rendering patterns @@ -91,7 +91,7 @@ cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, static cairo_pattern_t * sp_paint_server_create_dummy_pattern(SPPaintServer */*ps*/, cairo_t */* ct */, - NRRect const */*bbox*/, + Geom::OptRect const &/*bbox*/, double /* opacity */) { cairo_pattern_t *cp = cairo_pattern_create_rgb(1.0, 0.0, 1.0); diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index 283a97210..7d6f7a5ef 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -16,6 +16,7 @@ */ #include <cairo.h> +#include <2geom/rect.h> #include "sp-object.h" #include "uri-references.h" @@ -44,10 +45,10 @@ private: struct SPPaintServerClass { SPObjectClass sp_object_class; /** Get SPPaint instance. */ - cairo_pattern_t *(*pattern_new)(SPPaintServer *ps, cairo_t *ct, const NRRect *bbox, double opacity); + cairo_pattern_t *(*pattern_new)(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); }; -cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); #endif // SEEN_SP_PAINT_SERVER_H diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 9aefdf6ff..b8ccf5648 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -53,7 +53,7 @@ static void sp_pattern_modified (SPObject *object, unsigned int flags); static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat); static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern); -static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, NRRect const *bbox, double opacity); +static cairo_pattern_t *sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); static SPPaintServerClass * pattern_parent_class; @@ -604,7 +604,7 @@ bool pattern_hasItemChildren (SPPattern *pat) static cairo_pattern_t * sp_pattern_create_pattern(SPPaintServer *ps, cairo_t *base_ct, - NRRect const *bbox, + Geom::OptRect const &bbox, double opacity) { SPPattern *pat = SP_PATTERN (ps); @@ -657,7 +657,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, ps2user = pattern_patternTransform(pat); if (!pat->viewBox_set && pattern_patternContentUnits (pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { /* BBox to user coordinate system */ - Geom::Affine bbox2user (bbox->x1 - bbox->x0, 0.0, 0.0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + Geom::Affine bbox2user (bbox->width(), 0.0, 0.0, bbox->height(), bbox->left(), bbox->top()); ps2user *= bbox2user; } ps2user = Geom::Translate (pattern_x (pat), pattern_y (pat)) * ps2user; @@ -667,7 +667,7 @@ sp_pattern_create_pattern(SPPaintServer *ps, if (pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) { // interpret x, y, width, height in relation to bbox - Geom::Affine bbox2user(bbox->x1 - bbox->x0, 0,0, bbox->y1 - bbox->y0, bbox->x0, bbox->y0); + Geom::Affine bbox2user(bbox->width(), 0.0, 0.0, bbox->height(), bbox->left(), bbox->top()); pattern_tile = pattern_tile * bbox2user; } diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index fff9c0a5c..cbfb8fe5f 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -731,15 +731,11 @@ sp_desktop_widget_realize (GtkWidget *widget) if (GTK_WIDGET_CLASS (dtw_parent_class)->realize) (* GTK_WIDGET_CLASS (dtw_parent_class)->realize) (widget); - NRRect d; - d.x0 = 0.0; - d.y0 = 0.0; - d.x1 = (dtw->desktop->doc())->getWidth (); - d.y1 = (dtw->desktop->doc())->getHeight (); + Geom::Rect d = Geom::Rect::from_xywh(Geom::Point(0,0), (dtw->desktop->doc())->getDimensions()); - if ((fabs (d.x1 - d.x0) < 1.0) || (fabs (d.y1 - d.y0) < 1.0)) return; + if (d.width() < 1.0 || d.height() < 1.0) return; - dtw->desktop->set_display_area (d.x0, d.y0, d.x1, d.y1, 10); + dtw->desktop->set_display_area (d.left(), d.top(), d.right(), d.bottom(), 10); dtw->updateNamedview(); } |
