summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorNiko Kiirala <niko@kiirala.com>2007-05-29 10:47:04 +0000
committerkiirala <kiirala@users.sourceforge.net>2007-05-29 10:47:04 +0000
commitbb8c80451efac613442f77de66d246065ffa4fcf (patch)
tree61128cfdaedcc105fd1cb0861e0583a9cee47690 /src/display
parentAdd auto gap filling for Paint Bucket and implement "safety valve" to prevent... (diff)
downloadinkscape-bb8c80451efac613442f77de66d246065ffa4fcf.tar.gz
inkscape-bb8c80451efac613442f77de66d246065ffa4fcf.zip
Added support for in-parameter in filter primitives
(bzr r3041)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/nr-filter-blend.cpp8
-rw-r--r--src/display/nr-filter-slot.cpp23
-rw-r--r--src/display/nr-filter-types.h2
-rw-r--r--src/display/nr-filter.cpp2
4 files changed, 20 insertions, 15 deletions
diff --git a/src/display/nr-filter-blend.cpp b/src/display/nr-filter-blend.cpp
index 1468eb61b..0e2f965b7 100644
--- a/src/display/nr-filter-blend.cpp
+++ b/src/display/nr-filter-blend.cpp
@@ -23,14 +23,6 @@
#include "libnr/nr-blit.h"
#include "libnr/nr-pixops.h"
-/*
-static inline int clamp(const int val, const int min, const int max) {
- if (val < min) return min;
- if (val > max) return max;
- return val;
-}
-*/
-
template <void(*blend)(unsigned char *cr, unsigned char const *ca, unsigned char const *cb)>
static void _render(NRPixBlock &out, NRPixBlock &in1, NRPixBlock &in2) {
unsigned char *in1_data = NR_PIXBLOCK_PX(&in1);
diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp
index 3a2895ec6..673754f18 100644
--- a/src/display/nr-filter-slot.cpp
+++ b/src/display/nr-filter-slot.cpp
@@ -62,7 +62,7 @@ NRPixBlock *FilterSlot::get(int slot_nr)
|| slot_nr == NR_FILTER_BACKGROUNDIMAGE
|| slot_nr == NR_FILTER_BACKGROUNDALPHA
|| slot_nr == NR_FILTER_FILLPAINT
- || slot_nr == NR_FILTER_SOURCEPAINT))
+ || slot_nr == NR_FILTER_STROKEPAINT))
{
/* If needed, fetch background */
if (slot_nr == NR_FILTER_BACKGROUNDIMAGE
@@ -70,7 +70,22 @@ NRPixBlock *FilterSlot::get(int slot_nr)
{
NRPixBlock *pb;
pb = nr_arena_item_get_background(_arena_item);
- this->set(NR_FILTER_BACKGROUNDIMAGE, pb);
+ if (pb) {
+ this->set(NR_FILTER_BACKGROUNDIMAGE, pb);
+ } else {
+ NRPixBlock *source = this->get(NR_FILTER_SOURCEGRAPHIC);
+ pb = new NRPixBlock();
+ if (!pb) return NULL; // Allocation failed
+ nr_pixblock_setup_fast(pb, source->mode,
+ source->area.x0, source->area.y0,
+ source->area.x1, source->area.y1, true);
+ if (pb->size != NR_PIXBLOCK_SIZE_TINY && pb->data.px == NULL) {
+ // allocation failed
+ delete pb;
+ return NULL;
+ }
+ this->set(NR_FILTER_BACKGROUNDIMAGE, pb);
+ }
}
/* If only a alpha channel is needed, strip it from full image */
if (slot_nr == NR_FILTER_SOURCEALPHA) {
@@ -83,7 +98,7 @@ NRPixBlock *FilterSlot::get(int slot_nr)
if (slot_nr == NR_FILTER_FILLPAINT) {
// TODO
}
- if (slot_nr == NR_FILTER_SOURCEPAINT) {
+ if (slot_nr == NR_FILTER_STROKEPAINT) {
// TODO
}
}
@@ -125,7 +140,7 @@ int FilterSlot::_get_index(int slot_nr)
slot_nr == NR_FILTER_BACKGROUNDIMAGE ||
slot_nr == NR_FILTER_BACKGROUNDALPHA ||
slot_nr == NR_FILTER_FILLPAINT ||
- slot_nr == NR_FILTER_SOURCEPAINT);
+ slot_nr == NR_FILTER_STROKEPAINT);
int index = -1;
if (slot_nr == NR_FILTER_SLOT_NOT_SET) {
diff --git a/src/display/nr-filter-types.h b/src/display/nr-filter-types.h
index 3eebe3731..6f28c6257 100644
--- a/src/display/nr-filter-types.h
+++ b/src/display/nr-filter-types.h
@@ -31,7 +31,7 @@ enum {
NR_FILTER_BACKGROUNDIMAGE = -4,
NR_FILTER_BACKGROUNDALPHA = -5,
NR_FILTER_FILLPAINT = -6,
- NR_FILTER_SOURCEPAINT = -7
+ NR_FILTER_STROKEPAINT = -7
};
} /* namespace NR */
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp
index 515d5961f..d8cfb2ecf 100644
--- a/src/display/nr-filter.cpp
+++ b/src/display/nr-filter.cpp
@@ -35,8 +35,6 @@
using Inkscape::round;
#endif
-//#include "display/nr-arena-shape.h"
-
__attribute__ ((const))
inline static int _max4(const double a, const double b,
const double c, const double d) {