summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-03-12 20:15:38 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-03-12 20:15:38 +0000
commit3697b9ed4fa85fc4deb9a9069dc7397fbedc2003 (patch)
treeb1e8aa49ce94542b41231eb36c6e804ec2b3e08c /src
parentupdate to trunk (diff)
parentincorrect gradient transform on copy&paste.. committing for mathog (diff)
downloadinkscape-3697b9ed4fa85fc4deb9a9069dc7397fbedc2003.tar.gz
inkscape-3697b9ed4fa85fc4deb9a9069dc7397fbedc2003.zip
update to trunk
(bzr r11950.1.291)
Diffstat (limited to 'src')
-rw-r--r--src/display/drawing-surface.cpp36
-rw-r--r--src/document.cpp3
-rw-r--r--src/id-clash.cpp7
-rw-r--r--src/selection-chemistry.cpp2
-rw-r--r--src/sp-gradient.cpp19
-rw-r--r--src/sp-gradient.h1
6 files changed, 47 insertions, 21 deletions
diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp
index 30579134b..d2540de66 100644
--- a/src/display/drawing-surface.cpp
+++ b/src/display/drawing-surface.cpp
@@ -215,7 +215,7 @@ DrawingCache::prepare()
bool is_identity = _pending_transform.isIdentity();
if (is_identity && _pending_area == old_area) return; // no change
- bool is_integer_translation = false;
+ bool is_integer_translation = is_identity;
if (!is_identity && _pending_transform.isTranslation()) {
Geom::IntPoint t = _pending_transform.translation().round();
if (Geom::are_near(Geom::Point(t), _pending_transform.translation())) {
@@ -224,6 +224,7 @@ DrawingCache::prepare()
if (old_area + t == _pending_area) {
// if the areas match, the only thing to do
// is to ensure that the clean area is not too large
+ // we can exit early
cairo_rectangle_int_t limit = _convertRect(_pending_area);
cairo_region_intersect_rectangle(_clean_region, &limit);
_origin += t;
@@ -232,33 +233,36 @@ DrawingCache::prepare()
}
}
}
- // otherwise, we need to transform the cache
+
+ // the area has changed, so the cache content needs to be copied
Geom::IntPoint old_origin = old_area.min();
cairo_surface_t *old_surface = _surface;
_surface = NULL;
_pixels = _pending_area.dimensions();
_origin = _pending_area.min();
- cairo_t *ct = createRawContext();
- if (!is_identity) {
- ink_cairo_transform(ct, _pending_transform);
- }
- cairo_set_source_surface(ct, old_surface, old_origin[X], old_origin[Y]);
- cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE);
- cairo_paint(ct);
-
- cairo_surface_destroy(old_surface);
- cairo_destroy(ct);
+ if (is_integer_translation) {
+ // transform the cache only for integer translations and identities
+ cairo_t *ct = createRawContext();
+ if (!is_identity) {
+ ink_cairo_transform(ct, _pending_transform);
+ }
+ cairo_set_source_surface(ct, old_surface, old_origin[X], old_origin[Y]);
+ cairo_set_operator(ct, CAIRO_OPERATOR_SOURCE);
+ cairo_pattern_set_filter(cairo_get_source(ct), CAIRO_FILTER_NEAREST);
+ cairo_paint(ct);
+ cairo_destroy(ct);
- if (!is_identity && !is_integer_translation) {
+ cairo_rectangle_int_t limit = _convertRect(_pending_area);
+ cairo_region_intersect_rectangle(_clean_region, &limit);
+ } else {
// dirty everything
cairo_region_destroy(_clean_region);
_clean_region = cairo_region_create();
- } else {
- cairo_rectangle_int_t limit = _convertRect(_pending_area);
- cairo_region_intersect_rectangle(_clean_region, &limit);
}
+
//std::cout << _pending_transform << old_area << _pending_area << std::endl;
+ cairo_surface_destroy(old_surface);
_pending_transform.setIdentity();
}
diff --git a/src/document.cpp b/src/document.cpp
index d71fd97df..4756110f6 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -1552,7 +1552,8 @@ void SPDocument::importDefs(SPDocument *source)
SPGradient *gr = SP_GRADIENT(src);
for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) {
if (trg && SP_IS_GRADIENT(trg) && src != trg) {
- if (gr->isEquivalent(SP_GRADIENT(trg))) {
+ if (gr->isEquivalent(SP_GRADIENT(trg)) &&
+ gr->isAligned(SP_GRADIENT(trg))) {
// Change object references to the existing equivalent gradient
change_def_references(src, trg);
duplicate = true;
diff --git a/src/id-clash.cpp b/src/id-clash.cpp
index 76b8e6ff8..f59b3b920 100644
--- a/src/id-clash.cpp
+++ b/src/id-clash.cpp
@@ -215,9 +215,10 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc,
SPObject *cd_obj = current_doc->getObjectById(id);
if (cd_obj && SP_IS_GRADIENT(cd_obj)) {
- SPGradient *cd_gr = SP_GRADIENT(cd_obj);
- if (cd_gr->isEquivalent(SP_GRADIENT(elem))) {
- fix_clashing_ids = false;
+ SPGradient *cd_gr = SP_GRADIENT(cd_obj);
+ if ( cd_gr->isEquivalent(SP_GRADIENT(elem)) &&
+ cd_gr->isAligned(SP_GRADIENT(elem))) {
+ fix_clashing_ids = false;
}
}
}
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index fad2dff5b..5a981c6a0 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -794,7 +794,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop)
GSList *groups = NULL;
for (GSList *item = old_select; item; item = item->next) {
SPItem *obj = static_cast<SPItem*>(item->data);
- if (SP_IS_GROUP(obj) && !SP_IS_SWITCH(obj)) {
+ if (SP_IS_GROUP(obj)) {
groups = g_slist_prepend(groups, obj);
}
}
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index 04fb18cf3..e2ae98ec5 100644
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
@@ -135,6 +135,25 @@ gboolean SPGradient::isEquivalent(SPGradient *that)
return TRUE;
}
+/**
+ * return true if this gradient is "aligned" to that gradient.
+ * Aligned means that they have exactly the same transform.
+ * @param that - A gradient to compare this to
+ */
+gboolean SPGradient::isAligned(SPGradient *that)
+{
+ bool status = FALSE;
+
+ while(1){ // not really a loop, used to avoid deep nesting or multiple exit points from function
+ if(this->gradientTransform_set != that->gradientTransform_set) { break; }
+ if(this->gradientTransform_set &&
+ (this->gradientTransform != that->gradientTransform)) { break; }
+ status = TRUE;
+ break;
+ }
+ return status;
+}
+
/*
* Gradient
diff --git a/src/sp-gradient.h b/src/sp-gradient.h
index 46eb41cdb..1dfff22ee 100644
--- a/src/sp-gradient.h
+++ b/src/sp-gradient.h
@@ -147,6 +147,7 @@ public:
int getStopCount() const;
gboolean isEquivalent(SPGradient *b);
+ gboolean isAligned(SPGradient *b);
/** Mesh Gradients **************/