diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2009-01-02 12:18:25 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2009-01-02 12:18:25 +0000 |
| commit | ce6f12df4a3f9969f1e42aeaa3cfdd31e0602ae6 (patch) | |
| tree | 301702c746a4de6dbd5f9eff52b90256c9f2ba9c /src/display | |
| parent | reorder LPE list (diff) | |
| download | inkscape-ce6f12df4a3f9969f1e42aeaa3cfdd31e0602ae6.tar.gz inkscape-ce6f12df4a3f9969f1e42aeaa3cfdd31e0602ae6.zip | |
Move filters into their own namespace Inkscape::Filters (from NR::)
(bzr r7058)
Diffstat (limited to 'src/display')
59 files changed, 325 insertions, 215 deletions
diff --git a/src/display/nr-3dutils.cpp b/src/display/nr-3dutils.cpp index ffeaebe8e..dd1419f2b 100644 --- a/src/display/nr-3dutils.cpp +++ b/src/display/nr-3dutils.cpp @@ -136,11 +136,11 @@ void compute_surface_normal(Fvector &N, gdouble ss, NRPixBlock *in, int i, int j //std::cout << "(" << N[X_3D] << ", " << N[Y_3D] << ", " << N[Z_3D] << ")" << std::endl; } -void convert_coord(gdouble &x, gdouble &y, gdouble &z, Matrix const &trans) { +void convert_coord(gdouble &x, gdouble &y, gdouble &z, Geom::Matrix const &trans) { Point p = Point(x, y); p *= trans; - x = p[X]; - y = p[Y]; + x = p[Geom::X]; + y = p[Geom::Y]; z *= trans[0]; } diff --git a/src/display/nr-3dutils.h b/src/display/nr-3dutils.h index 4baa9cc86..dbbc7c9a4 100644 --- a/src/display/nr-3dutils.h +++ b/src/display/nr-3dutils.h @@ -4,6 +4,7 @@ /* * 3D utils. Definition of gdouble vectors of dimension 3 and of some basic * functions. + * This looks redundant, why not just use Geom::Point for this? * * Authors: * Jean-Rene Reinhard <jr@komite.net> @@ -14,13 +15,12 @@ */ #include <gdk/gdktypes.h> +#include <2geom/forward.h> struct NRPixBlock; namespace NR { -struct Matrix; - #define X_3D 0 #define Y_3D 1 #define Z_3D 2 @@ -94,7 +94,7 @@ void compute_surface_normal(Fvector &N, gdouble ss, NRPixBlock *in, int i, int j * \param z a reference to a z coordinate * \param z a reference to a transformation matrix */ -void convert_coord(gdouble &x, gdouble &y, gdouble &z, Matrix const &trans); +void convert_coord(gdouble &x, gdouble &y, gdouble &z, Geom::Matrix const &trans); } /* namespace NR */ diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index 7692cbf15..d73a0ecbf 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -201,7 +201,7 @@ void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style) if (style->filter.set && style->getFilter()) { if (!group->filter) { int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); - group->filter = new NR::Filter(primitives); + group->filter = new Inkscape::Filters::Filter(primitives); } sp_filter_build_renderer(SP_FILTER(style->getFilter()), group->filter); } else { diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index 147513f6b..da2f5ce7e 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -369,7 +369,7 @@ void nr_arena_image_set_style (NRArenaImage *image, SPStyle *style) if (style->filter.set && style->getFilter()) { if (!image->filter) { int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); - image->filter = new NR::Filter(primitives); + image->filter = new Inkscape::Filters::Filter(primitives); } sp_filter_build_renderer(SP_FILTER(style->getFilter()), image->filter); } else { diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 22c15daef..17a223b31 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -99,7 +99,7 @@ struct NRArenaItem : public NRObject { /* Mask item */ NRArenaItem *mask; /* Filter to be applied after rendering this object, NULL if none */ - NR::Filter *filter; + Inkscape::Filters::Filter *filter; /* Rendered buffer */ unsigned char *px; diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 906d9166c..aafdc37d6 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -1336,7 +1336,7 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) if (style->filter.set && style->getFilter()) { if (!shape->filter) { int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter())); - shape->filter = new NR::Filter(primitives); + shape->filter = new Inkscape::Filters::Filter(primitives); } sp_filter_build_renderer(SP_FILTER(style->getFilter()), shape->filter); } else { diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp index 2544d8bfb..2a066b563 100644 --- a/src/display/nr-filter-blend.cpp +++ b/src/display/nr-filter-blend.cpp @@ -24,7 +24,8 @@ #include "libnr/nr-blit.h" #include "libnr/nr-pixops.h" -namespace NR { +namespace Inkscape { +namespace Filters { /* * From http://www.w3.org/TR/SVG11/filters.html#feBlend @@ -218,7 +219,8 @@ void FilterBlend::set_mode(FilterBlendMode mode) { } } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index 3e3bf71b2..ffdd62118 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -21,7 +21,8 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -namespace NR { +namespace Inkscape { +namespace Filters { enum FilterBlendMode { BLEND_NORMAL, @@ -50,7 +51,8 @@ private: }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ diff --git a/src/display/nr-filter-colormatrix.cpp b/src/display/nr-filter-colormatrix.cpp index f619e2685..e5dc3fb20 100644 --- a/src/display/nr-filter-colormatrix.cpp +++ b/src/display/nr-filter-colormatrix.cpp @@ -16,7 +16,8 @@ #include "libnr/nr-blit.h" #include <math.h> -namespace NR { +namespace Inkscape { +namespace Filters { FilterColorMatrix::FilterColorMatrix() { @@ -210,7 +211,8 @@ void FilterColorMatrix::set_values(std::vector<gdouble> &v){ values = v; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index 85d2ab758..1c331a5b0 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -17,7 +17,8 @@ #include "display/nr-filter-units.h" #include<vector> -namespace NR { +namespace Inkscape { +namespace Filters { enum FilterColorMatrixType { COLORMATRIX_MATRIX, @@ -44,7 +45,8 @@ private: FilterColorMatrixType type; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_COLOR_MATRIX_H__ */ /* diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp index caf053bcf..74d66fbe4 100644 --- a/src/display/nr-filter-component-transfer.cpp +++ b/src/display/nr-filter-component-transfer.cpp @@ -18,7 +18,8 @@ #include "libnr/nr-pixops.h" #include <math.h> -namespace NR { +namespace Inkscape { +namespace Filters { FilterComponentTransfer::FilterComponentTransfer() { @@ -157,7 +158,8 @@ void FilterComponentTransfer::area_enlarge(NRRectL &/*area*/, Geom::Matrix const { } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h index 3a7c015cb..3d8be272e 100644 --- a/src/display/nr-filter-component-transfer.h +++ b/src/display/nr-filter-component-transfer.h @@ -17,7 +17,8 @@ #include "display/nr-filter-units.h" #include <vector> -namespace NR { +namespace Inkscape { +namespace Filters { enum FilterComponentTransferType { COMPONENTTRANSFER_TYPE_IDENTITY, @@ -46,7 +47,8 @@ public: double offset[4]; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_COMPONENT_TRANSFER_H__ */ /* diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index 568c093b9..34a2d2e63 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -73,21 +73,23 @@ static int arith_k1, arith_k2, arith_k3, arith_k4; inline void composite_arithmetic(unsigned char *r, unsigned char const *a, unsigned char const *b) { - r[0] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[0] * b[0] + using Inkscape::Filters::clamp3; + r[0] = NR_NORMALIZE_31(clamp3(arith_k1 * a[0] * b[0] + arith_k2 * a[0] + arith_k3 * b[0] + arith_k4)); - r[1] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[1] * b[1] + r[1] = NR_NORMALIZE_31(clamp3(arith_k1 * a[1] * b[1] + arith_k2 * a[1] + arith_k3 * b[1] + arith_k4)); - r[2] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[2] * b[2] + r[2] = NR_NORMALIZE_31(clamp3(arith_k1 * a[2] * b[2] + arith_k2 * a[2] + arith_k3 * b[2] + arith_k4)); - r[3] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[3] * b[3] + r[3] = NR_NORMALIZE_31(clamp3(arith_k1 * a[3] * b[3] + arith_k2 * a[3] + arith_k3 * b[3] + arith_k4)); } -namespace NR { +namespace Inkscape { +namespace Filters { FilterComposite::FilterComposite() : op(COMPOSITE_DEFAULT), k1(0), k2(0), k3(0), k4(0), - _input2(NR::NR_FILTER_SLOT_NOT_SET) + _input2(Inkscape::Filters::NR_FILTER_SLOT_NOT_SET) {} FilterPrimitive * FilterComposite::create() { @@ -216,7 +218,8 @@ void FilterComposite::set_arithmetic(double k1, double k2, double k3, double k4) this->k4 = k4; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-composite.h b/src/display/nr-filter-composite.h index d467213f0..b24666531 100644 --- a/src/display/nr-filter-composite.h +++ b/src/display/nr-filter-composite.h @@ -17,7 +17,8 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterComposite : public FilterPrimitive { public: @@ -39,7 +40,8 @@ private: int _input2; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_COMPOSITE_H__ */ /* diff --git a/src/display/nr-filter-convolve-matrix.cpp b/src/display/nr-filter-convolve-matrix.cpp index e29283cf1..3fca952da 100644 --- a/src/display/nr-filter-convolve-matrix.cpp +++ b/src/display/nr-filter-convolve-matrix.cpp @@ -14,7 +14,8 @@ #include "display/nr-filter-utils.h" #include <vector> -namespace NR { +namespace Inkscape { +namespace Filters { FilterConvolveMatrix::FilterConvolveMatrix() {} @@ -144,7 +145,8 @@ FilterTraits FilterConvolveMatrix::get_input_traits() { return TRAIT_PARALLER; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index 8414b60c1..d7a04a766 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -18,7 +18,8 @@ #include "libnr/nr-rect-l.h" #include <vector> -namespace NR { +namespace Inkscape { +namespace Filters { enum FilterConvolveMatrixEdgeMode { CONVOLVEMATRIX_EDGEMODE_DUPLICATE, @@ -57,7 +58,8 @@ private: bool preserveAlpha; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_CONVOLVE_MATRIX_H__ */ /* diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp index 77879cd89..9ae231d39 100644 --- a/src/display/nr-filter-diffuselighting.cpp +++ b/src/display/nr-filter-diffuselighting.cpp @@ -25,7 +25,8 @@ #include "libnr/nr-rect-l.h" #include "color.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterDiffuseLighting::FilterDiffuseLighting() { @@ -44,7 +45,7 @@ FilterDiffuseLighting::~FilterDiffuseLighting() #define COMPUTE_INTER(inter, N, L, kd) \ do {\ - (inter) = (kd) * scalar_product((N), (L)); \ + (inter) = (kd) * NR::scalar_product((N), (L)); \ if ((inter) < 0) (inter) = 0; \ }while(0) @@ -68,11 +69,11 @@ int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) { int dx = 1; //TODO setup int dy = 1; //TODO setup //surface scale - Matrix trans = units.get_matrix_primitiveunits2pb(); + Geom::Matrix trans = units.get_matrix_primitiveunits2pb(); gdouble ss = surfaceScale * trans[0]; gdouble kd = diffuseConstant; //diffuse lighting constant - Fvector L, N, LC; + NR::Fvector L, N, LC; gdouble inter; nr_pixblock_setup_fast(out, in->mode, @@ -90,7 +91,7 @@ int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) { dl->light_components(LC); //finish the work for (i = 0, j = 0; i < w*h; i++) { - compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); + NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); COMPUTE_INTER(inter, N, L, kd); data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); @@ -112,7 +113,7 @@ int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) { // 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); + NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); pl->light_vector(L, i % w + x0, i / w + y0, @@ -137,7 +138,7 @@ int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) { // 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); + NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); sl->light_vector(L, i % w + x0, i / w + y0, @@ -178,7 +179,8 @@ FilterTraits FilterDiffuseLighting::get_input_traits() { return TRAIT_PARALLER; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 36ed8835b..a1c6964cb 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -23,7 +23,8 @@ #include "filters/spotlight.h" #include "color.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterDiffuseLighting : public FilterPrimitive { public: @@ -46,7 +47,8 @@ public: private: }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_DIFFUSELIGHTING_H__ */ /* diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 928745f31..39e921a38 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -15,7 +15,8 @@ #include "libnr/nr-blit.h" #include "libnr/nr-pixops.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterDisplacementMap::FilterDisplacementMap() {} @@ -159,7 +160,8 @@ FilterTraits FilterDisplacementMap::get_input_traits() { return TRAIT_PARALLER; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index f30c5a8a9..2a7b0f195 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -18,7 +18,8 @@ #include "display/nr-filter-units.h" #include "libnr/nr-rect-l.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterDisplacementMap : public FilterPrimitive { public: @@ -42,7 +43,8 @@ private: int out_x0, out_y0, out_w, out_h; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_DISPLACEMENT_MAP_H__ */ /* diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp index 8e9b51039..026cbce16 100644 --- a/src/display/nr-filter-flood.cpp +++ b/src/display/nr-filter-flood.cpp @@ -12,7 +12,8 @@ #include "display/nr-filter-flood.h" #include "display/nr-filter-utils.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterFlood::FilterFlood() {} @@ -73,7 +74,8 @@ void FilterFlood::area_enlarge(NRRectL &/*area*/, Geom::Matrix const &/*trans*/) { } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index cd9269913..9e6a53abb 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -16,7 +16,8 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterFlood : public FilterPrimitive { public: @@ -33,7 +34,8 @@ private: guint32 color; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_FLOOD_H__ */ /* diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 4e4c3ee63..5d071be8c 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -90,7 +90,8 @@ static inline Tt clip_round_cast(Ts const& v, Tt const minval=std::numeric_limit return round_cast<Tt>(v); } -namespace NR { +namespace Inkscape { +namespace Filters { FilterGaussian::FilterGaussian() { @@ -872,7 +873,8 @@ void FilterGaussian::set_deviation(double x, double y) } } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index 1242a0961..763e42de2 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -29,7 +29,8 @@ enum { BLUR_QUALITY_WORST = -2 }; -namespace NR { +namespace Inkscape { +namespace Filters { class FilterGaussian : public FilterPrimitive { public: @@ -64,7 +65,8 @@ private: }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ diff --git a/src/display/nr-filter-getalpha.cpp b/src/display/nr-filter-getalpha.cpp index 72c05c797..0b71e28c8 100644 --- a/src/display/nr-filter-getalpha.cpp +++ b/src/display/nr-filter-getalpha.cpp @@ -13,7 +13,8 @@ #include "libnr/nr-blit.h" #include "libnr/nr-pixblock.h" -namespace NR { +namespace Inkscape { +namespace Filters { NRPixBlock *filter_get_alpha(NRPixBlock *src) { @@ -40,7 +41,8 @@ NRPixBlock *filter_get_alpha(NRPixBlock *src) return dst; } -} // namespace NR +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-getalpha.h b/src/display/nr-filter-getalpha.h index cfbca0bc1..fca645776 100644 --- a/src/display/nr-filter-getalpha.h +++ b/src/display/nr-filter-getalpha.h @@ -14,11 +14,13 @@ #include "libnr/nr-pixblock.h" -namespace NR { +namespace Inkscape { +namespace Filters { NRPixBlock *filter_get_alpha(NRPixBlock *src); -} +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_GETALPHA_H__ */ /* diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index da8fe0ac4..986b6502d 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -18,7 +18,8 @@ #include "display/nr-filter-units.h" #include "libnr/nr-rect-l.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterImage::FilterImage() { @@ -57,11 +58,8 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { } pb = new NRPixBlock; free_pb_on_exit = true; - - Matrix identity(1.0, 0.0, - 0.0, 1.0, - 0.0, 0.0); - Geom::OptRect area = SVGElem->getBounds(identity); + + Geom::OptRect area = SVGElem->getBounds(Geom::identity()); NRRectL rect; rect.x0=area->min()[Geom::X]; @@ -148,7 +146,7 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { // Get the object bounding box. Image is placed with respect to box. // Array values: 0: width; 3: height; 4: -x; 5: -y. - Matrix object_bbox = units.get_matrix_user2filterunits().inverse(); + Geom::Matrix object_bbox = units.get_matrix_user2filterunits().inverse(); // feImage is suppose to use the same parameters as a normal SVG image. // If a width or height is set to zero, the image is not suppose to be displayed. @@ -163,7 +161,7 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { int coordx,coordy; unsigned char *out_data = NR_PIXBLOCK_PX(out); - Matrix unit_trans = units.get_matrix_primitiveunits2pb().inverse(); + Geom::Matrix unit_trans = units.get_matrix_primitiveunits2pb().inverse(); for (x=x0; x < x1; x++){ for (y=y0; y < y1; y++){ //TODO: use interpolation @@ -217,7 +215,8 @@ FilterTraits FilterImage::get_input_traits() { return TRAIT_PARALLER; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index 42e7f089a..f7f0fe590 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -18,7 +18,8 @@ #include <gtkmm.h> #include "sp-item.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterImage : public FilterPrimitive { public: @@ -43,7 +44,8 @@ private: float feImageX,feImageY,feImageWidth,feImageHeight; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_IMAGE_H__ */ /* diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index 380884223..b913e2cd7 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -32,7 +32,8 @@ composite_over(unsigned char *r, unsigned char const *a, unsigned char const *b) r[3] = a[3] + NR_NORMALIZE_21(b[3] * (255 - a[3])); } -namespace NR { +namespace Inkscape { +namespace Filters { FilterMerge::FilterMerge() : _input_image(1, NR_FILTER_SLOT_NOT_SET) @@ -128,7 +129,8 @@ void FilterMerge::set_input(int input, int slot) { } } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-merge.h b/src/display/nr-filter-merge.h index 14c16a27a..b7737e347 100644 --- a/src/display/nr-filter-merge.h +++ b/src/display/nr-filter-merge.h @@ -19,7 +19,8 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterMerge : public FilterPrimitive { public: @@ -36,7 +37,8 @@ private: std::vector<int> _input_image; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_MERGE_H__ */ /* diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp index b1c790442..fb51099d5 100644 --- a/src/display/nr-filter-morphology.cpp +++ b/src/display/nr-filter-morphology.cpp @@ -13,7 +13,8 @@ #include "display/nr-filter-units.h" #include "libnr/nr-blit.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterMorphology::FilterMorphology() { @@ -137,7 +138,8 @@ FilterTraits FilterMorphology::get_input_traits() { return TRAIT_PARALLER; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-morphology.h b/src/display/nr-filter-morphology.h index b598a4208..1d3e16be3 100644 --- a/src/display/nr-filter-morphology.h +++ b/src/display/nr-filter-morphology.h @@ -16,7 +16,8 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -namespace NR { +namespace Inkscape { +namespace Filters { enum FilterMorphologyOperator { MORPHOLOGY_OPERATOR_ERODE, @@ -43,7 +44,8 @@ private: double yradius; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_MORPHOLOGY_H__ */ /* diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index ecfa40fa2..fd4f55053 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -16,7 +16,11 @@ #include "libnr/nr-pixblock.h" #include "libnr/nr-rect-l.h" -namespace NR { +namespace Inkscape { +namespace Filters { + +using Geom::X; +using Geom::Y; FilterOffset::FilterOffset() : dx(0), dy(0) @@ -39,8 +43,8 @@ int FilterOffset::render(FilterSlot &slot, FilterUnits const &units) { NRPixBlock *out = new NRPixBlock; - Matrix trans = units.get_matrix_primitiveunits2pb(); - Point offset(dx, dy); + Geom::Matrix trans = units.get_matrix_primitiveunits2pb(); + Geom::Point offset(dx, dy); offset *= trans; offset[X] -= trans[4]; offset[Y] -= trans[5]; @@ -72,7 +76,7 @@ void FilterOffset::set_dy(double amount) { void FilterOffset::area_enlarge(NRRectL &area, Geom::Matrix const &trans) { - Point offset(dx, dy); + Geom::Point offset(dx, dy); offset *= trans; offset[X] -= trans[4]; offset[Y] -= trans[5]; @@ -90,7 +94,8 @@ void FilterOffset::area_enlarge(NRRectL &area, Geom::Matrix const &trans) } } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h index 166fba247..b00ad25fe 100644 --- a/src/display/nr-filter-offset.h +++ b/src/display/nr-filter-offset.h @@ -17,7 +17,8 @@ #include "display/nr-filter-units.h" #include "libnr/nr-rect-l.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterOffset : public FilterPrimitive { public: @@ -35,7 +36,8 @@ private: double dx, dy; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_OFFSET_H__ */ /* diff --git a/src/display/nr-filter-pixops.h b/src/display/nr-filter-pixops.h index 8d7c31662..b2db7067a 100644 --- a/src/display/nr-filter-pixops.h +++ b/src/display/nr-filter-pixops.h @@ -16,7 +16,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -namespace NR { +namespace Inkscape { +namespace Filters { /** * Mixes the two input images using the function given as template. @@ -135,7 +136,8 @@ void pixops_mix(NRPixBlock &out, NRPixBlock &in1, NRPixBlock &in2) { } } -} // namespace NR +} /* namespace Filters */ +} /* namespace Inkscape */ #endif // __NR_FILTER_PIXOPS_H_ /* diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp index eb4583b6e..b70ae57fe 100644 --- a/src/display/nr-filter-primitive.cpp +++ b/src/display/nr-filter-primitive.cpp @@ -16,7 +16,8 @@ #include "libnr/nr-pixblock.h" #include "svg/svg-length.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterPrimitive::FilterPrimitive() { @@ -57,7 +58,8 @@ FilterTraits FilterPrimitive::get_input_traits() { return TRAIT_ANYTHING; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index 6d0f5433b..74b41211b 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -17,7 +17,8 @@ #include "libnr/nr-rect-l.h" #include "svg/svg-length.h" -namespace NR { +namespace Inkscape { +namespace Filters { /* * Different filter effects need different types of inputs. This is what @@ -118,7 +119,8 @@ protected: }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp index 384baa2c5..bdb993ed9 100644 --- a/src/display/nr-filter-skeleton.cpp +++ b/src/display/nr-filter-skeleton.cpp @@ -26,7 +26,8 @@ #include "display/nr-filter-units.h" #include "libnr/nr-pixblock.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterSkeleton::FilterSkeleton() {} @@ -51,7 +52,8 @@ int FilterSkeleton::render(FilterSlot &slot, return 0; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-skeleton.h b/src/display/nr-filter-skeleton.h index c2e595f9c..dc69c95ed 100644 --- a/src/display/nr-filter-skeleton.h +++ b/src/display/nr-filter-skeleton.h @@ -28,7 +28,8 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterSkeleton : public FilterPrimitive { public: @@ -42,7 +43,8 @@ private: }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_SKELETON_H__ */ /* diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 5d470df15..dc4de5bd3 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -60,7 +60,8 @@ inline static int _min2(const double a, const double b) { return (int)round(a); } -namespace NR { +namespace Inkscape { +namespace Filters { FilterSlot::FilterSlot(int slots, NRArenaItem const *item) : _last_out(-1), @@ -152,7 +153,7 @@ NRPixBlock *FilterSlot::get(int slot_nr) void FilterSlot::get_final(int slot_nr, NRPixBlock *result) { NRPixBlock *final_usr = get(slot_nr); - Matrix trans = units.get_matrix_pb2display(); + Geom::Matrix trans = units.get_matrix_pb2display(); int size = (result->area.x1 - result->area.x0) * (result->area.y1 - result->area.y0) @@ -161,12 +162,12 @@ void FilterSlot::get_final(int slot_nr, NRPixBlock *result) { if (fabs(trans[1]) > 1e-6 || fabs(trans[2]) > 1e-6) { if (filterquality == FILTER_QUALITY_BEST) { - transform_bicubic(result, final_usr, trans); + NR::transform_bicubic(result, final_usr, trans); } else { - transform_nearest(result, final_usr, trans); + NR::transform_nearest(result, final_usr, trans); } } else if (fabs(trans[0] - 1) > 1e-6 || fabs(trans[3] - 1) > 1e-6) { - scale_bicubic(result, final_usr); + NR::scale_bicubic(result, final_usr); } else { nr_blit_pixblock_pixblock(result, final_usr); } @@ -184,12 +185,12 @@ void FilterSlot::set(int slot_nr, NRPixBlock *pb) ? _get_index(slot_nr) : _get_index(NR_FILTER_UNNAMED_SLOT)); assert(index >= 0); - // Unnamed slot is only for NR::FilterSlot internal use. + // Unnamed slot is only for Inkscape::Filters::FilterSlot internal use. assert(slot_nr != NR_FILTER_UNNAMED_SLOT); assert(slot_nr == NR_FILTER_SLOT_NOT_SET ||_slot_number[index] == slot_nr); if (slot_nr == NR_FILTER_SOURCEGRAPHIC || slot_nr == NR_FILTER_BACKGROUNDIMAGE) { - Matrix trans = units.get_matrix_display2pb(); + Geom::Matrix trans = units.get_matrix_display2pb(); if (fabs(trans[1]) > 1e-6 || fabs(trans[2]) > 1e-6) { NRPixBlock *trans_pb = new NRPixBlock; int x0 = pb->area.x0; @@ -221,13 +222,13 @@ void FilterSlot::set(int slot_nr, NRPixBlock *pb) * images are exported in horizontal stripes. One stripe * is not too high, but can get thousands of pixels wide. * Rotate this 45 degrees -> _huge_ image */ - g_warning("Memory allocation failed in NR::FilterSlot::set (transform)"); + g_warning("Memory allocation failed in Inkscape::Filters::FilterSlot::set (transform)"); return; } if (filterquality == FILTER_QUALITY_BEST) { - transform_bicubic(trans_pb, pb, trans); + NR::transform_bicubic(trans_pb, pb, trans); } else { - transform_nearest(trans_pb, pb, trans); + NR::transform_nearest(trans_pb, pb, trans); } nr_pixblock_release(pb); delete pb; @@ -251,10 +252,10 @@ void FilterSlot::set(int slot_nr, NRPixBlock *pb) nr_pixblock_setup_fast(trans_pb, pb->mode, min_x, min_y, max_x, max_y, true); if (trans_pb->size != NR_PIXBLOCK_SIZE_TINY && trans_pb->data.px == NULL) { - g_warning("Memory allocation failed in NR::FilterSlot::set (scaling)"); + g_warning("Memory allocation failed in Inkscape::Filters::FilterSlot::set (scaling)"); return; } - scale_bicubic(trans_pb, pb); + NR::scale_bicubic(trans_pb, pb); nr_pixblock_release(pb); delete pb; pb = trans_pb; @@ -347,7 +348,8 @@ void FilterSlot::set_quality(FilterQuality const q) { filterquality = q; } -} +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index b566be10e..bddb42dc3 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -20,7 +20,8 @@ struct NRArenaItem; -namespace NR { +namespace Inkscape { +namespace Filters { class FilterSlot { public: @@ -95,7 +96,8 @@ private: int _get_index(int slot); }; -} +} /* namespace Filters */ +} /* namespace Inkscape */ #endif // __NR_FILTER_SLOT_H__ /* diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index c6c81700c..526f49ec8 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -26,7 +26,8 @@ #include "libnr/nr-rect-l.h" #include "color.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterSpecularLighting::FilterSpecularLighting() { @@ -51,7 +52,7 @@ FilterSpecularLighting::~FilterSpecularLighting() //to get the expected formula #define COMPUTE_INTER(inter, H, N, ks, speculaExponent) \ do {\ - gdouble scal = scalar_product((N), (H)); \ + gdouble scal = NR::scalar_product((N), (H)); \ if (scal <= 0)\ (inter) = 0;\ else\ @@ -79,10 +80,10 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { int dx = 1; //TODO setup int dy = 1; //TODO setup //surface scale - Matrix trans = units.get_matrix_primitiveunits2pb(); + Geom::Matrix trans = units.get_matrix_primitiveunits2pb(); gdouble ss = surfaceScale * trans[0]; gdouble ks = specularConstant; //diffuse lighting constant - Fvector L, N, LC, H; + NR::Fvector L, N, LC, H; gdouble inter; nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N, @@ -98,10 +99,10 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { DistantLight *dl = new DistantLight(light.distant, lighting_color); dl->light_vector(L); dl->light_components(LC); - normalized_sum(H, L, EYE_VECTOR); + NR::normalized_sum(H, L, NR::EYE_VECTOR); //finish the work for (i = 0, j = 0; i < w*h; i++) { - compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); + NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); COMPUTE_INTER(inter, N, H, ks, specularExponent); data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); @@ -124,12 +125,12 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { // 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); + NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); pl->light_vector(L, i % w + x0, i / w + y0, ss * (double) data_i[4*i+3]/ 255); - normalized_sum(H, L, EYE_VECTOR); + NR::normalized_sum(H, L, NR::EYE_VECTOR); COMPUTE_INTER(inter, N, H, ks, specularExponent); data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); @@ -151,13 +152,13 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) { // 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); + NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy); sl->light_vector(L, i % w + x0, i / w + y0, ss * (double) data_i[4*i+3]/ 255); sl->light_components(LC, L); - normalized_sum(H, L, EYE_VECTOR); + NR::normalized_sum(H, L, NR::EYE_VECTOR); COMPUTE_INTER(inter, N, H, ks, specularExponent); data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]); @@ -191,7 +192,8 @@ FilterTraits FilterSpecularLighting::get_input_traits() { return TRAIT_PARALLER; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 38f2dfc22..e141f8f1f 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -23,7 +23,8 @@ #include "filters/spotlight.h" #include "color.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterSpecularLighting : public FilterPrimitive { public: @@ -47,7 +48,8 @@ public: private: }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_SPECULARLIGHTING_H__ */ /* diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index 7fa8ac06c..53399eba2 100644 --- a/src/display/nr-filter-tile.cpp +++ b/src/display/nr-filter-tile.cpp @@ -12,7 +12,8 @@ #include "display/nr-filter-tile.h" #include "display/nr-filter-units.h" -namespace NR { +namespace Inkscape { +namespace Filters { FilterTile::FilterTile() { @@ -60,7 +61,8 @@ FilterTraits FilterTile::get_input_traits() { return TRAIT_PARALLER; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h index ecdae91f4..ea826dfd7 100644 --- a/src/display/nr-filter-tile.h +++ b/src/display/nr-filter-tile.h @@ -17,7 +17,8 @@ #include "display/nr-filter-units.h" #include "libnr/nr-rect-l.h" -namespace NR { +namespace Inkscape { +namespace Filters { class FilterTile : public FilterPrimitive { public: @@ -30,7 +31,8 @@ public: virtual FilterTraits get_input_traits(); }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_TILE_H__ */ /* diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index 1a3a8d1f1..1336e5f79 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -26,7 +26,8 @@ #include "libnr/nr-blit.h" #include <math.h> -namespace NR { +namespace Inkscape { +namespace Filters{ FilterTurbulence::FilterTurbulence() : XbaseFrequency(0), @@ -34,7 +35,7 @@ FilterTurbulence::FilterTurbulence() numOctaves(1), seed(0), updated(false), - updated_area(IPoint(), IPoint()), + updated_area(NR::IPoint(), NR::IPoint()), pix(NULL), fTileWidth(10), //guessed fTileHeight(10), //guessed @@ -80,13 +81,13 @@ void FilterTurbulence::set_updated(bool u){ updated=u; } -void FilterTurbulence::render_area(NRPixBlock *pix, IRect &full_area, FilterUnits const &units) { - const int bbox_x0 = full_area.min()[X]; - const int bbox_y0 = full_area.min()[Y]; - const int bbox_x1 = full_area.max()[X]; - const int bbox_y1 = full_area.max()[Y]; +void FilterTurbulence::render_area(NRPixBlock *pix, NR::IRect &full_area, FilterUnits const &units) { + const int bbox_x0 = full_area.min()[NR::X]; + const int bbox_y0 = full_area.min()[NR::Y]; + const int bbox_x1 = full_area.max()[NR::X]; + const int bbox_y1 = full_area.max()[NR::Y]; - Matrix unit_trans = units.get_matrix_primitiveunits2pb().inverse(); + Geom::Matrix unit_trans = units.get_matrix_primitiveunits2pb().inverse(); double point[2]; @@ -123,11 +124,11 @@ void FilterTurbulence::render_area(NRPixBlock *pix, IRect &full_area, FilterUnit pix->empty = FALSE; } -void FilterTurbulence::update_pixbuffer(IRect &area, FilterUnits const &units) { - int bbox_x0 = area.min()[X]; - int bbox_y0 = area.min()[Y]; - int bbox_x1 = area.max()[X]; - int bbox_y1 = area.max()[Y]; +void FilterTurbulence::update_pixbuffer(NR::IRect &area, FilterUnits const &units) { + int bbox_x0 = area.min()[NR::X]; + int bbox_y0 = area.min()[NR::Y]; + int bbox_x1 = area.max()[NR::X]; + int bbox_y1 = area.max()[NR::Y]; TurbulenceInit((long)seed); @@ -162,7 +163,7 @@ void FilterTurbulence::update_pixbuffer(IRect &area, FilterUnits const &units) { } int FilterTurbulence::render(FilterSlot &slot, FilterUnits const &units) { - IRect area = units.get_pixblock_filterarea_paraller(); + NR::IRect area = units.get_pixblock_filterarea_paraller(); // TODO: could be faster - updated_area only has to be same size as area if (!updated || updated_area != area) update_pixbuffer(area, units); @@ -350,7 +351,8 @@ FilterTraits FilterTurbulence::get_input_traits() { return TRAIT_PARALLER; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index d0f345360..b12e6395a 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -26,7 +26,8 @@ #include "display/nr-filter-units.h" #include "libnr/nr-rect-l.h" -namespace NR { +namespace Inkscape { +namespace Filters { enum FilterTurbulenceType { TURBULENCE_FRACTALNOISE, @@ -68,8 +69,8 @@ public: virtual ~FilterTurbulence(); virtual int render(FilterSlot &slot, FilterUnits const &units); - void update_pixbuffer(IRect &area, FilterUnits const &units); - void render_area(NRPixBlock *pix, IRect &full_area, FilterUnits const &units); + void update_pixbuffer(NR::IRect &area, FilterUnits const &units); + void render_area(NRPixBlock *pix, NR::IRect &full_area, FilterUnits const &units); void set_baseFrequency(int axis, double freq); void set_numOctaves(int num); @@ -92,7 +93,7 @@ private: bool stitchTiles; FilterTurbulenceType type; bool updated; - IRect updated_area; + NR::IRect updated_area; NRPixBlock *pix; unsigned char *pix_data; @@ -106,7 +107,8 @@ private: double fTileY; }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_TURBULENCE_H__ */ /* diff --git a/src/display/nr-filter-types.h b/src/display/nr-filter-types.h index a54bfa670..595606d49 100644 --- a/src/display/nr-filter-types.h +++ b/src/display/nr-filter-types.h @@ -1,7 +1,8 @@ #ifndef __NR_FILTER_TYPES_H__ #define __NR_FILTER_TYPES_H__ -namespace NR { +namespace Inkscape { +namespace Filters { enum FilterPrimitiveType { NR_FILTER_BLEND, @@ -34,8 +35,8 @@ enum FilterSlotType { NR_FILTER_STROKEPAINT = -7, NR_FILTER_UNNAMED_SLOT = -8 }; -/* Unnamed slot is for NR::FilterSlot internal use. Passing it as - * parameter to NR::FilterSlot accessors may have unforeseen consequences. */ +/* Unnamed slot is for Inkscape::Filters::FilterSlot internal use. Passing it as + * parameter to Inkscape::Filters::FilterSlot accessors may have unforeseen consequences. */ enum FilterQuality { FILTER_QUALITY_BEST = 2, @@ -45,7 +46,8 @@ enum FilterQuality { FILTER_QUALITY_WORST = -2 }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif // __NR_FILTER_TYPES_H__ /* diff --git a/src/display/nr-filter-units.cpp b/src/display/nr-filter-units.cpp index eafe1423f..6a7de1fed 100644 --- a/src/display/nr-filter-units.cpp +++ b/src/display/nr-filter-units.cpp @@ -16,7 +16,11 @@ #include "sp-filter-units.h" #include <2geom/transforms.h> -namespace NR { +using Geom::X; +using Geom::Y; + +namespace Inkscape { +namespace Filters { FilterUnits::FilterUnits() : filterUnits(SP_FILTER_UNITS_OBJECTBOUNDINGBOX), @@ -101,7 +105,7 @@ Geom::Matrix FilterUnits::get_matrix_units2pb(SPFilterUnits units) const { } else if (units == SP_FILTER_UNITS_USERSPACEONUSE) { return get_matrix_user2pb(); } else { - g_warning("Error in NR::FilterUnits::get_matrix_units2pb: unrecognized unit type (%d)", units); + g_warning("Error in Inkscape::Filters::FilterUnits::get_matrix_units2pb: unrecognized unit type (%d)", units); return Geom::Matrix(); } } @@ -130,8 +134,8 @@ Geom::Matrix FilterUnits::get_matrix_user2units(SPFilterUnits units) const { if (item_bbox && units == SP_FILTER_UNITS_OBJECTBOUNDINGBOX) { /* No need to worry about rotations: bounding box coordinates * always have base vectors paraller with userspace coordinates */ - Point min(item_bbox->min()); - Point max(item_bbox->max()); + Geom::Point min(item_bbox->min()); + Geom::Point max(item_bbox->max()); double scale_x = 1.0 / (max[X] - min[X]); double scale_y = 1.0 / (max[Y] - min[Y]); //return Geom::Translate(min) * Geom::Scale(scale_x,scale_y); ? @@ -141,7 +145,7 @@ Geom::Matrix FilterUnits::get_matrix_user2units(SPFilterUnits units) const { } else if (units == SP_FILTER_UNITS_USERSPACEONUSE) { return Geom::identity(); } else { - g_warning("Error in NR::FilterUnits::get_matrix_user2units: unrecognized unit type (%d)", units); + g_warning("Error in Inkscape::Filters::FilterUnits::get_matrix_user2units: unrecognized unit type (%d)", units); return Geom::Matrix(); } } @@ -154,7 +158,7 @@ Geom::Matrix FilterUnits::get_matrix_user2primitiveunits() const { return get_matrix_user2units(primitiveUnits); } -IRect FilterUnits::get_pixblock_filterarea_paraller() const { +NR::IRect FilterUnits::get_pixblock_filterarea_paraller() const { g_assert(filter_area); int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN; @@ -168,7 +172,7 @@ IRect FilterUnits::get_pixblock_filterarea_paraller() const { if (p[Y] < min_y) min_y = (int)std::floor(p[Y]); if (p[Y] > max_y) max_y = (int)std::ceil(p[Y]); } - IRect ret(IPoint(min_x, min_y), IPoint(max_x, max_y)); + NR::IRect ret(NR::IPoint(min_x, min_y), NR::IPoint(max_x, max_y)); return ret; } @@ -185,7 +189,8 @@ FilterUnits& FilterUnits::operator=(FilterUnits const &other) { return *this; } -} // namespace NR +} /* namespace Filters */ +} /* namespace Inkscape */ /* diff --git a/src/display/nr-filter-units.h b/src/display/nr-filter-units.h index d11df621f..d8489b42e 100644 --- a/src/display/nr-filter-units.h +++ b/src/display/nr-filter-units.h @@ -19,7 +19,8 @@ #include <2geom/matrix.h> #include <2geom/rect.h> -namespace NR { +namespace Inkscape { +namespace Filters { class FilterUnits { public: @@ -102,7 +103,7 @@ public: * NOTE: use only in filters, that define TRAIT_PARALLER in * get_input_traits. The filter effects area may not be representable * by simple rectangle otherwise. */ - IRect get_pixblock_filterarea_paraller() const; + NR::IRect get_pixblock_filterarea_paraller() const; FilterUnits& operator=(FilterUnits const &other); @@ -121,7 +122,8 @@ private: }; -} // namespace NR +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_UNITS_H__ */ diff --git a/src/display/nr-filter-utils.cpp b/src/display/nr-filter-utils.cpp index ddd41298c..e9e422094 100644 --- a/src/display/nr-filter-utils.cpp +++ b/src/display/nr-filter-utils.cpp @@ -1,6 +1,7 @@ #include "nr-filter-utils.h" -namespace NR { +namespace Inkscape { +namespace Filters { int clamp(int const val) { if (val < 0) return 0; @@ -20,7 +21,8 @@ int clamp_alpha(int const val, int const alpha) { return val; } -} //namespace NR +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter-utils.h b/src/display/nr-filter-utils.h index 91c295e94..ccdaec1a8 100644 --- a/src/display/nr-filter-utils.h +++ b/src/display/nr-filter-utils.h @@ -15,7 +15,8 @@ #include "round.h" /* Shouldn't these be inlined? */ -namespace NR { +namespace Inkscape { +namespace Filters { /** * Clamps an integer value to a value between 0 and 255. Needed by filters where @@ -49,7 +50,8 @@ int clamp3(int const val); */ int clamp_alpha(int const val, int const alpha); -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_UTILS_H__ */ /* diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index a6c5df036..30f8ae7e9 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -53,7 +53,11 @@ using Inkscape::round; #endif -namespace NR { +namespace Inkscape { +namespace Filters { + +using Geom::X; +using Geom::Y; static Geom::OptRect get_item_bbox(NRArenaItem const *item) { Geom::Rect item_bbox; @@ -184,7 +188,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) nr_pixblock_setup_fast(in, pb->mode, pb->area.x0, pb->area.y0, pb->area.x1, pb->area.y1, true); if (in->size != NR_PIXBLOCK_SIZE_TINY && in->data.px == NULL) { - g_warning("NR::Filter::render: failed to reserve temporary buffer"); + g_warning("Inkscape::Filters::Filter::render: failed to reserve temporary buffer"); return 0; } nr_blit_pixblock_pixblock(in, pb); @@ -195,7 +199,7 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) in = slot.get(NR_FILTER_SOURCEGRAPHIC); if (in->area.x1 - in->area.x0 <= 0 || in->area.y1 - in->area.y0 <= 0) { if (in->area.x1 - in->area.x0 < 0 || in->area.y1 - in->area.y0 < 0) { - g_warning("NR::Filter::render: negative area! (%d, %d) (%d, %d)", + g_warning("Inkscape::Filters::Filter::render: negative area! (%d, %d) (%d, %d)", in->area.x0, in->area.y0, in->area.x1, in->area.y1); } return 0; @@ -265,10 +269,10 @@ void Filter::bbox_enlarge(NRRectL &bbox) { Geom::Rect enlarged = filter_effect_area(tmp_bbox); - bbox.x0 = (ICoord)enlarged.min()[X]; - bbox.y0 = (ICoord)enlarged.min()[Y]; - bbox.x1 = (ICoord)enlarged.max()[X]; - bbox.y1 = (ICoord)enlarged.max()[Y]; + bbox.x0 = (NR::ICoord)enlarged.min()[X]; + bbox.y0 = (NR::ICoord)enlarged.min()[Y]; + bbox.x1 = (NR::ICoord)enlarged.max()[X]; + bbox.y1 = (NR::ICoord)enlarged.max()[Y]; } Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) @@ -310,7 +314,7 @@ Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) minp[Y] = _region_y.computed; maxp[Y] = minp[Y] + _region_height.computed; } else { - g_warning("Error in NR::Filter::bbox_enlarge: unrecognized value of _filter_units"); + g_warning("Error in Inkscape::Filters::Filter::bbox_enlarge: unrecognized value of _filter_units"); } Geom::Rect area(minp, maxp); return area; @@ -319,7 +323,7 @@ Geom::Rect Filter::filter_effect_area(Geom::Rect const &bbox) /* Constructor table holds pointers to static methods returning filter * primitives. This table is indexed with FilterPrimitiveType, so that * for example method in _constructor[NR_FILTER_GAUSSIANBLUR] - * returns a filter object of type NR::FilterGaussian. + * returns a filter object of type Inkscape::Filters::FilterGaussian. */ typedef FilterPrimitive*(*FilterConstructor)(); static FilterConstructor _constructor[NR_FILTER_ENDPRIMITIVETYPE]; @@ -531,7 +535,8 @@ std::pair<double,double> Filter::_filter_resolution( return resolution; } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index b00cbf7d7..318e1030f 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -24,7 +24,8 @@ struct NRArenaItem; -namespace NR { +namespace Inkscape { +namespace Filters { class Filter : public Inkscape::GC::Managed<> { public: @@ -205,9 +206,8 @@ private: }; -} /* namespace NR */ - - +} /* namespace Filters */ +} /* namespace Inkscape */ #endif /* __NR_FILTER_H__ */ diff --git a/src/display/nr-light-types.h b/src/display/nr-light-types.h index 87865467c..79b4a3a5e 100644 --- a/src/display/nr-light-types.h +++ b/src/display/nr-light-types.h @@ -1,7 +1,8 @@ #ifndef __NR_LIGHT_TYPES_H__ #define __NR_LIGHT_TYPES_H__ -namespace NR { +namespace Inkscape { +namespace Filters { enum LightType{ NO_LIGHT = 0, @@ -10,7 +11,8 @@ enum LightType{ SPOT_LIGHT }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif // __NR_LIGHT_TYPES_H__ /* diff --git a/src/display/nr-light.cpp b/src/display/nr-light.cpp index 72ed684b0..a3373aadb 100644 --- a/src/display/nr-light.cpp +++ b/src/display/nr-light.cpp @@ -20,7 +20,8 @@ #include "filters/pointlight.h" #include "filters/spotlight.h" -namespace NR { +namespace Inkscape { +namespace Filters { DistantLight::DistantLight(SPFeDistantLight *light, guint32 lighting_color) { color = lighting_color; @@ -30,42 +31,42 @@ DistantLight::DistantLight(SPFeDistantLight *light, guint32 lighting_color) { DistantLight::~DistantLight() {} -void DistantLight::light_vector(Fvector &v) { +void DistantLight::light_vector(NR::Fvector &v) { v[X_3D] = std::cos(azimuth)*std::cos(elevation); v[Y_3D] = std::sin(azimuth)*std::cos(elevation); v[Z_3D] = std::sin(elevation); } -void DistantLight::light_components(Fvector &lc) { +void DistantLight::light_components(NR::Fvector &lc) { lc[LIGHT_RED] = NR_RGBA32_R(color); lc[LIGHT_GREEN] = NR_RGBA32_G(color); lc[LIGHT_BLUE] = NR_RGBA32_B(color); } -PointLight::PointLight(SPFePointLight *light, guint32 lighting_color, const Matrix &trans) { +PointLight::PointLight(SPFePointLight *light, guint32 lighting_color, const Geom::Matrix &trans) { color = lighting_color; l_x = light->x; l_y = light->y; l_z = light->z; - convert_coord(l_x, l_y, l_z, trans); + NR::convert_coord(l_x, l_y, l_z, trans); } PointLight::~PointLight() {} -void PointLight::light_vector(Fvector &v, gdouble x, gdouble y, gdouble z) { +void PointLight::light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z) { v[X_3D] = l_x - x; v[Y_3D] = l_y - y; v[Z_3D] = l_z - z; - normalize_vector(v); + NR::normalize_vector(v); } -void PointLight::light_components(Fvector &lc) { +void PointLight::light_components(NR::Fvector &lc) { lc[LIGHT_RED] = NR_RGBA32_R(color); lc[LIGHT_GREEN] = NR_RGBA32_G(color); lc[LIGHT_BLUE] = NR_RGBA32_B(color); } -SpotLight::SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Matrix &trans) { +SpotLight::SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Geom::Matrix &trans) { gdouble p_x, p_y, p_z; color = lighting_color; l_x = light->x; @@ -76,26 +77,26 @@ SpotLight::SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Matrix p_z = light->pointsAtZ; cos_lca = std::cos(M_PI / 180 * light->limitingConeAngle); speExp = light->specularExponent; - convert_coord(l_x, l_y, l_z, trans); - convert_coord(p_x, p_y, p_z, trans); + NR::convert_coord(l_x, l_y, l_z, trans); + NR::convert_coord(p_x, p_y, p_z, trans); S[X_3D] = p_x - l_x; S[Y_3D] = p_y - l_y; S[Z_3D] = p_z - l_z; - normalize_vector(S); + NR::normalize_vector(S); } SpotLight::~SpotLight() {} -void SpotLight::light_vector(Fvector &v, gdouble x, gdouble y, gdouble z) { +void SpotLight::light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z) { v[X_3D] = l_x - x; v[Y_3D] = l_y - y; v[Z_3D] = l_z - z; - normalize_vector(v); + NR::normalize_vector(v); } -void SpotLight::light_components(Fvector &lc, const Fvector &L) { - gdouble spmod = (-1) * scalar_product(L, S); +void SpotLight::light_components(NR::Fvector &lc, const NR::Fvector &L) { + gdouble spmod = (-1) * NR::scalar_product(L, S); if (spmod <= cos_lca) spmod = 0; else @@ -105,7 +106,8 @@ void SpotLight::light_components(Fvector &lc, const Fvector &L) { lc[LIGHT_BLUE] = spmod * NR_RGBA32_B(color); } -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ /* Local Variables: diff --git a/src/display/nr-light.h b/src/display/nr-light.h index 6c73a0a68..e1870f176 100644 --- a/src/display/nr-light.h +++ b/src/display/nr-light.h @@ -11,14 +11,14 @@ #include <gdk/gdktypes.h> #include "display/nr-3dutils.h" #include "display/nr-light-types.h" +#include <2geom/forward.h> struct SPFeDistantLight; struct SPFePointLight; struct SPFeSpotLight; -namespace NR { - -struct Matrix; +namespace Inkscape { +namespace Filters { enum LightComponent { LIGHT_RED = 0, @@ -42,14 +42,14 @@ class DistantLight { * * \param v a Fvector referece where we store the result */ - void light_vector(Fvector &v); + void light_vector(NR::Fvector &v); /** * Computes the light components of the distant light * * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B */ - void light_components(Fvector &lc); + void light_components(NR::Fvector &lc); private: guint32 color; @@ -68,7 +68,7 @@ class PointLight { * employed in the sp light object) and current coordinate (those * employed in the rendering) */ - PointLight(SPFePointLight *light, guint32 lighting_color, const Matrix &trans); + PointLight(SPFePointLight *light, guint32 lighting_color, const Geom::Matrix &trans); virtual ~PointLight(); /** * Computes the light vector of the distant light at point (x,y,z). @@ -80,14 +80,14 @@ class PointLight { * \param y y coordinate of the current point * \param z z coordinate of the current point */ - void light_vector(Fvector &v, gdouble x, gdouble y, gdouble z); + void light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z); /** * Computes the light components of the distant light * * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B */ - void light_components(Fvector &lc); + void light_components(NR::Fvector &lc); private: guint32 color; @@ -108,7 +108,7 @@ class SpotLight { * employed in the sp light object) and current coordinate (those * employed in the rendering) */ - SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Matrix &trans); + SpotLight(SPFeSpotLight *light, guint32 lighting_color, const Geom::Matrix &trans); virtual ~SpotLight(); /** @@ -121,7 +121,7 @@ class SpotLight { * \param y y coordinate of the current point * \param z z coordinate of the current point */ - void light_vector(Fvector &v, gdouble x, gdouble y, gdouble z); + void light_vector(NR::Fvector &v, gdouble x, gdouble y, gdouble z); /** * Computes the light components of the distant light at the current @@ -130,7 +130,7 @@ class SpotLight { * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B * \param L the light vector of the current point */ - void light_components(Fvector &lc, const Fvector &L); + void light_components(NR::Fvector &lc, const NR::Fvector &L); private: guint32 color; @@ -140,12 +140,13 @@ class SpotLight { gdouble l_z; gdouble cos_lca; //cos of the limiting cone angle gdouble speExp; //specular exponent; - Fvector S; //unit vector from light position in the direction + NR::Fvector S; //unit vector from light position in the direction //the spot point at }; -} /* namespace NR */ +} /* namespace Filters */ +} /* namespace Inkscape */ #endif // __NR_LIGHT_H__ /* diff --git a/src/display/pixblock-scaler.cpp b/src/display/pixblock-scaler.cpp index 39c82daf6..511104c43 100644 --- a/src/display/pixblock-scaler.cpp +++ b/src/display/pixblock-scaler.cpp @@ -181,6 +181,8 @@ static void scale_bicubic_rgba(NRPixBlock *to, NRPixBlock *from) _check_index(to, to_y * to->rs + to_x * 4, __LINE__); + using Inkscape::Filters::clamp; + using Inkscape::Filters::clamp_alpha; if (to->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { /* Clamp the colour channels to range from 0 to result.a to * make sure, we don't exceed 100% per colour channel with @@ -268,7 +270,7 @@ void scale_bicubic_alpha(NRPixBlock *to, NRPixBlock *from) _check_index(to, to_y * to->rs + to_x, __LINE__); - NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x] = clamp(result); + NR_PIXBLOCK_PX(to)[to_y * to->rs + to_x] = Inkscape::Filters::clamp(result); } } } diff --git a/src/display/pixblock-transform.cpp b/src/display/pixblock-transform.cpp index daf27582a..d0ba89806 100644 --- a/src/display/pixblock-transform.cpp +++ b/src/display/pixblock-transform.cpp @@ -249,6 +249,8 @@ void transform_bicubic(NRPixBlock *to, NRPixBlock *from, Geom::Matrix const &tra result.a = samplex(line[0].a, line[1].a, line[2].a, line[3].a, from_x); + using Inkscape::Filters::clamp; + using Inkscape::Filters::clamp_alpha; _check_index(to, to_y * to->rs + to_x * 4, __LINE__); if (to->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) { /* Make sure, none of the RGB channels exceeds 100% intensity |
