index b02b20cbf6d8eddcfbaa2e97bf400d40d1865128..4645d9bc063a8bf0493e202e0b54ff4f5f0365b3 100644 (file)
*
* Authors:
* Niko Kiirala <niko@kiirala.com>
*
* Authors:
* Niko Kiirala <niko@kiirala.com>
+ * Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
*
*
- * Copyright (C) 2007 authors
+ * Copyright (C) 2007-2008 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "display/nr-filter-primitive.h"
#include "display/nr-filter-slot.h"
#include "display/nr-filter-types.h"
#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-pixblock.h"
-#include "libnr/nr-matrix.h"
#include "libnr/nr-blit.h"
#include "libnr/nr-pixops.h"
#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
/*
* From http://www.w3.org/TR/SVG11/filters.html#feBlend
inline void
blend_normal(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
inline void
blend_normal(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
- r[0] = NR_NORMALIZE_21((255 - a[3]) * b[0]) + a[0];
- r[1] = NR_NORMALIZE_21((255 - a[3]) * b[1]) + a[1];
- r[2] = NR_NORMALIZE_21((255 - a[3]) * b[2]) + a[2];
+ r[0] = NR_COMPOSEPPP_1111(a[0],a[3],b[0]);
+ r[1] = NR_COMPOSEPPP_1111(a[1],a[3],b[1]);
+ r[2] = NR_COMPOSEPPP_1111(a[2],a[3],b[2]);
SET_ALPHA;
}
SET_ALPHA;
}
inline void
blend_screen(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
inline void
blend_screen(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
- r[0] = NR_NORMALIZE_21(b[0] * 255 + a[0] * 255 - a[0] * b[0]);
- r[1] = NR_NORMALIZE_21(b[1] * 255 + a[1] * 255 - a[1] * b[1]);
- r[2] = NR_NORMALIZE_21(b[2] * 255 + a[2] * 255 - a[2] * b[2]);
+ r[0] = NR_NORMALIZE_21((b[0] + a[0]) * 255 - a[0] * b[0]);
+ r[1] = NR_NORMALIZE_21((b[1] + a[1]) * 255 - a[1] * b[1]);
+ r[2] = NR_NORMALIZE_21((b[2] + a[2]) * 255 - a[2] * b[2]);
SET_ALPHA;
}
SET_ALPHA;
}
inline void
blend_darken(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
inline void
blend_darken(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
- r[0] = std::min(NR_NORMALIZE_21((255 - a[3]) * b[0]) + a[0],
- NR_NORMALIZE_21((255 - b[3]) * a[0]) + b[0]);
- r[1] = std::min(NR_NORMALIZE_21((255 - a[3]) * b[1]) + a[1],
- NR_NORMALIZE_21((255 - b[3]) * a[1]) + b[1]);
- r[2] = std::min(NR_NORMALIZE_21((255 - a[3]) * b[2]) + a[2],
- NR_NORMALIZE_21((255 - b[3]) * a[2]) + b[2]);
+ r[0] = NR_NORMALIZE_21(std::min(NR_COMPOSEPPP_1112(a[0],a[3],b[0]),
+ NR_COMPOSEPPP_1112(b[0],b[3],a[0])));
+ r[1] = NR_NORMALIZE_21(std::min(NR_COMPOSEPPP_1112(a[1],a[3],b[1]),
+ NR_COMPOSEPPP_1112(b[1],b[3],a[1])));
+ r[2] = NR_NORMALIZE_21(std::min(NR_COMPOSEPPP_1112(a[2],a[3],b[2]),
+ NR_COMPOSEPPP_1112(b[2],b[3],a[2])));
SET_ALPHA;
}
SET_ALPHA;
}
@@ -102,12 +104,12 @@ blend_darken(unsigned char *r, unsigned char const *a, unsigned char const *b)
inline void
blend_lighten(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
inline void
blend_lighten(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
- r[0] = std::max(NR_NORMALIZE_21((255 - a[3]) * b[0]) + a[0],
- NR_NORMALIZE_21((255 - b[3]) * a[0]) + b[0]);
- r[1] = std::max(NR_NORMALIZE_21((255 - a[3]) * b[1]) + a[1],
- NR_NORMALIZE_21((255 - b[3]) * a[1]) + b[1]);
- r[2] = std::max(NR_NORMALIZE_21((255 - a[3]) * b[2]) + a[2],
- NR_NORMALIZE_21((255 - b[3]) * a[2]) + b[2]);
+ r[0] = NR_NORMALIZE_21(std::max(NR_COMPOSEPPP_1112(a[0],a[3],b[0]),
+ NR_COMPOSEPPP_1112(b[0],b[3],a[0])));
+ r[1] = NR_NORMALIZE_21(std::max(NR_COMPOSEPPP_1112(a[1],a[3],b[1]),
+ NR_COMPOSEPPP_1112(b[1],b[3],a[1])));
+ r[2] = NR_NORMALIZE_21(std::max(NR_COMPOSEPPP_1112(a[2],a[3],b[2]),
+ NR_COMPOSEPPP_1112(b[2],b[3],a[2])));
SET_ALPHA;
}
SET_ALPHA;
}
FilterBlend::~FilterBlend()
{}
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;
NRPixBlock *in1 = slot.get(_input);
NRPixBlock *in2 = slot.get(_input2);
NRPixBlock *original_in1 = in1;
}
}
}
}
-} /* namespace NR */
+} /* namespace Filters */
+} /* namespace Inkscape */
/*
Local Variables:
/*
Local Variables: