From: kiirala Date: Wed, 31 Oct 2007 13:56:54 +0000 (+0000) Subject: Modified filter primitives' render method to use FilterUnits instead of Matrix X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fb86717633bfcfe161571aed7058ea6a39b7a69b;p=inkscape.git Modified filter primitives' render method to use FilterUnits instead of Matrix --- diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index b02b20cbf..fe21dc125 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -19,6 +19,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" #include "display/nr-filter-types.h" +#include "display/nr-filter-units.h" #include "libnr/nr-pixblock.h" #include "libnr/nr-matrix.h" #include "libnr/nr-blit.h" @@ -123,7 +124,7 @@ FilterPrimitive * FilterBlend::create() { FilterBlend::~FilterBlend() {} -int FilterBlend::render(FilterSlot &slot, Matrix const &trans) { +int FilterBlend::render(FilterSlot &slot, FilterUnits const & /*units*/) { NRPixBlock *in1 = slot.get(_input); NRPixBlock *in2 = slot.get(_input2); NRPixBlock *original_in1 = in1; diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index ffed2cd03..28f92dad4 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -19,6 +19,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" namespace NR { @@ -38,7 +39,7 @@ public: static FilterPrimitive *create(); virtual ~FilterBlend(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void set_input(int slot); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index 3ed193984..e69e753e8 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -10,8 +10,9 @@ */ #include "display/nr-filter-colormatrix.h" +#include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" -#include +#include namespace NR { @@ -26,7 +27,7 @@ FilterPrimitive * FilterColorMatrix::create() { FilterColorMatrix::~FilterColorMatrix() {} -int FilterColorMatrix::render(FilterSlot &slot, Matrix const &trans) { +int FilterColorMatrix::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); NRPixBlock *out = new NRPixBlock; diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index 32b57ce0c..d62cb5c19 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include namespace NR { @@ -32,7 +33,7 @@ public: static FilterPrimitive *create(); virtual ~FilterColorMatrix(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &trans); virtual void set_type(FilterColorMatrixType type); virtual void set_value(gdouble value); diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp index 909dc7d90..a190cecde 100644 --- a/src/display/nr-filter-component-transfer.cpp +++ b/src/display/nr-filter-component-transfer.cpp @@ -10,6 +10,7 @@ */ #include "display/nr-filter-component-transfer.h" +#include "display/nr-filter-units.h" namespace NR { @@ -25,7 +26,7 @@ FilterPrimitive * FilterComponentTransfer::create() { FilterComponentTransfer::~FilterComponentTransfer() {} -int FilterComponentTransfer::render(FilterSlot &slot, Matrix const &trans) { +int FilterComponentTransfer::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); NRPixBlock *out = new NRPixBlock; diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h index 9036a6644..30b793777 100644 --- a/src/display/nr-filter-component-transfer.h +++ b/src/display/nr-filter-component-transfer.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include namespace NR { @@ -33,7 +34,7 @@ public: static FilterPrimitive *create(); virtual ~FilterComponentTransfer(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &trans); void set_type(FilterComponentTransferType t); diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index 29207b6b9..de7dd7952 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -16,6 +16,7 @@ #include "display/nr-filter-composite.h" #include "display/nr-filter-pixops.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "libnr/nr-blit.h" #include "libnr/nr-pixblock.h" @@ -97,7 +98,7 @@ FilterPrimitive * FilterComposite::create() { FilterComposite::~FilterComposite() {} -int FilterComposite::render(FilterSlot &slot, Matrix const &trans) { +int FilterComposite::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in1 = slot.get(_input); NRPixBlock *in2 = slot.get(_input2); NRPixBlock *original_in1 = in1; diff --git a/src/display/nr-filter-composite.h b/src/display/nr-filter-composite.h index a1bbbb186..e41dd77db 100644 --- a/src/display/nr-filter-composite.h +++ b/src/display/nr-filter-composite.h @@ -15,6 +15,7 @@ #include "sp-fecomposite.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" namespace NR { @@ -25,7 +26,7 @@ public: static FilterPrimitive *create(); virtual ~FilterComposite(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void set_input(int input); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index 13bc585c9..e40a201a0 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -10,8 +10,10 @@ */ #include "display/nr-filter-convolve-matrix.h" +#include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include + namespace NR { FilterConvolveMatrix::FilterConvolveMatrix() @@ -32,7 +34,7 @@ static bool inside_area(int px, int py, int w, int h){ return true; } -int FilterConvolveMatrix::render(FilterSlot &slot, Matrix const &trans) { +int FilterConvolveMatrix::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); NRPixBlock *out = new NRPixBlock; diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index ec47028e1..b13db2f98 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" #include "libnr/nr-rect-l.h" #include @@ -33,7 +34,7 @@ public: static FilterPrimitive *create(); virtual ~FilterConvolveMatrix(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &trans); virtual FilterTraits get_input_traits(); diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index 0fa0495e7..9ff3922e8 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -17,6 +17,7 @@ #include "display/nr-filter-diffuselighting.h" #include "display/nr-filter-getalpha.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" #include "libnr/nr-blit.h" @@ -49,7 +50,7 @@ do {\ }while(0) -int FilterDiffuseLighting::render(FilterSlot &slot, Matrix const &trans) { +int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = filter_get_alpha(slot.get(_input)); NRPixBlock *out = new NRPixBlock; @@ -63,7 +64,7 @@ int FilterDiffuseLighting::render(FilterSlot &slot, Matrix const &trans) { int dx = 1; //TODO setup int dy = 1; //TODO setup //surface scale - //TODO for the time being, assumes userSpaceOnUse + Matrix trans = units.get_matrix_primitiveunits2pb(); gdouble ss = surfaceScale * trans[0]; gdouble kd = diffuseConstant; //diffuse lighting constant @@ -102,9 +103,9 @@ int FilterDiffuseLighting::render(FilterSlot &slot, Matrix const &trans) { PointLight *pl = new PointLight(light.point, lighting_color, trans); pl->light_components(LC); //TODO we need a reference to the filter to determine primitiveUnits - //slot._arena_item->filter seems to be ok on simple examples - //for now assume userSpaceOnUse //if objectBoundingBox is used, use a different matrix for light_vector + // UPDATE: trans is now correct matrix from primitiveUnits to + // pixblock coordinates //finish the work for (i = 0, j = 0; i < w*h; i++) { compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); @@ -127,9 +128,9 @@ int FilterDiffuseLighting::render(FilterSlot &slot, Matrix const &trans) { { SpotLight *sl = new SpotLight(light.spot, lighting_color, trans); //TODO we need a reference to the filter to determine primitiveUnits - //slot._arena_item->filter seems to be ok on simple examples - //for now assume userSpaceOnUse //if objectBoundingBox is used, use a different matrix for light_vector + // UPDATE: trans is now correct matrix from primitiveUnits to + // pixblock coordinates //finish the work for (i = 0, j = 0; i < w*h; i++) { compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 37da884ca..669d2c7e1 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -17,6 +17,7 @@ #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" #include "sp-fedistantlight.h" #include "sp-fepointlight.h" @@ -40,7 +41,7 @@ public: FilterDiffuseLighting(); static FilterPrimitive *create(); virtual ~FilterDiffuseLighting(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual FilterTraits get_input_traits(); private: diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index f40510928..184aa802d 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -11,6 +11,7 @@ #include "display/nr-filter-displacement-map.h" #include "display/nr-filter-types.h" +#include "display/nr-filter-units.h" #include "libnr/nr-pixops.h" namespace NR { @@ -25,7 +26,7 @@ FilterPrimitive * FilterDisplacementMap::create() { FilterDisplacementMap::~FilterDisplacementMap() {} -int FilterDisplacementMap::render(FilterSlot &slot, Matrix const &trans) { +int FilterDisplacementMap::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *texture = slot.get(_input); NRPixBlock *map = slot.get(_input2); diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index bf0565c22..b89553697 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" #include "libnr/nr-rect-l.h" @@ -29,7 +30,7 @@ public: virtual void set_input(int input, int slot); virtual void set_scale(double s); virtual void set_channel_selector(int channel, int s); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &trans); virtual FilterTraits get_input_traits(); diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index 5bd346637..fc03e564f 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -10,6 +10,8 @@ */ #include "display/nr-filter-flood.h" +#include "display/nr-filter-units.h" + namespace NR { FilterFlood::FilterFlood() @@ -24,7 +26,7 @@ FilterPrimitive * FilterFlood::create() { FilterFlood::~FilterFlood() {} -int FilterFlood::render(FilterSlot &slot, Matrix const &trans) { +int FilterFlood::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); NRPixBlock *out = new NRPixBlock; diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index 548711164..34cde5a78 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" namespace NR { @@ -23,7 +24,7 @@ public: static FilterPrimitive *create(); virtual ~FilterFlood(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &trans); }; diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index fb94a654b..fdab94f1d 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -24,6 +24,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-gaussian.h" #include "display/nr-filter-types.h" +#include "display/nr-filter-units.h" #include "libnr/nr-pixblock.h" #include "libnr/nr-matrix.h" #include "util/fixed_point.h" @@ -505,8 +506,9 @@ upsample(PT *const dst, int const dstr1, int const dstr2, unsigned int const dn1 } } -int FilterGaussian::render(FilterSlot &slot, Matrix const &trans) +int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units) { + Matrix trans = units.get_matrix_primitiveunits2pb(); /* in holds the input pixblock */ NRPixBlock *in = slot.get(_input); diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index 7b2a96ca5..3ff3e3d22 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -16,6 +16,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-pixblock.h" #include "libnr/nr-matrix.h" #include "libnr/nr-rect-l.h" @@ -36,7 +37,7 @@ public: static FilterPrimitive *create(); virtual ~FilterGaussian(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &m); virtual FilterTraits get_input_traits(); diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index bd5e52965..b8abb0317 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -11,6 +11,7 @@ #include "display/nr-arena-item.h" #include "display/nr-filter.h" #include "display/nr-filter-image.h" +#include "display/nr-filter-units.h" namespace NR { @@ -31,7 +32,7 @@ FilterPrimitive * FilterImage::create() { FilterImage::~FilterImage() {} -int FilterImage::render(FilterSlot &slot, Matrix const &trans) { +int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { int w,x,y; NRPixBlock *in = slot.get(_input); NRPixBlock *out = new NRPixBlock; diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index 0e522139c..9d4057826 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include namespace NR { @@ -24,7 +25,7 @@ public: static FilterPrimitive *create(); virtual ~FilterImage(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual FilterTraits get_input_traits(); void set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height); private: diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index 8650fee8b..1e95d7cf1 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -17,6 +17,7 @@ #include "display/nr-filter-merge.h" #include "display/nr-filter-pixops.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "libnr/nr-blit.h" #include "libnr/nr-pixblock.h" @@ -45,7 +46,7 @@ FilterPrimitive * FilterMerge::create() { FilterMerge::~FilterMerge() {} -int FilterMerge::render(FilterSlot &slot, Matrix const &trans) { +int FilterMerge::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in[_input_image.size()]; NRPixBlock *original_in[_input_image.size()]; diff --git a/src/display/nr-filter-merge.h b/src/display/nr-filter-merge.h index a88819c50..5fe6b33e3 100644 --- a/src/display/nr-filter-merge.h +++ b/src/display/nr-filter-merge.h @@ -17,6 +17,7 @@ #include "sp-femerge.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" namespace NR { @@ -27,7 +28,7 @@ public: static FilterPrimitive *create(); virtual ~FilterMerge(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void set_input(int input); virtual void set_input(int input, int slot); diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp index 6cc6dd7b8..20dc95bfa 100644 --- a/src/display/nr-filter-morphology.cpp +++ b/src/display/nr-filter-morphology.cpp @@ -10,6 +10,8 @@ */ #include "display/nr-filter-morphology.h" +#include "display/nr-filter-units.h" + namespace NR { FilterMorphology::FilterMorphology() @@ -23,7 +25,7 @@ FilterPrimitive * FilterMorphology::create() { FilterMorphology::~FilterMorphology() {} -int FilterMorphology::render(FilterSlot &slot, Matrix const &trans) { +int FilterMorphology::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); NRPixBlock *out = new NRPixBlock; diff --git a/src/display/nr-filter-morphology.h b/src/display/nr-filter-morphology.h index 7283b0cea..a9435041e 100644 --- a/src/display/nr-filter-morphology.h +++ b/src/display/nr-filter-morphology.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" namespace NR { @@ -29,7 +30,7 @@ public: static FilterPrimitive *create(); virtual ~FilterMorphology(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &trans); virtual FilterTraits get_input_traits(); void set_operator(FilterMorphologyOperator &o); diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index 4facd9436..85df3351f 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -11,6 +11,7 @@ #include "display/nr-filter-offset.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-blit.h" #include "libnr/nr-matrix.h" #include "libnr/nr-pixblock.h" @@ -31,7 +32,7 @@ FilterPrimitive * FilterOffset::create() { FilterOffset::~FilterOffset() {} -int FilterOffset::render(FilterSlot &slot, Matrix const &trans) { +int FilterOffset::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); NRPixBlock *out = new NRPixBlock; @@ -41,6 +42,7 @@ int FilterOffset::render(FilterSlot &slot, Matrix const &trans) { return 1; } + Matrix trans = units.get_matrix_primitiveunits2pb(); Point offset(dx, dy); offset *= trans; offset[X] -= trans[4]; diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h index 7c39b0ecc..ffcdbd744 100644 --- a/src/display/nr-filter-offset.h +++ b/src/display/nr-filter-offset.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" #include "libnr/nr-rect-l.h" @@ -25,7 +26,7 @@ public: static FilterPrimitive *create(); virtual ~FilterOffset(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &trans); void set_dx(double amount); diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index 14f5c0078..6e7e9e6ab 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -36,17 +36,6 @@ FilterPrimitive::~FilterPrimitive() // Nothing to do here } -/** Wrapper function for rendering with C-style matrices. */ -int FilterPrimitive::render(FilterSlot &slot, NRMatrix const *trans) { - if(trans) { - return this->render(slot, *trans); - } else { - Matrix tmp; - tmp.set_identity(); - return this->render(slot, tmp); - } -} - void FilterPrimitive::area_enlarge(NRRectL &area, Matrix const &m) { // This doesn't need to do anything by default diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index e1e5984e6..fba4c6344 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -7,7 +7,7 @@ * Author: * Niko Kiirala * - * Copyright (C) 2006 Niko Kiirala + * Copyright (C) 2006-2007 Niko Kiirala * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -43,8 +43,7 @@ public: FilterPrimitive(); virtual ~FilterPrimitive(); - int render(FilterSlot &slot, NRMatrix const *trans); - virtual int render(FilterSlot &slot, Matrix const &trans) = 0; + virtual int render(FilterSlot &slot, FilterUnits const &units) = 0; virtual void area_enlarge(NRRectL &area, Matrix const &m); /** diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp index 68c38c4b2..70d7a2512 100644 --- a/src/display/nr-filter-skeleton.cpp +++ b/src/display/nr-filter-skeleton.cpp @@ -23,6 +23,7 @@ #include "display/nr-filter-skeleton.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-pixblock.h" #include "libnr/nr-matrix.h" @@ -38,7 +39,7 @@ FilterPrimitive * FilterSkeleton::create() { FilterSkeleton::~FilterSkeleton() {} -int FilterSkeleton::render(FilterSlot &slot, Matrix const &trans) { +int FilterSkeleton::render(FilterSlot &slot, FitlerUnits const &units) { NRPixBlock *in = slot.get(_input); NRPixBlock *out; diff --git a/src/display/nr-filter-skeleton.h b/src/display/nr-filter-skeleton.h index edba5c2f1..b0581593b 100644 --- a/src/display/nr-filter-skeleton.h +++ b/src/display/nr-filter-skeleton.h @@ -26,6 +26,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" namespace NR { @@ -36,7 +37,7 @@ public: static FilterPrimitive *create(); virtual ~FilterSkeleton(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); private: diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index ca8bca6a8..7f24f3ec2 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -18,6 +18,7 @@ #include "display/nr-filter-specularlighting.h" #include "display/nr-filter-getalpha.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include "display/nr-light.h" #include "libnr/nr-blit.h" @@ -58,7 +59,7 @@ do {\ (inter) = (ks) * std::pow(scal, (specularExponent));\ }while(0) -int FilterSpecularLighting::render(FilterSlot &slot, Matrix const &trans) { +int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = filter_get_alpha(slot.get(_input)); NRPixBlock *out = new NRPixBlock; @@ -74,7 +75,7 @@ int FilterSpecularLighting::render(FilterSlot &slot, Matrix const &trans) { int dx = 1; //TODO setup int dy = 1; //TODO setup //surface scale - //TODO for the time being, assumes userSpaceOnUse + Matrix trans = units.get_matrix_primitiveunits2pb(); gdouble ss = surfaceScale * trans[0]; gdouble ks = specularConstant; //diffuse lighting constant Fvector L, N, LC, H; @@ -113,9 +114,9 @@ int FilterSpecularLighting::render(FilterSlot &slot, Matrix const &trans) { PointLight *pl = new PointLight(light.point, lighting_color, trans); pl->light_components(LC); //TODO we need a reference to the filter to determine primitiveUnits - //slot._arena_item->filter seems to be ok on simple examples - //for now assume userSpaceOnUse //if objectBoundingBox is used, use a different matrix for light_vector + // UPDATE: trans is now correct matrix from primitiveUnits to + // pixblock coordinates //finish the work for (i = 0, j = 0; i < w*h; i++) { compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); @@ -139,9 +140,9 @@ int FilterSpecularLighting::render(FilterSlot &slot, Matrix const &trans) { { SpotLight *sl = new SpotLight(light.spot, lighting_color, trans); //TODO we need a reference to the filter to determine primitiveUnits - //slot._arena_item->filter seems to be ok on simple examples - //for now assume userSpaceOnUse //if objectBoundingBox is used, use a different matrix for light_vector + // UPDATE: trans is now correct matrix from primitiveUnits to + // pixblock coordinates //finish the work for (i = 0, j = 0; i < w*h; i++) { compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 578b7ad4a..6de682972 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -17,6 +17,7 @@ #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" #include "sp-fedistantlight.h" #include "sp-fepointlight.h" @@ -41,7 +42,7 @@ public: FilterSpecularLighting(); static FilterPrimitive *create(); virtual ~FilterSpecularLighting(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual FilterTraits get_input_traits(); private: diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index 39e2bff33..01453da39 100644 --- a/src/display/nr-filter-tile.cpp +++ b/src/display/nr-filter-tile.cpp @@ -10,6 +10,8 @@ */ #include "display/nr-filter-tile.h" +#include "display/nr-filter-units.h" + namespace NR { FilterTile::FilterTile() @@ -24,7 +26,7 @@ FilterPrimitive * FilterTile::create() { FilterTile::~FilterTile() {} -int FilterTile::render(FilterSlot &slot, Matrix const &trans) { +int FilterTile::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *in = slot.get(_input); NRPixBlock *out = new NRPixBlock; diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h index 56c26bd66..45d280d39 100644 --- a/src/display/nr-filter-tile.h +++ b/src/display/nr-filter-tile.h @@ -14,6 +14,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" #include "libnr/nr-matrix.h" #include "libnr/nr-rect-l.h" @@ -25,7 +26,7 @@ public: static FilterPrimitive *create(); virtual ~FilterTile(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void area_enlarge(NRRectL &area, Matrix const &trans); virtual FilterTraits get_input_traits(); }; diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index b3938418f..addbbb663 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -12,6 +12,7 @@ #include "display/nr-arena-item.h" #include "display/nr-filter.h" #include "display/nr-filter-turbulence.h" +#include "display/nr-filter-units.h" #include "display/nr-filter-utils.h" #include @@ -106,7 +107,7 @@ void FilterTurbulence::update_pixbuffer(FilterSlot &slot) { updated=true; } -int FilterTurbulence::render(FilterSlot &slot, Matrix const &trans) { +int FilterTurbulence::render(FilterSlot &slot, FilterUnits const &units) { //g_warning("render"); if (!updated) update_pixbuffer(slot); diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index 03c2e22a5..144e3ec4c 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -15,6 +15,7 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include "display/nr-filter-units.h" namespace NR { @@ -57,7 +58,7 @@ public: static FilterPrimitive *create(); virtual ~FilterTurbulence(); - virtual int render(FilterSlot &slot, Matrix const &trans); + virtual int render(FilterSlot &slot, FilterUnits const &units); virtual void update_pixbuffer(FilterSlot &slot); virtual void set_baseFrequency(int axis, double freq); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index 770d9d0a9..84e8180bc 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -196,11 +196,8 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) } in = NULL; // in is now handled by FilterSlot, we should not touch it - // TODO: filters may need both filterUnits and primitiveUnits, - // so we should pass FilterUnits to render method, not just one Matrix - Matrix primitiveunits2pixblock = units.get_matrix_primitiveunits2pb(); for (int i = 0 ; i < _primitive_count ; i++) { - _primitive[i]->render(slot, primitiveunits2pixblock); + _primitive[i]->render(slot, units); } slot.get_final(_output_slot, pb);