diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 17c61d3c09581bd311b4bc2a3aa325d9d4729306..97c77d1464d7bcd398e7be3e5178df9b3bd8ce48 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -112,7 +112,7 @@ SPGradient *sp_gradient_ensure_vector_normalized(SPGradient *gr) gr->ensureVector(); g_assert(gr->vector.built); // this adds stops from gr->vector as children to gr - sp_gradient_repr_write_vector (gr); + gr->repr_write_vector (); } /* If gr hrefs some other gradient, remove the href */ diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index dc69934b17ba1745b2673000cbb5a08f0f03dc56..7f9ee69a9d47c85bde3c0e2bef384804370f4bfb 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -270,9 +270,9 @@ Geom::Affine glyph_matrix; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); Geom::PathVector temp_pv = (*pv) * glyph_matrix; if (!text_source->style->fill.isNone()) - sp_print_fill(ctx, temp_pv, ctm, text_source->style, pbox, dbox, bbox); + ctx->fill(temp_pv, ctm, text_source->style, pbox, dbox, bbox); if (!text_source->style->stroke.isNone()) - sp_print_stroke(ctx, temp_pv, ctm, text_source->style, pbox, dbox, bbox); + ctx->stroke(temp_pv, ctm, text_source->style, pbox, dbox, bbox); } } } @@ -401,16 +401,16 @@ std:: cout << "DEBUG Layout::print in while --- " } // write it - sp_print_bind(ctx, glyph_matrix, 1.0); + ctx->bind(glyph_matrix, 1.0); // the dx array is smuggled through to the EMF driver (ignored by others) as: // textw1 w2 w3 ...wn // where the widths are floats 7 characters wide, including the space char *smuggle_string=smuggle_adxkyrtl_in(text_string.c_str(),ndx, &hold_dx[0], ky, rtl); - sp_print_text(ctx, smuggle_string, g_pos, text_source->style); + ctx->text(smuggle_string, g_pos, text_source->style); free(smuggle_string); - sp_print_release(ctx); + ctx->release(); ndx = 0; char_index = lc_index; } diff --git a/src/object/sp-gradient.cpp b/src/object/sp-gradient.cpp index 0e3fa8e7717b30ceb260d3a87ae93bc0e69e8b1a..e36af38deb89cef2140b4e8445651d39fa3f367e 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 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 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 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::iterator i = gr->vector.stops.begin(); - i != gr->vector.stops.end(); ++i) + for (std::vector::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 5d644925ae1b28e47f80a34b336ca36d6aeafc56..e03937c5b319acb8ae7e63f12d3538d8b9730c5c 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 cdbe0ef4a5bdb9d8b74396aca38e7410076024f0..a5bc115ce694b5cb81a6c06fa50f7e468abd964e 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 04e1df7fae0414bab03ab7c5ba11897fcd05a99e..464d0f144bdbaddbef3a194654d31bfe326f6d8f 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 286886a1a131c92a391c49802383adef9a15d54c..ec92c655f59c54269ebbde870133ecdb216f2fbf 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 592aae443b40f2901caabd40781369436f756342..6ebccef3cc5eeff346b0731395c4217808022d20 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 1f45724289b1ca878e1643c04fae48433b33f56f..d3fce702e9bbcecdee17f4cf5e6347ecc60973df 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 d3a06a60b6ebb367b62851a72dd810ab5a06046a..feb3ed097054f415fb843a2e32007f81a6a587f3 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 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 6ee4be4b2365cd37848050ea5aac30d427ef676e..a73a731f8a1c6c67916c7bb1e3ca0d073312850b 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(); } } diff --git a/src/print.cpp b/src/print.cpp index efdfe392baae65483467093f83a6d02cd4394d16..f455623aee0868be73c58732ef7c45456935141a 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -34,49 +34,48 @@ unsigned int -sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity) +SPPrintContext::bind(Geom::Affine const &transform, float opacity) { - return ctx->module->bind(transform, opacity); + return module->bind(transform, opacity); } unsigned int -sp_print_release(SPPrintContext *ctx) +SPPrintContext::release() { - return ctx->module->release(); + return module->release(); } unsigned int -sp_print_comment(SPPrintContext *ctx, char const *comment) +SPPrintContext::comment(char const *comment) { - return ctx->module->comment(comment); + return module->comment(comment); } unsigned int -sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, - Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) +SPPrintContext::fill(Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { - return ctx->module->fill(pathv, ctm, style, pbox, dbox, bbox); + return module->fill(pathv, ctm, style, pbox, dbox, bbox); } unsigned int -sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, - Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) +SPPrintContext::stroke(Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox) { - return ctx->module->stroke(pathv, ctm, style, pbox, dbox, bbox); + return module->stroke(pathv, ctm, style, pbox, dbox, bbox); } unsigned int -sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, - guchar *px, unsigned int w, unsigned int h, unsigned int rs, - Geom::Affine const &transform, SPStyle const *style) +SPPrintContext::image_R8G8B8A8_N(guchar *px, unsigned int w, unsigned int h, unsigned int rs, + Geom::Affine const &transform, SPStyle const *style) { - return ctx->module->image(px, w, h, rs, transform, style); + return module->image(px, w, h, rs, transform, style); } -unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, +unsigned int SPPrintContext::text(char const *text, Geom::Point p, SPStyle const *style) { - return ctx->module->text(text, p, style); + return module->text(text, p, style); } /* UI */ diff --git a/src/print.h b/src/print.h index ab2bcc0a703c3211f904598783a96f7923b140fe..a952672b7cdc599e2efb1788406d15f03c78a9e0 100644 --- a/src/print.h +++ b/src/print.h @@ -30,24 +30,23 @@ class Print; struct SPPrintContext { Inkscape::Extension::Print *module; -}; -unsigned int sp_print_bind(SPPrintContext *ctx, Geom::Affine const &transform, float opacity); -unsigned int sp_print_release(SPPrintContext *ctx); -unsigned int sp_print_comment(SPPrintContext *ctx, char const *comment); -unsigned int sp_print_fill(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, - Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); -unsigned int sp_print_stroke(SPPrintContext *ctx, Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, - Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); + unsigned int bind(Geom::Affine const &transform, float opacity); + unsigned int release(); + unsigned int comment(char const *comment); + unsigned int fill(Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); + unsigned int stroke(Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style, + Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox); -unsigned int sp_print_image_R8G8B8A8_N(SPPrintContext *ctx, - unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, - Geom::Affine const &transform, SPStyle const *style); + unsigned int image_R8G8B8A8_N(unsigned char *px, unsigned int w, unsigned int h, unsigned int rs, + Geom::Affine const &transform, SPStyle const *style); -unsigned int sp_print_text(SPPrintContext *ctx, char const *text, Geom::Point p, - SPStyle const *style); + unsigned int text(char const *text, Geom::Point p, + SPStyle const *style); -void sp_print_get_param(SPPrintContext *ctx, char *name, bool *value); + void get_param(char *name, bool *value); +}; /* UI */ diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 7a3971994f5710a34afa3424c1d14a8affa6be5e..081e10da25431ee57a838af5c6e3b7ace9eba142 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -2559,7 +2559,7 @@ SPCurve* curve_for_item(SPItem *item) } else if (SP_IS_IMAGE(item)) { - curve = sp_image_get_curve(SP_IMAGE(item)); + curve = SP_IMAGE(item)->get_curve(); } return curve; // do not forget to unref the curve at some point! @@ -2584,7 +2584,7 @@ SPCurve* curve_for_item_before_LPE(SPItem *item) } else if (SP_IS_IMAGE(item)) { - curve = sp_image_get_curve(SP_IMAGE(item)); + curve = SP_IMAGE(item)->get_curve(); } return curve; // do not forget to unref the curve at some point! diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 61709f791afe524892da612855f2f47b563a5ff3..53f0d4c34bc9a80c3ffa7270f8a44e2bbbc96682 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -215,7 +215,7 @@ static void colorItemDragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpoin GdkPixbuf* pixbuf = nullptr; if ( item->getGradient() ){ cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - cairo_pattern_t *gradient = sp_gradient_create_preview_pattern(item->getGradient(), width); + cairo_pattern_t *gradient = item->getGradient()->create_preview_pattern(width); cairo_t *ct = cairo_create(s); cairo_set_source(ct, gradient); cairo_paint(ct); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 8dc982b82fa6c2ffe7c7d038ba5dc10cac3f7d68..0eef5ecc3b2c05fdb2a9fc32587d965a7ed0ec7a 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -1207,7 +1207,7 @@ static void recalcSwatchContents(SPDocument* doc, ColorItem* item = new ColorItem( 0, 0, 0, name ); cairo_pattern_t *check = ink_cairo_pattern_create_checkerboard(); - cairo_pattern_t *gradient = sp_gradient_create_preview_pattern(grad, PREVIEW_PIXBUF_WIDTH); + cairo_pattern_t *gradient = grad->create_preview_pattern(PREVIEW_PIXBUF_WIDTH); cairo_set_source(ct, check); cairo_paint(ct); cairo_set_source(ct, gradient); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index e70578e906e8de87736f04684ff4172c8fe4dbe9..d0b6af9a05c3d5e30afecf787f9935f44496181b 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1796,7 +1796,7 @@ bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*) std::vector imageList = (desktop->doc())->getResourceList("image"); for (std::vector::const_iterator it = imageList.begin(); it != imageList.end(); ++it) { SPImage* image = SP_IMAGE(*it); - sp_image_refresh_if_outdated( image ); + image->refresh_if_outdated(); } } diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index aae0cc0638afd24ef403c4e4559b03f623ea06b5..1dfc1179528d7034d75e26c11e2aa754e69bb6fb 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -113,7 +113,7 @@ static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *ct) cairo_pattern_destroy(check); if (gr) { - cairo_pattern_t *p = sp_gradient_create_preview_pattern(gr, allocation.width); + cairo_pattern_t *p = gr->create_preview_pattern(allocation.width); cairo_set_source(ct, p); cairo_paint(ct); cairo_pattern_destroy(p); @@ -144,7 +144,7 @@ sp_gradient_to_pixbuf (SPGradient *gr, int width, int height) cairo_pattern_destroy(check); if (gr) { - cairo_pattern_t *p = sp_gradient_create_preview_pattern(gr, width); + cairo_pattern_t *p = gr->create_preview_pattern(width); cairo_set_source(ct, p); cairo_paint(ct); cairo_pattern_destroy(p); @@ -171,7 +171,7 @@ sp_gradient_to_pixbuf_ref (SPGradient *gr, int width, int height) cairo_pattern_destroy(check); if (gr) { - cairo_pattern_t *p = sp_gradient_create_preview_pattern(gr, width); + cairo_pattern_t *p = gr->create_preview_pattern(width); cairo_set_source(ct, p); cairo_paint(ct); cairo_pattern_destroy(p); diff --git a/testfiles/src/sp-gradient-test.cpp b/testfiles/src/sp-gradient-test.cpp index 512c2678314f161801eab3864d62f519deecab34..96da055cb0befb3da1a80bea555faf708facb673 100644 --- a/testfiles/src/sp-gradient-test.cpp +++ b/testfiles/src/sp-gradient-test.cpp @@ -84,12 +84,12 @@ TEST_F(SPGradientTest, GetG2dGetGs2dSetGs2) { Geom::Rect unit_rect(Geom::Point(0, 0), Geom::Point(1, 1)); { - Geom::Affine g2d(sp_gradient_get_g2d_matrix(gr, Geom::identity(), unit_rect)); - Geom::Affine gs2d(sp_gradient_get_gs2d_matrix(gr, Geom::identity(), unit_rect)); + Geom::Affine g2d(gr->get_g2d_matrix(Geom::identity(), unit_rect)); + Geom::Affine gs2d(gr->get_gs2d_matrix(Geom::identity(), unit_rect)); EXPECT_TRUE(Geom::are_near(Geom::identity(), g2d)); EXPECT_TRUE(Geom::are_near(gs2d, gr->gradientTransform * g2d, 1e-12)); - sp_gradient_set_gs2d_matrix(gr, Geom::identity(), unit_rect, gs2d); + gr->set_gs2d_matrix(Geom::identity(), unit_rect, gs2d); EXPECT_TRUE(Geom::are_near(gr->gradientTransform, grXform, 1e-12)); } @@ -98,31 +98,31 @@ TEST_F(SPGradientTest, GetG2dGetGs2dSetGs2) { 4, 5, 6, 7); { - Geom::Affine g2d(sp_gradient_get_g2d_matrix(gr, funny, unit_rect)); - Geom::Affine gs2d(sp_gradient_get_gs2d_matrix(gr, funny, unit_rect)); + Geom::Affine g2d(gr->get_g2d_matrix(funny, unit_rect)); + Geom::Affine gs2d(gr->get_gs2d_matrix(funny, unit_rect)); EXPECT_TRUE(Geom::are_near(funny, g2d)); EXPECT_TRUE(Geom::are_near(gs2d, gr->gradientTransform * g2d, 1e-12)); - sp_gradient_set_gs2d_matrix(gr, funny, unit_rect, gs2d); + gr->set_gs2d_matrix(funny, unit_rect, gs2d); EXPECT_TRUE(Geom::are_near(gr->gradientTransform, grXform, 1e-12)); } gr->gradientTransform = grXform; Geom::Rect larger_rect(Geom::Point(5, 6), Geom::Point(8, 10)); { - Geom::Affine g2d(sp_gradient_get_g2d_matrix(gr, funny, larger_rect)); - Geom::Affine gs2d(sp_gradient_get_gs2d_matrix(gr, funny, larger_rect)); + Geom::Affine g2d(gr->get_g2d_matrix(funny, larger_rect)); + Geom::Affine gs2d(gr->get_gs2d_matrix(funny, larger_rect)); EXPECT_TRUE(Geom::are_near(Geom::Affine(3, 0, 0, 4, 5, 6) * funny, g2d )); EXPECT_TRUE(Geom::are_near(gs2d, gr->gradientTransform * g2d, 1e-12)); - sp_gradient_set_gs2d_matrix(gr, funny, larger_rect, gs2d); + gr->set_gs2d_matrix(funny, larger_rect, gs2d); EXPECT_TRUE(Geom::are_near(gr->gradientTransform, grXform, 1e-12)); SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTUNITS, "userSpaceOnUse"); - Geom::Affine user_g2d(sp_gradient_get_g2d_matrix(gr, funny, larger_rect)); - Geom::Affine user_gs2d(sp_gradient_get_gs2d_matrix(gr, funny, larger_rect)); + Geom::Affine user_g2d(gr->get_g2d_matrix(funny, larger_rect)); + Geom::Affine user_gs2d(gr->get_gs2d_matrix(funny, larger_rect)); EXPECT_TRUE(Geom::are_near(funny, user_g2d)); EXPECT_TRUE(Geom::are_near(user_gs2d, gr->gradientTransform * user_g2d, 1e-12)); }