Code

Fixes "disappearing gradients" problem discussed on mailing list and adds a few g_war...
authorjaspervdg <jaspervdg@users.sourceforge.net>
Sat, 20 Dec 2008 14:00:41 +0000 (14:00 +0000)
committerjaspervdg <jaspervdg@users.sourceforge.net>
Sat, 20 Dec 2008 14:00:41 +0000 (14:00 +0000)
src/display/nr-filter-component-transfer.cpp
src/filters/componenttransfer.cpp

index 4004d6e8d1373a7c761c1ef38d8ed1d49e994aa6..5c4fd45982d0c6c7d465d6330a29452c76614a23 100644 (file)
@@ -118,7 +118,10 @@ int FilterComponentTransfer::render(FilterSlot &slot, FilterUnits const &/*units
                 break;
             case COMPONENTTRANSFER_TYPE_ERROR:
                 //TODO: report an error here
+                g_warning("Component tranfer type \"error\".");
                 break;
+            default:
+                g_warning("Invalid tranfer type %d.", type[color]);
         }
     }
 
index 09ea48bc6f713469526de067295b1be2fdaa3d5d..603e1f4e57297f54392ed8c92d30b7e26d90937a 100644 (file)
@@ -25,7 +25,7 @@
 #include "componenttransfer.h"
 #include "componenttransfer-funcnode.h"
 #include "xml/repr.h"
-//#include "display/nr-filter-component-transfer.h"
+#include "display/nr-filter-component-transfer.h"
 
 /* FeComponentTransfer base class */
 
@@ -106,6 +106,7 @@ sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::X
 static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_componenttransfer)
 {
     if (sp_componenttransfer->renderer) {
+        bool set[4] = {false, false, false, false};
         SPObject* node = sp_componenttransfer->children;
         for(;node;node=node->next){
             int i=4;
@@ -113,7 +114,10 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c
             if (SP_IS_FEFUNCG(node)) i=1;
             if (SP_IS_FEFUNCB(node)) i=2;
             if (SP_IS_FEFUNCA(node)) i=3;
-            if (i==4) break;
+            if (i==4) {
+                g_warning("Unrecognized channel for component transfer.");
+                break;
+            }
             sp_componenttransfer->renderer->type[i] = ((SPFeFuncNode *) node)->type;
             sp_componenttransfer->renderer->tableValues[i] = ((SPFeFuncNode *) node)->tableValues;
             sp_componenttransfer->renderer->slope[i] = ((SPFeFuncNode *) node)->slope;
@@ -121,6 +125,13 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c
             sp_componenttransfer->renderer->amplitude[i] = ((SPFeFuncNode *) node)->amplitude;
             sp_componenttransfer->renderer->exponent[i] = ((SPFeFuncNode *) node)->exponent;
             sp_componenttransfer->renderer->offset[i] = ((SPFeFuncNode *) node)->offset;
+            set[i] = true;
+        }
+        // Set any types not explicitly set to the identity transform
+        for(int i=0;i<4;i++) {
+            if (!set[i]) {
+                sp_componenttransfer->renderer->type[i] = NR::COMPONENTTRANSFER_TYPE_IDENTITY;
+            }
         }
     }
 }