Lines Matching defs:gr

87 static void sp_gradient_repr_set_link(Inkscape::XML::Node *repr, SPGradient *gr);
89 SPGradient *sp_gradient_ensure_vector_normalized(SPGradient *gr)
92 g_message("sp_gradient_ensure_vector_normalized(%p)", gr);
94 g_return_val_if_fail(gr != NULL, NULL);
95 g_return_val_if_fail(SP_IS_GRADIENT(gr), NULL);
98 if (gr->state == SP_GRADIENT_STATE_VECTOR) return gr;
100 if (gr->state != SP_GRADIENT_STATE_UNKNOWN) {
101 g_warning("file %s: line %d: Cannot normalize private gradient to vector (%s)", __FILE__, __LINE__, gr->getId());
105 /* First make sure we have vector directly defined (i.e. gr has its own stops) */
106 if ( !gr->hasStops() ) {
108 gr->ensureVector();
109 g_assert(gr->vector.built);
110 // this adds stops from gr->vector as children to gr
111 sp_gradient_repr_write_vector (gr);
114 /* If gr hrefs some other gradient, remove the href */
115 if (gr->ref){
116 if (gr->ref->getObject()) {
118 gr->updateRepr(SP_OBJECT_WRITE_EXT | SP_OBJECT_WRITE_ALL);
119 sp_gradient_repr_set_link(gr->getRepr(), NULL);
124 gr->state = SP_GRADIENT_STATE_VECTOR;
125 return gr;
169 SPGradient *gr = static_cast<SPGradient *>(document->getObjectByRepr(repr));
170 g_assert(gr != NULL);
171 g_assert(SP_IS_GRADIENT(gr));
173 return gr;
177 Count how many times gr is used by the styles of o and its descendants
179 static guint count_gradient_hrefs(SPObject *o, SPGradient *gr)
190 && SP_GRADIENT(SP_STYLE_FILL_SERVER(style)) == gr)
197 && SP_GRADIENT(SP_STYLE_STROKE_SERVER(style)) == gr)
203 i += count_gradient_hrefs(child, gr);
211 * If gr has other users, create a new private; also check if gr links to vector, relink if not
213 static SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradient *vector,
217 g_message("sp_gradient_fork_private_if_necessary(%p, %p, %d, %p)", gr, vector, type, o);
219 g_return_val_if_fail(gr != NULL, NULL);
220 g_return_val_if_fail(SP_IS_GRADIENT(gr), NULL);
226 return (gr);
239 if (!vector->isSwatch() && (gr->hrefcount <= count_gradient_hrefs(user, gr))) {
241 if ( gr != vector && gr->ref->getObject() != vector ) {
242 /* our href is not the vector, and vector is different from gr; relink */
243 sp_gradient_repr_set_link(gr->getRepr(), vector);
245 return gr;
248 SPDocument *doc = gr->document;
251 if ((gr->hasStops()) ||
252 (gr->state != SP_GRADIENT_STATE_UNKNOWN) ||
253 (gr->parent != SP_OBJECT(defs)) ||
254 (gr->hrefcount > 1)) {
262 Inkscape::XML::Node *repr = gr->getRepr();
266 if (SP_IS_RADIALGRADIENT(gr)) {
272 } else if (SP_IS_LINEARGRADIENT(gr)) {
283 return gr;
287 SPGradient *sp_gradient_fork_vector_if_necessary(SPGradient *gr)
290 g_message("sp_gradient_fork_vector_if_necessary(%p)", gr);
295 return gr;
297 if (gr->hrefcount > 1) {
298 SPDocument *doc = gr->document;
301 Inkscape::XML::Node *repr = gr->getRepr()->duplicate(xml_doc);
308 return gr;
333 SPGradient *sp_gradient_reset_to_userspace(SPGradient *gr, SPItem *item)
336 g_message("sp_gradient_reset_to_userspace(%p, %p)", gr, item);
338 Inkscape::XML::Node *repr = gr->getRepr();
345 return gr;
352 if (SP_IS_RADIALGRADIENT(gr)) {
364 gr->gradientTransform = squeeze;
366 gchar *c=sp_svg_transform_write(gr->gradientTransform);
367 gr->getRepr()->setAttribute("gradientTransform", c);
370 } else if (SP_IS_LINEARGRADIENT(gr)) {
416 SPMesh* mg = SP_MESH( gr );
423 return gr;
430 SPGradient *sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar const *property)
433 g_message("sp_gradient_convert_to_userspace(%p, %p, \"%s\")", gr, item, property);
435 g_return_val_if_fail(SP_IS_GRADIENT(gr), NULL);
437 if ( gr && gr->isSolid() ) {
438 return gr;
442 gr = sp_gradient_fork_private_if_necessary(gr, gr->getVector(),
443 SP_IS_RADIALGRADIENT(gr) ? SP_GRADIENT_TYPE_RADIAL : SP_GRADIENT_TYPE_LINEAR, item);
445 if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
447 Inkscape::XML::Node *repr = gr->getRepr();
486 gr->gradientTransform = skew;
488 gchar *c=sp_svg_transform_write(gr->gradientTransform);
489 gr->getRepr()->setAttribute("gradientTransform", c);
497 if (SP_IS_RADIALGRADIENT(gr)) {
498 SPRadialGradient *rg = SP_RADIALGRADIENT(gr);
517 SPLinearGradient *lg = SP_LINEARGRADIENT(gr);
541 sp_style_set_property_url(item, property, gr, true);
543 sp_style_set_property_url(item, property, gr, false);
546 return gr;
1389 * gr has to be a normalized vector.
1392 SPGradient *sp_item_set_gradient(SPItem *item, SPGradient *gr, SPGradientType type, Inkscape::PaintTarget fill_or_stroke)
1395 g_message("sp_item_set_gradient(%p, %p, %d, %d)", item, gr, type, fill_or_stroke);
1399 g_return_val_if_fail(gr != NULL, NULL);
1400 g_return_val_if_fail(SP_IS_GRADIENT(gr), NULL);
1401 g_return_val_if_fail(gr->state == SP_GRADIENT_STATE_VECTOR, NULL);
1428 if ( current != gr && current->getVector() != gr ) {
1430 sp_gradient_repr_set_link(current->getRepr(), gr);
1439 SPGradient *normalized = sp_gradient_fork_private_if_necessary(current, gr, type, item);
1456 g_assert(SP_IS_GRADIENT(gr)); // TEMP
1457 SPGradient *constructed = sp_gradient_get_private_normalized(item->document, gr, type);
1532 SPGradient *gr = static_cast<SPGradient *>(document->getObjectByRepr(repr));
1533 g_assert(gr != NULL);
1534 g_assert(SP_IS_GRADIENT(gr));
1536 gr->state = SP_GRADIENT_STATE_VECTOR;
1538 return gr;