diff options
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/sp-gradient.cpp | 59 | ||||
| -rw-r--r-- | src/object/sp-gradient.h | 28 | ||||
| -rw-r--r-- | src/object/sp-image.cpp | 20 | ||||
| -rw-r--r-- | src/object/sp-image.h | 5 | ||||
| -rw-r--r-- | src/object/sp-item.cpp | 4 | ||||
| -rw-r--r-- | src/object/sp-root.cpp | 4 | ||||
| -rw-r--r-- | src/object/sp-shape.cpp | 8 | ||||
| -rw-r--r-- | src/object/sp-symbol.cpp | 4 | ||||
| -rw-r--r-- | src/object/sp-use.cpp | 4 |
9 files changed, 67 insertions, 69 deletions
diff --git a/src/object/sp-gradient.cpp b/src/object/sp-gradient.cpp index 0e3fa8e77..e36af38de 100644 --- a/src/object/sp-gradient.cpp +++ b/src/object/sp-gradient.cpp @@ -863,9 +863,9 @@ SPGradientUnits SPGradient::fetchUnits() * Clears the gradient's svg:stop children from its repr. */ void -sp_gradient_repr_clear_vector(SPGradient *gr) +SPGradient::repr_clear_vector() { - Inkscape::XML::Node *repr = gr->getRepr(); + Inkscape::XML::Node *repr = getRepr(); /* Collect stops from original repr */ std::vector<Inkscape::XML::Node *> l; @@ -889,30 +889,27 @@ sp_gradient_repr_clear_vector(SPGradient *gr) * inherited from refs) into the gradient repr as svg:stop elements. */ void -sp_gradient_repr_write_vector(SPGradient *gr) +SPGradient::repr_write_vector() { - g_return_if_fail(gr != nullptr); - g_return_if_fail(SP_IS_GRADIENT(gr)); - - Inkscape::XML::Document *xml_doc = gr->document->getReprDoc(); - Inkscape::XML::Node *repr = gr->getRepr(); + Inkscape::XML::Document *xml_doc = document->getReprDoc(); + Inkscape::XML::Node *repr = getRepr(); /* We have to be careful, as vector may be our own, so construct repr list at first */ std::vector<Inkscape::XML::Node *> l; - for (guint i = 0; i < gr->vector.stops.size(); i++) { + for (guint i = 0; i < vector.stops.size(); i++) { Inkscape::CSSOStringStream os; Inkscape::XML::Node *child = xml_doc->createElement("svg:stop"); - sp_repr_set_css_double(child, "offset", gr->vector.stops[i].offset); + sp_repr_set_css_double(child, "offset", vector.stops[i].offset); /* strictly speaking, offset an SVG <number> rather than a CSS one, but exponents make no * sense for offset proportions. */ - os << "stop-color:" << gr->vector.stops[i].color.toString() << ";stop-opacity:" << gr->vector.stops[i].opacity; + os << "stop-color:" << vector.stops[i].color.toString() << ";stop-opacity:" << vector.stops[i].opacity; child->setAttribute("style", os.str().c_str()); /* Order will be reversed here */ l.push_back(child); } - sp_gradient_repr_clear_vector(gr); + repr_clear_vector(); /* And insert new children from list */ for (auto i=l.rbegin();i!=l.rend();++i) { @@ -1072,9 +1069,9 @@ void SPGradient::rebuildArray() } Geom::Affine -sp_gradient_get_g2d_matrix(SPGradient const *gr, Geom::Affine const &ctm, Geom::Rect const &bbox) +SPGradient::get_g2d_matrix(Geom::Affine const &ctm, Geom::Rect const &bbox) const { - if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { + if (getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { return ( Geom::Scale(bbox.dimensions()) * Geom::Translate(bbox.min()) * Geom::Affine(ctm) ); @@ -1084,31 +1081,31 @@ sp_gradient_get_g2d_matrix(SPGradient const *gr, Geom::Affine const &ctm, Geom:: } Geom::Affine -sp_gradient_get_gs2d_matrix(SPGradient const *gr, Geom::Affine const &ctm, Geom::Rect const &bbox) +SPGradient::get_gs2d_matrix(Geom::Affine const &ctm, Geom::Rect const &bbox) const { - if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { - return ( gr->gradientTransform + if (getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) { + return ( gradientTransform * Geom::Scale(bbox.dimensions()) * Geom::Translate(bbox.min()) * Geom::Affine(ctm) ); } else { - return gr->gradientTransform * ctm; + return gradientTransform * ctm; } } void -sp_gradient_set_gs2d_matrix(SPGradient *gr, Geom::Affine const &ctm, +SPGradient::set_gs2d_matrix(Geom::Affine const &ctm, Geom::Rect const &bbox, Geom::Affine const &gs2d) { - gr->gradientTransform = gs2d * ctm.inverse(); - if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX ) { - gr->gradientTransform = ( gr->gradientTransform + gradientTransform = gs2d * ctm.inverse(); + if (getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX ) { + gradientTransform = ( gradientTransform * Geom::Translate(-bbox.min()) * Geom::Scale(bbox.dimensions()).inverse() ); } - gr->gradientTransform_set = TRUE; + gradientTransform_set = TRUE; - gr->requestModified(SP_OBJECT_MODIFIED_FLAG); + requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -1157,17 +1154,17 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, } cairo_pattern_t * -sp_gradient_create_preview_pattern(SPGradient *gr, double width) +SPGradient::create_preview_pattern(double width) { cairo_pattern_t *pat = nullptr; - if (!SP_IS_MESHGRADIENT(gr)) { - gr->ensureVector(); + if (!SP_IS_MESHGRADIENT(this)) { + ensureVector(); pat = cairo_pattern_create_linear(0, 0, width, 0); - for (std::vector<SPGradientStop>::iterator i = gr->vector.stops.begin(); - i != gr->vector.stops.end(); ++i) + for (std::vector<SPGradientStop>::iterator i = vector.stops.begin(); + i != vector.stops.end(); ++i) { cairo_pattern_add_color_stop_rgba(pat, i->offset, i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity); @@ -1175,14 +1172,14 @@ sp_gradient_create_preview_pattern(SPGradient *gr, double width) } else { // For the moment, use the top row of nodes for preview. - unsigned columns = gr->array.patch_columns(); + unsigned columns = array.patch_columns(); double offset = 1.0/double(columns); pat = cairo_pattern_create_linear(0, 0, width, 0); for (unsigned i = 0; i < columns+1; ++i) { - SPMeshNode* node = gr->array.node( 0, i*3 ); + SPMeshNode* node = array.node( 0, i*3 ); cairo_pattern_add_color_stop_rgba(pat, i*offset, node->color.v.c[0], node->color.v.c[1], node->color.v.c[2], node->opacity); } diff --git a/src/object/sp-gradient.h b/src/object/sp-gradient.h index 5d644925a..e03937c5b 100644 --- a/src/object/sp-gradient.h +++ b/src/object/sp-gradient.h @@ -185,6 +185,20 @@ public: static void gradientRefModified(SPObject *href, unsigned int flags, SPGradient *gradient); static void gradientRefChanged(SPObject *old_ref, SPObject *ref, SPGradient *gr); + /* Gradient repr methods */ + void repr_write_vector(); + void repr_clear_vector(); + + cairo_pattern_t *create_preview_pattern(double width); + + /** Transforms to/from gradient position space in given environment */ + Geom::Affine get_g2d_matrix(Geom::Affine const &ctm, + Geom::Rect const &bbox) const; + Geom::Affine get_gs2d_matrix(Geom::Affine const &ctm, + Geom::Rect const &bbox) const; + void set_gs2d_matrix(Geom::Affine const &ctm, Geom::Rect const &bbox, + Geom::Affine const &gs2d); + private: bool invalidateVector(); bool invalidateArray(); @@ -209,20 +223,6 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, Geom::OptRect const &bbox, double opacity); -/* Gradient repr methods */ -void sp_gradient_repr_write_vector(SPGradient *gr); -void sp_gradient_repr_clear_vector(SPGradient *gr); - -cairo_pattern_t *sp_gradient_create_preview_pattern(SPGradient *gradient, double width); - -/** Transforms to/from gradient position space in given environment */ -Geom::Affine sp_gradient_get_g2d_matrix(SPGradient const *gr, Geom::Affine const &ctm, - Geom::Rect const &bbox); -Geom::Affine sp_gradient_get_gs2d_matrix(SPGradient const *gr, Geom::Affine const &ctm, - Geom::Rect const &bbox); -void sp_gradient_set_gs2d_matrix(SPGradient *gr, Geom::Affine const &ctm, Geom::Rect const &bbox, - Geom::Affine const &gs2d); - #endif // SEEN_SP_GRADIENT_H diff --git a/src/object/sp-image.cpp b/src/object/sp-image.cpp index cdbe0ef4a..a5bc115ce 100644 --- a/src/object/sp-image.cpp +++ b/src/object/sp-image.cpp @@ -479,7 +479,7 @@ void SPImage::print(SPPrintContext *ctx) { Geom::Translate tp(vx, vy); Geom::Scale s(this->sx, this->sy); t = s * tp; - sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style); + ctx->image_R8G8B8A8_N(px, w, h, rs, t, this->style); delete pb; } } @@ -735,11 +735,11 @@ static void sp_image_set_curve( SPImage *image ) /** * Return duplicate of curve (if any exists) or NULL if there is no curve */ -SPCurve *sp_image_get_curve( SPImage *image ) +SPCurve *SPImage::get_curve() const { SPCurve *result = nullptr; - if (image->curve) { - result = image->curve->copy(); + if (curve) { + result = curve->copy(); } return result; } @@ -841,21 +841,21 @@ void sp_embed_svg(Inkscape::XML::Node *image_node, std::string const &fn) } } -void sp_image_refresh_if_outdated( SPImage* image ) +void SPImage::refresh_if_outdated() { - if ( image->href && image->pixbuf && image->pixbuf->modificationTime()) { + if ( href && pixbuf && pixbuf->modificationTime()) { // It *might* change GStatBuf st; memset(&st, 0, sizeof(st)); int val = 0; - if (g_file_test (image->pixbuf->originalPath().c_str(), G_FILE_TEST_EXISTS)){ - val = g_stat(image->pixbuf->originalPath().c_str(), &st); + if (g_file_test (pixbuf->originalPath().c_str(), G_FILE_TEST_EXISTS)){ + val = g_stat(pixbuf->originalPath().c_str(), &st); } if ( !val ) { // stat call worked. Check time now - if ( st.st_mtime != image->pixbuf->modificationTime() ) { - image->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_IMAGE_HREF_MODIFIED_FLAG); + if ( st.st_mtime != pixbuf->modificationTime() ) { + requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_IMAGE_HREF_MODIFIED_FLAG); } } } diff --git a/src/object/sp-image.h b/src/object/sp-image.h index 04e1df7fa..464d0f144 100644 --- a/src/object/sp-image.h +++ b/src/object/sp-image.h @@ -63,12 +63,13 @@ public: #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) void apply_profile(Inkscape::Pixbuf *pixbuf); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + + SPCurve *get_curve () const; + void refresh_if_outdated(); }; /* Return duplicate of curve or NULL */ -SPCurve *sp_image_get_curve (SPImage *image); void sp_embed_image(Inkscape::XML::Node *imgnode, Inkscape::Pixbuf *pb); void sp_embed_svg(Inkscape::XML::Node *image_node, std::string const &fn); -void sp_image_refresh_if_outdated( SPImage* image ); #endif diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index 286886a1a..ec92c655f 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -1023,9 +1023,9 @@ void SPItem::invoke_print(SPPrintContext *ctx) { if ( !isHidden() ) { if (!transform.isIdentity() || style->opacity.value != SP_SCALE24_MAX) { - sp_print_bind(ctx, transform, SP_SCALE24_TO_FLOAT(style->opacity.value)); + ctx->bind(transform, SP_SCALE24_TO_FLOAT(style->opacity.value)); this->print(ctx); - sp_print_release(ctx); + ctx->release(); } else { this->print(ctx); } diff --git a/src/object/sp-root.cpp b/src/object/sp-root.cpp index 592aae443..6ebccef3c 100644 --- a/src/object/sp-root.cpp +++ b/src/object/sp-root.cpp @@ -369,11 +369,11 @@ Inkscape::DrawingItem *SPRoot::show(Inkscape::Drawing &drawing, unsigned int key void SPRoot::print(SPPrintContext *ctx) { - sp_print_bind(ctx, this->c2p, 1.0); + ctx->bind(this->c2p, 1.0); SPGroup::print(ctx); - sp_print_release(ctx); + ctx->release(); } const char *SPRoot::displayName() const { diff --git a/src/object/sp-shape.cpp b/src/object/sp-shape.cpp index 1f4572428..d3fce702e 100644 --- a/src/object/sp-shape.cpp +++ b/src/object/sp-shape.cpp @@ -641,7 +641,7 @@ void SPShape::print(SPPrintContext* ctx) { if (add_comments) { gchar * comment = g_strdup_printf("begin '%s'", this->defaultLabel()); - sp_print_comment(ctx, comment); + ctx->comment(comment); g_free(comment); } @@ -656,11 +656,11 @@ void SPShape::print(SPPrintContext* ctx) { SPStyle* style = this->style; if (!style->fill.isNone()) { - sp_print_fill (ctx, pathv, i2dt, style, pbox, dbox, bbox); + ctx->fill (pathv, i2dt, style, pbox, dbox, bbox); } if (!style->stroke.isNone()) { - sp_print_stroke (ctx, pathv, i2dt, style, pbox, dbox, bbox); + ctx->stroke (pathv, i2dt, style, pbox, dbox, bbox); } /** \todo make code prettier */ @@ -737,7 +737,7 @@ void SPShape::print(SPPrintContext* ctx) { if (add_comments) { gchar * comment = g_strdup_printf("end '%s'", this->defaultLabel()); - sp_print_comment(ctx, comment); + ctx->comment(comment); g_free(comment); } } diff --git a/src/object/sp-symbol.cpp b/src/object/sp-symbol.cpp index d3a06a60b..feb3ed097 100644 --- a/src/object/sp-symbol.cpp +++ b/src/object/sp-symbol.cpp @@ -148,11 +148,11 @@ void SPSymbol::print(SPPrintContext* ctx) { if (this->cloned) { // Cloned <symbol> is actually renderable - sp_print_bind(ctx, this->c2p, 1.0); + ctx->bind(this->c2p, 1.0); SPGroup::print(ctx); - sp_print_release (ctx); + ctx->release (); } } diff --git a/src/object/sp-use.cpp b/src/object/sp-use.cpp index 6ee4be4b2..a73a731f8 100644 --- a/src/object/sp-use.cpp +++ b/src/object/sp-use.cpp @@ -216,7 +216,7 @@ void SPUse::print(SPPrintContext* ctx) { if ((this->x._set && this->x.computed != 0) || (this->y._set && this->y.computed != 0)) { Geom::Affine tp(Geom::Translate(this->x.computed, this->y.computed)); - sp_print_bind(ctx, tp, 1.0); + ctx->bind(tp, 1.0); translated = true; } @@ -225,7 +225,7 @@ void SPUse::print(SPPrintContext* ctx) { } if (translated) { - sp_print_release(ctx); + ctx->release(); } } |
