From: jucablues Date: Fri, 27 Jul 2007 03:07:02 +0000 (+0000) Subject: added helper methods NumberOptNumber::numIsSet() and X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=514fb30cb30a34ab3d77700af8093d808fb39815;p=inkscape.git added helper methods NumberOptNumber::numIsSet() and NumberOptNumber::optNumIsSet() using it for default attribute values in feTubulence and feConvolvematrix feDisplacementMap scale parameter variable is a double --- diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index f8a00cb4b..9c9cf5f21 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -14,7 +14,11 @@ namespace NR { FilterConvolveMatrix::FilterConvolveMatrix() -: bias(0), +: orderX(3), + orderY(3), + targetX((int)(orderX/2)), + targetY((int)(orderY/2)), + bias(0), edgeMode(0), preserveAlpha(false) {} diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 8d2e6dc3c..4b401bb33 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -59,8 +59,8 @@ int FilterDisplacementMap::render(FilterSlot &slot, Matrix const &trans) { y1 = out->area.y1; width = x1 - x0; - for (x=x0 + scale/2; x < x1 - scale/2; x++){ - for (y=y0 + scale/2; y < y1 - scale/2; y++){ + for (x=x0 + (int)(scale/2); x < x1 - (int)(scale/2); x++){ + for (y=y0 + (int)(scale/2); y < y1 - (int)(scale/2); y++){ /* SVG spec states that pixel values must be alpha-demultiplied before processing this filter operation. The following code does it, but when we DON'T do it, output is more similar to output from Batik. @@ -102,7 +102,7 @@ void FilterDisplacementMap::set_input(int slot) { _input = slot; } -void FilterDisplacementMap::set_scale(int s) { +void FilterDisplacementMap::set_scale(double s) { scale = s; } @@ -119,10 +119,10 @@ void FilterDisplacementMap::set_channel_selector(int s, int channel) { void FilterDisplacementMap::area_enlarge(NRRectL &area, Matrix const &trans) { //I'm in doubt whether this affects all input buffers or only 'in' - area.x0 -= scale/2; - area.y0 -= scale/2; - area.x1 += scale/2; - area.y1 += scale/2; + area.x0 -= (int)(scale/2); + area.y0 -= (int)(scale/2); + area.x1 += (int)(scale/2); + area.y1 += (int)(scale/2); } } /* namespace NR */ diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index 4b5c6ada5..fbe0d3064 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -27,13 +27,13 @@ public: virtual void set_input(int slot); virtual void set_input(int input, int slot); - virtual void set_scale(int s); + virtual void set_scale(double s); virtual void set_channel_selector(int channel, int s); virtual int render(FilterSlot &slot, Matrix const &trans); virtual void area_enlarge(NRRectL &area, Matrix const &trans); private: - int scale; + double scale; int _input2; int Xchannel; int Ychannel; diff --git a/src/number-opt-number.h b/src/number-opt-number.h index ef1675079..0025f2d07 100644 --- a/src/number-opt-number.h +++ b/src/number-opt-number.h @@ -73,6 +73,14 @@ public: number = num; } + bool optNumIsSet(){ + return optNumber_set; + } + + bool numIsSet(){ + return _set; + } + gchar *getValueString() { Inkscape::SVGOStringStream os; diff --git a/src/sp-feconvolvematrix.cpp b/src/sp-feconvolvematrix.cpp index 059475e5f..edd093499 100644 --- a/src/sp-feconvolvematrix.cpp +++ b/src/sp-feconvolvematrix.cpp @@ -79,11 +79,7 @@ sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass) static void sp_feConvolveMatrix_init(SPFeConvolveMatrix *feConvolveMatrix) -{ - feConvolveMatrix->divisor=0; - feConvolveMatrix->preserveAlpha = false; - feConvolveMatrix->order.set("3 3"); -} +{} /** * Reads the Inkscape::XML::Node, and initializes SPFeConvolveMatrix variables. For this to get called, @@ -190,6 +186,9 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value) /*DEAL WITH SETTING ATTRIBUTES HERE*/ case SP_ATTR_ORDER: feConvolveMatrix->order.set(value); + //From SVG spec: If is not provided, it defaults to . + if (feConvolveMatrix->order.optNumIsSet() == false) + feConvolveMatrix->order.setOptNumber(feConvolveMatrix->order.getNumber()); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_KERNELMATRIX: diff --git a/src/sp-feturbulence.cpp b/src/sp-feturbulence.cpp index 138778984..f7b256898 100644 --- a/src/sp-feturbulence.cpp +++ b/src/sp-feturbulence.cpp @@ -174,7 +174,7 @@ sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value) case SP_ATTR_BASEFREQUENCY: feTurbulence->baseFrequency.set(value); //From SVG spec: If two s are provided, the first number represents a base frequency in the X direction and the second value represents a base frequency in the Y direction. If one number is provided, then that value is used for both X and Y. - if (feTurbulence->baseFrequency.getOptNumber() == -1) // -1 means "not set" + if (feTurbulence->baseFrequency.optNumIsSet() == false) feTurbulence->baseFrequency.setOptNumber(feTurbulence->baseFrequency.getNumber()); object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); break;