summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2011-03-12 08:23:09 +0000
committertavmjong-free <tavmjong@free.fr>2011-03-12 08:23:09 +0000
commitac8b01693af4588db21cc219baa8c5d0fd3d5826 (patch)
treeddc7f487f0bbc14b9443dfa095ab636c7f00cac5 /src
parentSnap while rotating: fix removal of points too close to the rotation center (diff)
downloadinkscape-ac8b01693af4588db21cc219baa8c5d0fd3d5826.tar.gz
inkscape-ac8b01693af4588db21cc219baa8c5d0fd3d5826.zip
Use filter primitive subregion for feFlood per SVG standard.
(bzr r10094)
Diffstat (limited to 'src')
-rw-r--r--src/display/nr-filter-flood.cpp68
1 files changed, 44 insertions, 24 deletions
diff --git a/src/display/nr-filter-flood.cpp b/src/display/nr-filter-flood.cpp
index ca073cfd8..eb1cf13a6 100644
--- a/src/display/nr-filter-flood.cpp
+++ b/src/display/nr-filter-flood.cpp
@@ -3,8 +3,9 @@
*
* Authors:
* Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
+ * Tavmjong Bah <tavmjong@free.fr> (use primitive filter region)
*
- * Copyright (C) 2007 authors
+ * Copyright (C) 2007, 2011 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -31,7 +32,7 @@ FilterPrimitive * FilterFlood::create() {
FilterFlood::~FilterFlood()
{}
-int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) {
+int FilterFlood::render(FilterSlot &slot, FilterUnits const &units) {
//g_message("rendering feflood");
NRPixBlock *in = slot.get(_input);
if (!in) {
@@ -39,35 +40,54 @@ int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) {
return 1;
}
- int i;
- int in_w = in->area.x1 - in->area.x0;
- int in_h = in->area.y1 - in->area.y0;
-
- NRPixBlock *out = new NRPixBlock;
-
- nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N,
- in->area.x0, in->area.y0, in->area.x1, in->area.y1,
- true);
+ // Region being drawn on screen in screen coordinates.
+ int x0 = in->area.x0, y0 = in->area.y0;
+ int x1 = in->area.x1, y1 = in->area.y1;
+ int w = x1 - x0;
+ // Set up pix block
+ NRPixBlock *out = new NRPixBlock;
+ nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N, x0, y0, x1, y1, true);
unsigned char *out_data = NR_PIXBLOCK_PX(out);
- unsigned char r,g,b,a;
-
- r = CLAMP_D_TO_U8((color >> 24) % 256);
- g = CLAMP_D_TO_U8((color >> 16) % 256);
- b = CLAMP_D_TO_U8((color >> 8) % 256);
- a = CLAMP_D_TO_U8(opacity*255);
+ // Get RGBA values.
+ unsigned char r,g,b,a;
+ r = CLAMP_D_TO_U8((color >> 24) % 256);
+ g = CLAMP_D_TO_U8((color >> 16) % 256);
+ b = CLAMP_D_TO_U8((color >> 8) % 256);
+ a = CLAMP_D_TO_U8(opacity*255);
#if ENABLE_LCMS
- icc_color_to_sRGB(icc, &r, &g, &b);
-//g_message("result: r:%d g:%d b:%d", r, g, b);
+ icc_color_to_sRGB(icc, &r, &g, &b);
+ //g_message("result: r:%d g:%d b:%d", r, g, b);
#endif //ENABLE_LCMS
- for(i=0; i < 4*in_h*in_w; i+=4){
- out_data[i]=r;
- out_data[i+1]=g;
- out_data[i+2]=b;
- out_data[i+3]=a;
+ // Only fill primitive subregion
+
+ // Get subregion in user units
+ Geom::Rect fp = filter_primitive_area( units );
+
+ // Need to convert to pixbuff units
+ Geom::Rect fp_pb = fp * units.get_matrix_user2pb();
+
+ // Make sure we are in pixbuff area
+ int fp_x0 = fp_pb.min()[Geom::X];
+ int fp_x1 = fp_pb.max()[Geom::X];
+ int fp_y0 = fp_pb.min()[Geom::Y];
+ int fp_y1 = fp_pb.max()[Geom::Y];
+ if( fp_x0 < x0 ) fp_x0 = x0;
+ if( fp_x1 > x1 ) fp_x1 = x1;
+ if( fp_y0 < y0 ) fp_y0 = y0;
+ if( fp_y1 > y1 ) fp_y1 = y1;
+
+ // Do fill
+ for (int x=fp_x0; x < fp_x1; x++){
+ for (int y=fp_y0; y < fp_y1; y++){
+ out_data[ 4*((x - x0) + w*(y - y0)) ] = r;
+ out_data[ 4*((x - x0) + w*(y - y0)) + 1 ] = g;
+ out_data[ 4*((x - x0) + w*(y - y0)) + 2 ] = b;
+ out_data[ 4*((x - x0) + w*(y - y0)) + 3 ] = a;
+ }
}
out->empty = FALSE;