summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-09-23 22:53:52 +0000
committerMarkus Engel <markus.engel@tum.de>2013-09-23 22:53:52 +0000
commitbbe5a375195443bf9235f859d58d533fe5815e00 (patch)
tree023fcc2171c19e48fa5aaf4326abf9ef717e6035 /src
parentfix crash on uninitialized unittracker for spinbuttons. fixes crash on changi... (diff)
downloadinkscape-bbe5a375195443bf9235f859d58d533fe5815e00.tar.gz
inkscape-bbe5a375195443bf9235f859d58d533fe5815e00.zip
Fixed FeComponentTransfer.
Fixed bugs: - https://launchpad.net/bugs/1229326 (bzr r12582)
Diffstat (limited to 'src')
-rw-r--r--src/filters/componenttransfer-funcnode.cpp31
-rw-r--r--src/filters/componenttransfer-funcnode.h28
-rw-r--r--src/filters/componenttransfer.cpp26
-rw-r--r--src/sp-object.cpp2
4 files changed, 57 insertions, 30 deletions
diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp
index 7c5191700..7c7375802 100644
--- a/src/filters/componenttransfer-funcnode.cpp
+++ b/src/filters/componenttransfer-funcnode.cpp
@@ -30,10 +30,37 @@
#define SP_MACROS_SILENT
#include "macros.h"
+
+#include "sp-factory.h"
+
+namespace {
+ SPObject* createFuncR() {
+ return new SPFeFuncNode(SPFeFuncNode::R);
+ }
+
+ SPObject* createFuncG() {
+ return new SPFeFuncNode(SPFeFuncNode::G);
+ }
+
+ SPObject* createFuncB() {
+ return new SPFeFuncNode(SPFeFuncNode::B);
+ }
+
+ SPObject* createFuncA() {
+ return new SPFeFuncNode(SPFeFuncNode::A);
+ }
+
+ bool funcRRegistered = SPFactory::instance().registerObject("svg:feFuncR", createFuncR);
+ bool funcGRegistered = SPFactory::instance().registerObject("svg:feFuncG", createFuncG);
+ bool funcBRegistered = SPFactory::instance().registerObject("svg:feFuncB", createFuncB);
+ bool funcARegistered = SPFactory::instance().registerObject("svg:feFuncA", createFuncA);
+}
+
+
/* FeFuncNode class */
-SPFeFuncNode::SPFeFuncNode()
+SPFeFuncNode::SPFeFuncNode(SPFeFuncNode::Channel channel)
: SPObject(), type(Inkscape::Filters::COMPONENTTRANSFER_TYPE_IDENTITY),
- slope(1), intercept(0), amplitude(1), exponent(1), offset(0) {
+ slope(1), intercept(0), amplitude(1), exponent(1), offset(0), channel(channel) {
}
SPFeFuncNode::~SPFeFuncNode() {
diff --git a/src/filters/componenttransfer-funcnode.h b/src/filters/componenttransfer-funcnode.h
index a5f813e1e..4f9b8de2e 100644
--- a/src/filters/componenttransfer-funcnode.h
+++ b/src/filters/componenttransfer-funcnode.h
@@ -18,32 +18,15 @@
#include "sp-object.h"
#include "display/nr-filter-component-transfer.h"
-//#define SP_TYPE_FEFUNCR (sp_fefuncR_get_type())
-//#define SP_TYPE_FEFUNCG (sp_fefuncG_get_type())
-//#define SP_TYPE_FEFUNCB (sp_fefuncB_get_type())
-//#define SP_TYPE_FEFUNCA (sp_fefuncA_get_type())
-
-// CPPIFY: Casting macros buggy, as these aren't classes.
-//#define SP_IS_FEFUNCR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFUNCR))
-//#define SP_IS_FEFUNCG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFUNCG))
-//#define SP_IS_FEFUNCB(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFUNCB))
-//#define SP_IS_FEFUNCA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFUNCA))
-
#define SP_FEFUNCNODE(obj) (dynamic_cast<SPFeFuncNode*>((SPObject*)obj))
-//#define SP_IS_FEFUNCR(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode)))
-//#define SP_IS_FEFUNCG(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode)))
-//#define SP_IS_FEFUNCB(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode)))
-//#define SP_IS_FEFUNCA(obj) (obj != NULL && static_cast<const SPObject*>(obj)->typeHierarchy.count(typeid(SPFeFuncNode)))
-
-#define SP_IS_FEFUNCR(obj) (dynamic_cast<const SPFeFuncNode*>((SPObject*)obj) != NULL)
-#define SP_IS_FEFUNCG(obj) (dynamic_cast<const SPFeFuncNode*>((SPObject*)obj) != NULL)
-#define SP_IS_FEFUNCB(obj) (dynamic_cast<const SPFeFuncNode*>((SPObject*)obj) != NULL)
-#define SP_IS_FEFUNCA(obj) (dynamic_cast<const SPFeFuncNode*>((SPObject*)obj) != NULL)
-
class SPFeFuncNode : public SPObject {
public:
- SPFeFuncNode();
+ enum Channel {
+ R, G, B, A
+ };
+
+ SPFeFuncNode(Channel channel);
virtual ~SPFeFuncNode();
Inkscape::Filters::FilterComponentTransferType type;
@@ -53,6 +36,7 @@ public:
double amplitude;
double exponent;
double offset;
+ Channel channel;
protected:
virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp
index 96d1ea0bf..610b3dd02 100644
--- a/src/filters/componenttransfer.cpp
+++ b/src/filters/componenttransfer.cpp
@@ -65,12 +65,26 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c
bool set[4] = {false, false, false, false};
SPObject* node = sp_componenttransfer->children;
for(;node;node=node->next){
- int i=4;
- if (SP_IS_FEFUNCR(node)) i=0;
- if (SP_IS_FEFUNCG(node)) i=1;
- if (SP_IS_FEFUNCB(node)) i=2;
- if (SP_IS_FEFUNCA(node)) i=3;
- if (i==4) {
+ int i = 4;
+
+ SPFeFuncNode *funcNode = SP_FEFUNCNODE(node);
+
+ switch (funcNode->channel) {
+ case SPFeFuncNode::R:
+ i = 0;
+ break;
+ case SPFeFuncNode::G:
+ i = 1;
+ break;
+ case SPFeFuncNode::B:
+ i = 2;
+ break;
+ case SPFeFuncNode::A:
+ i = 3;
+ break;
+ }
+
+ if (i == 4) {
g_warning("Unrecognized channel for component transfer.");
break;
}
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index fa7d30dab..6fd4de43b 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -599,6 +599,7 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
std::string node = e.what();
// special cases
+ if (node.empty()) return; // comments, usually
if (node == "rdf:RDF") return; // no SP node yet
if (node == "inkscape:clipboard") return; // SP node not necessary
@@ -651,6 +652,7 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) {
const std::string typeString = NodeTraits::get_type_string(*rchild);
// special cases
+ if (typeString.empty()) continue; // comments, usually
if (typeString == "rdf:RDF") continue; // no SP node yet
if (typeString == "inkscape:clipboard") continue; // SP node not necessary