index 32fa3e2a5e965c1efad4b3ff48b270109b09db57..51652d743e562ed5ef0cf471687cf3ebc004121f 100644 (file)
#include "libnr/nr-blit.h"
#include "libnr/nr-pixblock.h"
#include "libnr/nr-pixops.h"
-#include "libnr/nr-matrix.h"
inline void
composite_over(unsigned char *r, unsigned char const *a, unsigned char const *b)
{
- r[0] = a[0] + NR_NORMALIZE_21(b[0] * (255 - a[3]));
- r[1] = a[1] + NR_NORMALIZE_21(b[1] * (255 - a[3]));
- r[2] = a[2] + NR_NORMALIZE_21(b[2] * (255 - a[3]));
- r[3] = a[3] + NR_NORMALIZE_21(b[3] * (255 - a[3]));
+ 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]);
+ r[3] = NR_COMPOSEPPP_1111(a[3],a[3],b[3]);
}
inline void
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() {
// Blending modes are defined for premultiplied RGBA values,
// thus convert them to that format before blending
if (in1->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) {
- in1 = new NRPixBlock;
- nr_pixblock_setup_fast(in1, NR_PIXBLOCK_MODE_R8G8B8A8P,
- original_in1->area.x0, original_in1->area.y0,
- original_in1->area.x1, original_in1->area.y1,
- false);
+ in1 = nr_pixblock_new_fast(NR_PIXBLOCK_MODE_R8G8B8A8P,
+ original_in1->area.x0, original_in1->area.y0,
+ original_in1->area.x1, original_in1->area.y1,
+ false);
nr_blit_pixblock_pixblock(in1, original_in1);
}
if (in2->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) {
- in2 = new NRPixBlock;
- nr_pixblock_setup_fast(in2, NR_PIXBLOCK_MODE_R8G8B8A8P,
- original_in2->area.x0, original_in2->area.y0,
- original_in2->area.x1, original_in2->area.y1,
- false);
+ in2 = nr_pixblock_new_fast(NR_PIXBLOCK_MODE_R8G8B8A8P,
+ original_in2->area.x0, original_in2->area.y0,
+ original_in2->area.x1, original_in2->area.y1,
+ false);
nr_blit_pixblock_pixblock(in2, original_in2);
}
pixops_mix<composite_xor>(*out, *in1, *in2);
break;
case COMPOSITE_ARITHMETIC:
- arith_k1 = (int)(k1 * 255);
- arith_k2 = (int)(k2 * 255 * 255);
- arith_k3 = (int)(k3 * 255 * 255);
- arith_k4 = (int)(k4 * 255 * 255 * 255);
+ arith_k1 = (int)round(k1 * 255);
+ arith_k2 = (int)round(k2 * 255 * 255);
+ arith_k3 = (int)round(k3 * 255 * 255);
+ arith_k4 = (int)round(k4 * 255 * 255 * 255);
pixops_mix<composite_arithmetic>(*out, *in1, *in2);
break;
case COMPOSITE_DEFAULT:
}
if (in1 != original_in1) {
- nr_pixblock_release(in1);
- delete in1;
+ nr_pixblock_free(in1);
}
if (in2 != original_in2) {
- nr_pixblock_release(in2);
- delete in2;
+ nr_pixblock_free(in2);
}
out->empty = FALSE;
@@ -217,7 +214,8 @@ void FilterComposite::set_arithmetic(double k1, double k2, double k3, double k4)
this->k4 = k4;
}
-} /* namespace NR */
+} /* namespace Filters */
+} /* namespace Inkscape */
/*
Local Variables: