index 43580191e761e0ddef1d30e9b27c33214ffb582d..a1a4886741f6a02d59328f3b9f639873392729dd 100644 (file)
#include <cmath>
-#include "isnan.h"
+#include "2geom/isnan.h"
#include "sp-fecomposite.h"
#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"
#include "libnr/nr-pixops.h"
r[3] = NR_NORMALIZE_21(a[3] * (255 - b[3]) + b[3] * (255 - a[3]));
}
-static int clamp(int val) {
- if (val < 0) return 0;
- if (val > 255) return 255;
- return val;
-}
-
// BUGBUG / TODO
// This makes arithmetic compositing non re-entrant and non thread safe.
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] = clamp(NR_NORMALIZE_31(arith_k1 * a[0] * b[0]
+ r[0] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[0] * b[0]
+ arith_k2 * a[0] + arith_k3 * b[0] + arith_k4));
- r[1] = clamp(NR_NORMALIZE_31(arith_k1 * a[1] * b[1]
+ r[1] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[1] * b[1]
+ arith_k2 * a[1] + arith_k3 * b[1] + arith_k4));
- r[2] = clamp(NR_NORMALIZE_31(arith_k1 * a[2] * b[2]
+ r[2] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[2] * b[2]
+ arith_k2 * a[2] + arith_k3 * b[2] + arith_k4));
- r[3] = clamp(NR_NORMALIZE_31(arith_k1 * a[3] * b[3]
+ r[3] = NR_NORMALIZE_31(NR::clamp3(arith_k1 * a[3] * b[3]
+ arith_k2 * a[3] + arith_k3 * b[3] + arith_k4));
}
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;
}
void FilterComposite::set_arithmetic(double k1, double k2, double k3, double k4) {
- if (!isFinite(k1) || !isFinite(k2) || !isFinite(k3) || !isFinite(k4)) {
+ if (!IS_FINITE(k1) || !IS_FINITE(k2) || !IS_FINITE(k3) || !IS_FINITE(k4)) {
g_warning("Non-finite parameter for feComposite arithmetic operator");
return;
}