summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2017-10-05 15:34:42 +0000
committerShlomi Fish <shlomif@shlomifish.org>2017-10-05 15:34:42 +0000
commitb4b96eb22c978024da8841f9184b1c7d85140ffd (patch)
treeb3b01e875ab3f237cce27829bdc9b2beaf7daa23 /src
parentExtract SPDimensions from spuse (diff)
downloadinkscape-b4b96eb22c978024da8841f9184b1c7d85140ffd.tar.gz
inkscape-b4b96eb22c978024da8841f9184b1c7d85140ffd.zip
Extract SPDimensions from spfilters
Diffstat (limited to 'src')
-rw-r--r--src/sp-dimensions.cpp7
-rw-r--r--src/sp-dimensions.h2
-rw-r--r--src/sp-filter-primitive.cpp20
-rw-r--r--src/sp-filter-primitive.h6
-rw-r--r--src/sp-filter.cpp20
-rw-r--r--src/sp-filter.h9
6 files changed, 14 insertions, 50 deletions
diff --git a/src/sp-dimensions.cpp b/src/sp-dimensions.cpp
index 2eb495219..f39b98945 100644
--- a/src/sp-dimensions.cpp
+++ b/src/sp-dimensions.cpp
@@ -19,21 +19,26 @@
#include "sp-dimensions.h"
#include "sp-item.h"
-void SPDimensions::calcDimsFromParentViewport(const SPItemCtx *ictx)
+void SPDimensions::calcDimsFromParentViewport(const SPItemCtx *ictx, bool assign_to_set)
{
+#define ASSIGN(field) { if (assign_to_set) { field._set = true; } }
if (this->x.unit == SVGLength::PERCENT) {
+ ASSIGN(x);
this->x.computed = this->x.value * ictx->viewport.width();
}
if (this->y.unit == SVGLength::PERCENT) {
+ ASSIGN(y);
this->y.computed = this->y.value * ictx->viewport.height();
}
if (this->width.unit == SVGLength::PERCENT) {
+ ASSIGN(width);
this->width.computed = this->width.value * ictx->viewport.width();
}
if (this->height.unit == SVGLength::PERCENT) {
+ ASSIGN(height);
this->height.computed = this->height.value * ictx->viewport.height();
}
}
diff --git a/src/sp-dimensions.h b/src/sp-dimensions.h
index b3581d953..eb76df739 100644
--- a/src/sp-dimensions.h
+++ b/src/sp-dimensions.h
@@ -23,7 +23,7 @@ public:
SVGLength y;
SVGLength width;
SVGLength height;
- void calcDimsFromParentViewport(const SPItemCtx *ictx);
+ void calcDimsFromParentViewport(const SPItemCtx *ictx, bool assign_to_set = false);
};
#endif
diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp
index 0fbeed15b..7ced52e11 100644
--- a/src/sp-filter-primitive.cpp
+++ b/src/sp-filter-primitive.cpp
@@ -139,25 +139,7 @@ void SPFilterPrimitive::update(SPCtx *ctx, guint flags) {
SPFilter *parent = SP_FILTER(this->parent);
if( parent->primitiveUnits == SP_FILTER_UNITS_USERSPACEONUSE ) {
- if (this->x.unit == SVGLength::PERCENT) {
- this->x._set = true;
- this->x.computed = this->x.value * ictx->viewport.width();
- }
-
- if (this->y.unit == SVGLength::PERCENT) {
- this->y._set = true;
- this->y.computed = this->y.value * ictx->viewport.height();
- }
-
- if (this->width.unit == SVGLength::PERCENT) {
- this->width._set = true;
- this->width.computed = this->width.value * ictx->viewport.width();
- }
-
- if (this->height.unit == SVGLength::PERCENT) {
- this->height._set = true;
- this->height.computed = this->height.value * ictx->viewport.height();
- }
+ this->calcDimsFromParentViewport(ictx, true);
}
SPObject::update(ctx, flags);
diff --git a/src/sp-filter-primitive.h b/src/sp-filter-primitive.h
index d81adbd10..0ecb8af62 100644
--- a/src/sp-filter-primitive.h
+++ b/src/sp-filter-primitive.h
@@ -15,6 +15,7 @@
*/
#include "sp-object.h"
+#include "sp-dimensions.h"
#include "svg/svg-length.h"
#define SP_FILTER_PRIMITIVE(obj) (dynamic_cast<SPFilterPrimitive*>((SPObject*)obj))
@@ -26,16 +27,13 @@ class Filter;
class FilterPrimitive;
} }
-class SPFilterPrimitive : public SPObject {
+class SPFilterPrimitive : public SPObject, public SPDimensions {
public:
SPFilterPrimitive();
virtual ~SPFilterPrimitive();
int image_in, image_out;
- /* filter primitive subregion */
- SVGLength x, y, height, width;
-
protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
virtual void release();
diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp
index 2a5ec0755..aa5fe2942 100644
--- a/src/sp-filter.cpp
+++ b/src/sp-filter.cpp
@@ -213,25 +213,7 @@ void SPFilter::update(SPCtx *ctx, guint flags) {
// Note: This only works for root viewport since this routine is not called after
// setting a new viewport. A true fix requires a strategy like SPItemView or SPMarkerView.
if(this->filterUnits == SP_FILTER_UNITS_USERSPACEONUSE) {
- if (this->x.unit == SVGLength::PERCENT) {
- this->x._set = true;
- this->x.computed = this->x.value * ictx->viewport.width();
- }
-
- if (this->y.unit == SVGLength::PERCENT) {
- this->y._set = true;
- this->y.computed = this->y.value * ictx->viewport.height();
- }
-
- if (this->width.unit == SVGLength::PERCENT) {
- this->width._set = true;
- this->width.computed = this->width.value * ictx->viewport.width();
- }
-
- if (this->height.unit == SVGLength::PERCENT) {
- this->height._set = true;
- this->height.computed = this->height.value * ictx->viewport.height();
- }
+ this->calcDimsFromParentViewport(ictx, true);
}
/* do something to trigger redisplay, updates? */
diff --git a/src/sp-filter.h b/src/sp-filter.h
index 1c214c6b7..054562d39 100644
--- a/src/sp-filter.h
+++ b/src/sp-filter.h
@@ -16,6 +16,7 @@
#include <map>
#include "number-opt-number.h"
+#include "sp-dimensions.h"
#include "sp-object.h"
#include "sp-filter-units.h"
#include "svg/svg-length.h"
@@ -38,7 +39,7 @@ struct ltstr {
bool operator()(const char* s1, const char* s2) const;
};
-class SPFilter : public SPObject {
+class SPFilter : public SPObject, public SPDimensions {
public:
SPFilter();
virtual ~SPFilter();
@@ -47,14 +48,10 @@ public:
unsigned int filterUnits_set : 1;
SPFilterUnits primitiveUnits;
unsigned int primitiveUnits_set : 1;
- SVGLength x;
- SVGLength y;
- SVGLength width;
- SVGLength height;
NumberOptNumber filterRes;
SPFilterReference *href;
sigc::connection modified_connection;
-
+
guint getRefCount();
guint _refcount;