summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-05-15 18:08:17 +0000
committerTed Gould <ted@gould.cx>2010-05-15 18:08:17 +0000
commit2d8c2dfd832ce207aef3895e702bff4098ab7136 (patch)
tree642a37c6e3ca05d5e991ffe868f03c9cc58e51bc /src/display
parentMerge from trunk (diff)
parentMinor tweaks to text toolbar. (diff)
downloadinkscape-2d8c2dfd832ce207aef3895e702bff4098ab7136.tar.gz
inkscape-2d8c2dfd832ce207aef3895e702bff4098ab7136.zip
Updating to trunk
(bzr r8254.1.54)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/canvas-axonomgrid.cpp16
-rw-r--r--src/display/curve.cpp13
-rw-r--r--src/display/curve.h2
-rw-r--r--src/display/nr-arena-glyphs.cpp12
-rw-r--r--src/display/nr-arena-image.cpp16
-rw-r--r--src/display/nr-arena-shape.cpp33
-rw-r--r--src/display/nr-filter-displacement-map.cpp92
-rw-r--r--src/display/nr-filter-gaussian.cpp22
-rw-r--r--src/display/nr-filter.cpp8
-rw-r--r--src/display/pixblock-transform.cpp5
-rw-r--r--src/display/snap-indicator.cpp8
11 files changed, 132 insertions, 95 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index ee05cd01c..cf2883116 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -518,6 +518,9 @@ CanvasAxonomGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/)
{
ow = origin * affine;
sw = Geom::Point(fabs(affine[0]),fabs(affine[3]));
+ sw *= lengthy;
+
+ scaled = false;
for(int dim = 0; dim < 2; dim++) {
gint scaling_factor = empspacing;
@@ -525,10 +528,9 @@ CanvasAxonomGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/)
if (scaling_factor <= 1)
scaling_factor = 5;
- scaled = FALSE;
int watchdog = 0;
while ( (sw[dim] < 8.0) & (watchdog < 100) ) {
- scaled = TRUE;
+ scaled = true;
sw[dim] *= scaling_factor;
// First pass, go up to the major line spacing, then
// keep increasing by two.
@@ -538,13 +540,13 @@ CanvasAxonomGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/)
}
- spacing_ylines = sw[Geom::X] * lengthy /(tan_angle[X] + tan_angle[Z]);
- lyw = sw[Geom::Y] * lengthy;
- lxw_x = (lengthy / tan_angle[X]) * sw[Geom::X];
- lxw_z = (lengthy / tan_angle[Z]) * sw[Geom::X];
+ spacing_ylines = sw[Geom::X] /(tan_angle[X] + tan_angle[Z]);
+ lyw = sw[Geom::Y];
+ lxw_x = sw[Geom::X] / tan_angle[X];
+ lxw_z = sw[Geom::X] / tan_angle[Z];
if (empspacing == 0) {
- scaled = TRUE;
+ scaled = true;
}
}
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 1b54c981c..73b8dc36d 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -44,7 +44,7 @@ SPCurve::SPCurve(Geom::PathVector const& pathv)
}
SPCurve *
-SPCurve::new_from_rect(Geom::Rect const &rect)
+SPCurve::new_from_rect(Geom::Rect const &rect, bool all_four_sides)
{
SPCurve *c = new SPCurve();
@@ -54,7 +54,16 @@ SPCurve::new_from_rect(Geom::Rect const &rect)
for (int i=3; i>=1; i--) {
c->lineto(rect.corner(i));
}
- c->closepath();
+
+ if (all_four_sides) {
+ // When _constrained_ snapping to a path, the 2geom::SimpleCrosser will be invoked which doesn't consider the closing segment.
+ // of a path. Consequently, in case we want to snap to for example the page border, we must provide all four sides of the
+ // rectangle explicitly
+ c->lineto(rect.corner(0));
+ } else {
+ // ... instead of just three plus a closing segment
+ c->closepath();
+ }
return c;
}
diff --git a/src/display/curve.h b/src/display/curve.h
index 79a385b09..fe0720195 100644
--- a/src/display/curve.h
+++ b/src/display/curve.h
@@ -27,7 +27,7 @@ public:
/* Constructors */
explicit SPCurve();
explicit SPCurve(Geom::PathVector const& pathv);
- static SPCurve * new_from_rect(Geom::Rect const &rect);
+ static SPCurve * new_from_rect(Geom::Rect const &rect, bool all_four_sides = false);
virtual ~SPCurve();
diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp
index db0922915..33b08a91c 100644
--- a/src/display/nr-arena-glyphs.cpp
+++ b/src/display/nr-arena-glyphs.cpp
@@ -211,10 +211,10 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s
}
if (nr_rect_d_test_empty(bbox)) return NR_ARENA_ITEM_STATE_ALL;
- item->bbox.x0 = (gint32)(bbox.x0 - 1.0);
- item->bbox.y0 = (gint32)(bbox.y0 - 1.0);
- item->bbox.x1 = (gint32)(bbox.x1 + 1.0);
- item->bbox.y1 = (gint32)(bbox.y1 + 1.0);
+ item->bbox.x0 = static_cast<NR::ICoord>(floor(bbox.x0));
+ item->bbox.y0 = static_cast<NR::ICoord>(floor(bbox.y0));
+ item->bbox.x1 = static_cast<NR::ICoord>(ceil (bbox.x1));
+ item->bbox.y1 = static_cast<NR::ICoord>(ceil (bbox.y1));
return NR_ARENA_ITEM_STATE_ALL;
}
@@ -234,7 +234,7 @@ nr_arena_glyphs_clip(NRArenaItem *item, NRRectL */*area*/, NRPixBlock */*pb*/)
}
static NRArenaItem *
-nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, gdouble /*delta*/, unsigned int /*sticky*/)
+nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, gdouble delta, unsigned int /*sticky*/)
{
NRArenaGlyphs *glyphs;
@@ -246,7 +246,7 @@ nr_arena_glyphs_pick(NRArenaItem *item, Geom::Point p, gdouble /*delta*/, unsign
double const x = p[Geom::X];
double const y = p[Geom::Y];
/* With text we take a simple approach: pick if the point is in a characher bbox */
- if ((x >= item->bbox.x0) && (y >= item->bbox.y0) && (x <= item->bbox.x1) && (y <= item->bbox.y1)) return item;
+ if ((x + delta >= item->bbox.x0) && (y + delta >= item->bbox.y0) && (x - delta <= item->bbox.x1) && (y - delta <= item->bbox.y1)) return item;
return NULL;
}
diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp
index f45a2da4f..493943168 100644
--- a/src/display/nr-arena-image.cpp
+++ b/src/display/nr-arena-image.cpp
@@ -151,10 +151,10 @@ nr_arena_image_update( NRArenaItem *item, NRRectL */*area*/, NRGC *gc, unsigned
nr_rect_d_matrix_transform (&bbox, &bbox, gc->transform);
- item->bbox.x0 = (int) floor (bbox.x0);
- item->bbox.y0 = (int) floor (bbox.y0);
- item->bbox.x1 = (int) ceil (bbox.x1);
- item->bbox.y1 = (int) ceil (bbox.y1);
+ item->bbox.x0 = static_cast<NR::ICoord>(floor(bbox.x0)); // Floor gives the coordinate in which the point resides
+ item->bbox.y0 = static_cast<NR::ICoord>(floor(bbox.y0));
+ item->bbox.x1 = static_cast<NR::ICoord>(ceil (bbox.x1)); // Ceil gives the first coordinate beyond the point
+ item->bbox.y1 = static_cast<NR::ICoord>(ceil (bbox.y1));
} else {
item->bbox.x0 = (int) gc->transform[4];
item->bbox.y0 = (int) gc->transform[5];
@@ -211,13 +211,7 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixB
} else if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8P) {
nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
} else if (pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8N) {
-
- //FIXME: The _N_N_N_ version gives a gray border around images, see bug 906376
- // This mode is only used when exporting, screen rendering always has _P_P_P_, so I decided to simply replace it for now
- // Feel free to propose a better fix
-
- //nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
- nr_R8G8B8A8_P_R8G8B8A8_P_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
+ nr_R8G8B8A8_N_R8G8B8A8_N_R8G8B8A8_N_TRANSFORM (dpx, dw, dh, drs, spx, sw, sh, srs, d2s, Falpha, nr_arena_image_x_sample, nr_arena_image_y_sample);
}
pb->empty = FALSE;
diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp
index e2a9e9580..a3b295a4e 100644
--- a/src/display/nr-arena-shape.cpp
+++ b/src/display/nr-arena-shape.cpp
@@ -254,12 +254,11 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
if (state & NR_ARENA_ITEM_STATE_BBOX) {
if (shape->curve) {
boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform);
- /// \todo just write item->bbox = boundingbox
if (boundingbox) {
- item->bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F);
- item->bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F);
- item->bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F);
- item->bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F);
+ item->bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0])); // Floor gives the coordinate in which the point resides
+ item->bbox.y0 = static_cast<NR::ICoord>(floor((*boundingbox)[1][0]));
+ item->bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1])); // Ceil gives the first coordinate beyond the point
+ item->bbox.y1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[1][1]));
} else {
item->bbox = NR_RECT_L_EMPTY;
}
@@ -300,10 +299,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
/// \todo just write item->bbox = boundingbox
if (boundingbox) {
- shape->approx_bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F);
- shape->approx_bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F);
- shape->approx_bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F);
- shape->approx_bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F);
+ shape->approx_bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0]));
+ shape->approx_bbox.y0 = static_cast<NR::ICoord>(floor((*boundingbox)[1][0]));
+ shape->approx_bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1]));
+ shape->approx_bbox.y1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[1][1]));
} else {
shape->approx_bbox = NR_RECT_L_EMPTY;
}
@@ -349,10 +348,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
/// \todo just write shape->approx_bbox = boundingbox
if (boundingbox) {
- shape->approx_bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F);
- shape->approx_bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F);
- shape->approx_bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F);
- shape->approx_bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F);
+ shape->approx_bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0]));
+ shape->approx_bbox.y0 = static_cast<NR::ICoord>(floor((*boundingbox)[1][0]));
+ shape->approx_bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1]));
+ shape->approx_bbox.y1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[1][1]));
} else {
shape->approx_bbox = NR_RECT_L_EMPTY;
}
@@ -362,10 +361,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
return NR_ARENA_ITEM_STATE_ALL;
/// \todo just write item->bbox = boundingbox
- item->bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F);
- item->bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F);
- item->bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.0F);
- item->bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.0F);
+ item->bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0]));
+ item->bbox.y0 = static_cast<NR::ICoord>(floor((*boundingbox)[1][0]));
+ item->bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1]));
+ item->bbox.y1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[1][1]));
item->render_opacity = TRUE;
if ( shape->_fill.paint.type() == NRArenaShape::Paint::SERVER ) {
diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp
index 4de5e658c..a983fb840 100644
--- a/src/display/nr-filter-displacement-map.cpp
+++ b/src/display/nr-filter-displacement-map.cpp
@@ -43,9 +43,8 @@ struct pixel_t {
static inline pixel_t pixelValue(NRPixBlock const* pb, int x, int y) {
if ( x < pb->area.x0 || x >= pb->area.x1 || y < pb->area.y0 || y >= pb->area.y1 ) return pixel_t::blank(); // This assumes anything outside the defined range is (0,0,0,0)
- pixel_t const* data = reinterpret_cast<pixel_t const*>(NR_PIXBLOCK_PX(pb));
- int offset = (x-pb->area.x0) + (pb->area.x1-pb->area.x0)*(y-pb->area.y0);
- return data[offset];
+ pixel_t const* rowData = reinterpret_cast<pixel_t const*>(NR_PIXBLOCK_PX(pb) + (y-pb->area.y0)*pb->rs);
+ return rowData[x-pb->area.x0];
}
template<bool PREMULTIPLIED>
@@ -74,18 +73,9 @@ static pixel_t interpolatePixels(NRPixBlock const* pb, double x, double y) {
* We might as well avoid premultiplication in this case, which still gives us a fully
* transparent result, but with interpolated RGB parts. */
- /* First calculate interpolated alpha value. */
- unsigned ra = 0;
- if (!PREMULTIPLIED) {
- unsigned const y0 = sf*p00[3] + xf*(p01[3]-p00[3]); // range [0,a*sf]
- unsigned const y1 = sf*p10[3] + xf*(p11[3]-p10[3]);
- ra = sf*y0 + yf*(y1-y0); // range [0,a*sf*sf]
- }
-
pixel_t r;
- if (ra == 0) {
- /* Either premultiplied or the interpolated alpha value is zero,
- * so do simple interpolation. */
+ if (PREMULTIPLIED) {
+ /* Premultiplied, so do simple interpolation. */
for (unsigned i = 0; i != 4; ++i) {
// y0,y1 have range [0,a*sf]
unsigned const y0 = sf*p00[i] + xf*((unsigned int)p01[i]-(unsigned int)p00[i]);
@@ -95,21 +85,39 @@ static pixel_t interpolatePixels(NRPixBlock const* pb, double x, double y) {
r[i] = (ri + sf2h)>>(2*sfl); // range [0,a]
}
} else {
- /* Do premultiplication ourselves. */
- for (unsigned i = 0; i != 3; ++i) {
- // Premultiplied versions. Range [0,255*a].
- unsigned const c00 = p00[i]*p00[3];
- unsigned const c01 = p01[i]*p01[3];
- unsigned const c10 = p10[i]*p10[3];
- unsigned const c11 = p11[i]*p11[3];
-
- // Interpolation.
- unsigned const y0 = sf*c00 + xf*(c01-c00); // range [0,255*a*sf]
- unsigned const y1 = sf*c10 + xf*(c11-c10); // range [0,255*a*sf]
- unsigned const ri = sf*y0 + yf*(y1-y0); // range [0,255*a*sf*sf]
- r[i] = (ri + ra/2) / ra; // range [0,255]
+ /* First calculate interpolated alpha value. */
+ unsigned const y0 = sf*p00[3] + xf*((unsigned int)p01[3]-(unsigned int)p00[3]); // range [0,a*sf]
+ unsigned const y1 = sf*p10[3] + xf*((unsigned int)p11[3]-(unsigned int)p10[3]);
+ unsigned const ra = sf*y0 + yf*(y1-y0); // range [0,a*sf*sf]
+
+ if (ra==0) {
+ /* Fully transparent, so do simple interpolation. */
+ for (unsigned i = 0; i != 3; ++i) {
+ // y0,y1 have range [0,255*sf]
+ unsigned const y0 = sf*p00[i] + xf*((unsigned int)p01[i]-(unsigned int)p00[i]);
+ unsigned const y1 = sf*p10[i] + xf*((unsigned int)p11[i]-(unsigned int)p10[i]);
+
+ unsigned const ri = sf*y0 + yf*(y1-y0); // range [0,255*sf*sf]
+ r[i] = (ri + sf2h)>>(2*sfl); // range [0,255]
+ }
+ r[3] = 0;
+ } else {
+ /* Do premultiplication ourselves. */
+ for (unsigned i = 0; i != 3; ++i) {
+ // Premultiplied versions. Range [0,255*a].
+ unsigned const c00 = p00[i]*p00[3];
+ unsigned const c01 = p01[i]*p01[3];
+ unsigned const c10 = p10[i]*p10[3];
+ unsigned const c11 = p11[i]*p11[3];
+
+ // Interpolation.
+ unsigned const y0 = sf*c00 + xf*(c01-c00); // range [0,255*a*sf]
+ unsigned const y1 = sf*c10 + xf*(c11-c10); // range [0,255*a*sf]
+ unsigned const ri = sf*y0 + yf*(y1-y0); // range [0,255*a*sf*sf]
+ r[i] = (ri + ra/2) / ra; // range [0,255]
+ }
+ r[3] = (ra + sf2h)>>(2*sfl); // range [0,a]
}
- r[3] = (ra + sf2h)>>(2*sfl); // range [0,a]
}
return r;
@@ -117,19 +125,17 @@ static pixel_t interpolatePixels(NRPixBlock const* pb, double x, double y) {
template<bool MAP_PREMULTIPLIED, bool DATA_PREMULTIPLIED>
static void performDisplacement(NRPixBlock const* texture, NRPixBlock const* map, int Xchannel, int Ychannel, NRPixBlock* out, double scalex, double scaley) {
- pixel_t *out_data = reinterpret_cast<pixel_t*>(NR_PIXBLOCK_PX(out));
-
bool Xneedsdemul = MAP_PREMULTIPLIED && Xchannel<3;
bool Yneedsdemul = MAP_PREMULTIPLIED && Ychannel<3;
if (!Xneedsdemul) scalex /= 255.0;
if (!Yneedsdemul) scaley /= 255.0;
for (int yout=out->area.y0; yout < out->area.y1; yout++){
+ pixel_t const* mapRowData = reinterpret_cast<pixel_t const*>(NR_PIXBLOCK_PX(map) + (yout-map->area.y0)*map->rs);
+ pixel_t* outRowData = reinterpret_cast<pixel_t*>(NR_PIXBLOCK_PX(out) + (yout-out->area.y0)*out->rs);
for (int xout=out->area.x0; xout < out->area.x1; xout++){
- int xmap = xout;
- int ymap = yout;
+ pixel_t const mapValue = mapRowData[xout-map->area.x0];
- pixel_t mapValue = pixelValue(map, xmap, ymap);
double xtex = xout + (Xneedsdemul ? // Although the value of the pixel corresponds to the MIDDLE of the pixel, no +0.5 is needed because we're interpolating pixels anyway (so to get the actual pixel locations 0.5 would have to be subtracted again).
(mapValue[3]==0?0:(scalex * (mapValue[Xchannel] - mapValue[3]*0.5) / mapValue[3])) :
(scalex * (mapValue[Xchannel] - 127.5)));
@@ -137,7 +143,7 @@ static void performDisplacement(NRPixBlock const* texture, NRPixBlock const* map
(mapValue[3]==0?0:(scaley * (mapValue[Ychannel] - mapValue[3]*0.5) / mapValue[3])) :
(scaley * (mapValue[Ychannel] - 127.5)));
- out_data[(xout-out->area.x0) + (out->area.x1-out->area.x0)*(yout-out->area.y0)] = interpolatePixels<DATA_PREMULTIPLIED>(texture, xtex, ytex);
+ outRowData[xout-out->area.x0] = interpolatePixels<DATA_PREMULTIPLIED>(texture, xtex, ytex);
}
}
}
@@ -152,8 +158,14 @@ int FilterDisplacementMap::render(FilterSlot &slot, FilterUnits const &units) {
return 1;
}
- //TODO: check whether do we really need this check:
- if (map->area.x1 <= map->area.x0 || map->area.y1 <= map->area.y0) return 0; //nothing to do!
+ NR::IRect area = units.get_pixblock_filterarea_paraller();
+ int x0 = std::max(map->area.x0,area.min()[NR::X]);
+ int y0 = std::max(map->area.y0,area.min()[NR::Y]);
+ int x1 = std::min(map->area.x1,area.max()[NR::X]);
+ int y1 = std::min(map->area.y1,area.max()[NR::Y]);
+
+ //TODO: check whether we really need this check:
+ if (x1 <= x0 || y1 <= y0) return 0; //nothing to do!
if (texture->mode != NR_PIXBLOCK_MODE_R8G8B8A8N && texture->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) {
g_warning("Source images without an alpha channel are not supported by feDisplacementMap at the moment.");
@@ -161,13 +173,7 @@ int FilterDisplacementMap::render(FilterSlot &slot, FilterUnits const &units) {
}
NRPixBlock *out = new NRPixBlock;
-
- out->area.x0 = map->area.x0;
- out->area.y0 = map->area.y0;
- out->area.x1 = map->area.x1;
- out->area.y1 = map->area.y1;
-
- nr_pixblock_setup_fast(out, texture->mode, out->area.x0, out->area.y0, out->area.x1, out->area.y1, true);
+ nr_pixblock_setup_fast(out, texture->mode, x0, y0, x1, y1, true);
// convert to a suitable format
bool free_map_on_exit = false;
diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp
index d80782d20..9509eaef7 100644
--- a/src/display/nr-filter-gaussian.cpp
+++ b/src/display/nr-filter-gaussian.cpp
@@ -345,7 +345,7 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2,
// Filters over 1st dimension
// Assumes kernel is symmetric
-// scr_len should be size of kernel - 1
+// Kernel should have scr_len+1 elements
template<typename PT, unsigned int PC>
static void
filter2D_FIR(PT *const dst, int const dstr1, int const dstr2,
@@ -377,7 +377,7 @@ filter2D_FIR(PT *const dst, int const dstr1, int const dstr2,
for ( int c1 = 0 ; c1 < n1 ; c1++ ) {
int const src_disp = src_line + c1 * sstr1;
- int const dst_disp = dst_line + c1 * sstr1;
+ int const dst_disp = dst_line + c1 * dstr1;
// update history
for(int i=scr_len; i>0; i--) copy_n(history[i-1], PC, history[i]);
@@ -433,7 +433,7 @@ filter2D_FIR(PT *const dst, int const dstr1, int const dstr2,
// optimization: if there was no variation within this point's neighborhood,
// skip ahead while we keep seeing the same last_in byte:
// blurring flat color would not change it anyway
- if (different_count <= 1) {
+ if (different_count <= 1) { // note that different_count is at least 1, because last_in is initialized to -1
int pos = c1 + 1;
int nb_src_disp = src_disp + (1+scr_len)*sstr1 + byte; // src_line + (pos+scr_len) * sstr1 + byte
int nb_dst_disp = dst_disp + (1) *dstr1 + byte; // dst_line + (pos) * sstr1 + byte
@@ -441,7 +441,7 @@ filter2D_FIR(PT *const dst, int const dstr1, int const dstr2,
dst[nb_dst_disp] = last_in;
pos++;
nb_src_disp += sstr1;
- nb_dst_disp += sstr1;
+ nb_dst_disp += dstr1;
}
skipbuf[byte] = pos;
}
@@ -645,6 +645,8 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units)
}
}
}
+
+ // Resampling (if necessary), goes from in -> out (setting ssin to out if used)
NRPixBlock *ssin = in;
if ( resampling ) {
ssin = out;
@@ -667,6 +669,7 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units)
};
}
+ // Horizontal filtering, goes from ssin -> out (ssin might be equal to out, but these algorithms can be used in-place)
if (use_IIR_x) {
// Filter variables
IIRValue b[N+1]; // scaling coefficient + filter coefficients (can be 10.21 fixed point)
@@ -702,9 +705,9 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units)
default:
assert(false);
};
- } else if ( scr_len_x > 1 ) { // !use_IIR_x
+ } else if ( scr_len_x > 0 ) { // !use_IIR_x
// Filter kernel for x direction
- FIRValue kernel[scr_len_x];
+ FIRValue kernel[scr_len_x+1];
_make_kernel(kernel, deviation_x);
// Filter (x)
@@ -728,6 +731,7 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units)
nr_blit_pixblock_pixblock(out, ssin);
}
+ // Vertical filtering, goes from out -> out
if (use_IIR_y) {
// Filter variables
IIRValue b[N+1]; // scaling coefficient + filter coefficients (can be 10.21 fixed point)
@@ -763,9 +767,9 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units)
default:
assert(false);
};
- } else if ( scr_len_y > 1 ) { // !use_IIR_y
+ } else if ( scr_len_y > 0 ) { // !use_IIR_y
// Filter kernel for y direction
- FIRValue kernel[scr_len_y];
+ FIRValue kernel[scr_len_y+1];
_make_kernel(kernel, deviation_y);
// Filter (y)
@@ -791,6 +795,7 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units)
delete[] tmpdata[i]; // deleting a nullptr has no effect, so this is safe
}
+ // Upsampling, stores (the upsampled) out using slot.set(_output, ...)
if ( !resampling ) {
// No upsampling needed
out->empty = FALSE;
@@ -835,6 +840,7 @@ int FilterGaussian::render(FilterSlot &slot, FilterUnits const &units)
slot.set(_output, finalout);
}
+ // If we downsampled the input, clean up the downsampled data
if (in != original_in) nr_pixblock_free(in);
return 0;
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp
index d0e0ec11e..3b19ff69b 100644
--- a/src/display/nr-filter.cpp
+++ b/src/display/nr-filter.cpp
@@ -223,6 +223,14 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb)
return 0;
}
+void Filter::set_filter_units(SPFilterUnits unit) {
+ _filter_units = unit;
+}
+
+void Filter::set_primitive_units(SPFilterUnits unit) {
+ _primitive_units = unit;
+}
+
void Filter::area_enlarge(NRRectL &bbox, NRArenaItem const *item) const {
for (int i = 0 ; i < _primitive_count ; i++) {
if (_primitive[i]) _primitive[i]->area_enlarge(bbox, item->ctm);
diff --git a/src/display/pixblock-transform.cpp b/src/display/pixblock-transform.cpp
index 73b467d5a..af05a9b88 100644
--- a/src/display/pixblock-transform.cpp
+++ b/src/display/pixblock-transform.cpp
@@ -148,6 +148,11 @@ void transform_bicubic(NRPixBlock *to, NRPixBlock *from, Geom::Matrix const &tra
nr_blit_pixblock_pixblock(from, o_from);
free_from_on_exit = true;
}
+
+ if (from->mode != NR_PIXBLOCK_MODE_R8G8B8A8P) {
+ // TODO: Fix this... (The problem is that for interpolation non-premultiplied colors should be premultiplied...)
+ g_warning("transform_bicubic does not properly support non-premultiplied images");
+ }
// Precalculate sizes of source and destination pixblocks
int from_width = from->area.x1 - from->area.x0;
diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp
index 1e4ca12a8..fe5bd0371 100644
--- a/src/display/snap-indicator.cpp
+++ b/src/display/snap-indicator.cpp
@@ -55,6 +55,14 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap
return; // If we haven't snapped, then it is of no use to draw a snapindicator
}
+ if (p.getTarget() == SNAPTARGET_CONSTRAINT) {
+ // This is not a real snap, although moving along the constraint did affect the mouse pointer's position.
+ // Maybe we should only show a snap indicator when the user explicitly asked for a constraint by pressing ctrl?
+ // We should not show a snap indicator when stretching a selection box, which is also constrained. That would be
+ // too much information.
+ return;
+ }
+
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool value = prefs->getBool("/options/snapindicator/value", true);