summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
Diffstat (limited to 'src/display')
-rw-r--r--src/display/drawing-text.cpp70
-rw-r--r--src/display/drawing-text.h4
-rw-r--r--src/display/nr-filter-gaussian.cpp6
-rw-r--r--src/display/nr-filter-morphology.cpp1
-rw-r--r--src/display/nr-filter-primitive.cpp67
5 files changed, 80 insertions, 68 deletions
diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp
index 55d54b770..f37f4d3c4 100644
--- a/src/display/drawing-text.cpp
+++ b/src/display/drawing-text.cpp
@@ -197,7 +197,7 @@ DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, un
return DrawingGroup::_updateItem(area, ctx, flags, reset);
}
-void DrawingText::decorateStyle(DrawingContext &ct, double vextent, double xphase, Geom::Point p1, Geom::Point p2)
+void DrawingText::decorateStyle(DrawingContext &ct, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2)
{
double wave[16]={
0.000000, 0.382499, 0.706825, 0.923651, 1.000000, 0.923651, 0.706825, 0.382499,
@@ -311,28 +311,25 @@ pf = Geom::Point(step * round(p2[Geom::X]/step),p2[Geom::Y]);
}
/* returns scaled line thickness */
-double DrawingText::decorateItem(DrawingContext &ct, Geom::Affine aff, double phase_length)
+double DrawingText::decorateItem(DrawingContext &ct, Geom::Affine const &aff, double phase_length)
{
- double tsp_width_adj, tsp_asc_adj, tsp_size_adj;
- double final_underline_thickness, final_line_through_thickness;
- double thickness;
-
- tsp_width_adj = _nrstyle.tspan_width / _nrstyle.font_size;
- tsp_asc_adj = _nrstyle.ascender / _nrstyle.font_size;
- tsp_size_adj = (_nrstyle.ascender + _nrstyle.descender) / _nrstyle.font_size;
-#define VALTRUNC(A,B,C) (A < B ? B : ( A > C ? C : A ))
- final_underline_thickness = VALTRUNC(_nrstyle.underline_thickness, tsp_size_adj/30.0, tsp_size_adj/10.0);
- final_line_through_thickness = VALTRUNC(_nrstyle.line_through_thickness, tsp_size_adj/30.0, tsp_size_adj/10.0);
- Inkscape::DrawingContext::Save save(ct);
+ double tsp_width_adj = _nrstyle.tspan_width / _nrstyle.font_size;
+ double tsp_asc_adj = _nrstyle.ascender / _nrstyle.font_size;
+ double tsp_size_adj = (_nrstyle.ascender + _nrstyle.descender) / _nrstyle.font_size;
+
+ double final_underline_thickness = CLAMP(_nrstyle.underline_thickness, tsp_size_adj/30.0, tsp_size_adj/10.0);
+ double final_line_through_thickness = CLAMP(_nrstyle.line_through_thickness, tsp_size_adj/30.0, tsp_size_adj/10.0);
double scale = aff.descrim();
double xphase = phase_length/ _nrstyle.font_size; // used to figure out phase of patterns
+ Inkscape::DrawingContext::Save save(ct);
ct.transform(aff); // must be leftmost affine in span
+
Geom::Point p1;
Geom::Point p2;
// All lines must be the same thickness, in combinations, line_through trumps underline
- thickness = final_underline_thickness;
+ double thickness = final_underline_thickness;
if(_nrstyle.text_decoration_line & TEXT_DECORATION_LINE_UNDERLINE){
p1 = Geom::Point(0.0, -_nrstyle.underline_position);
p2 = Geom::Point(tsp_width_adj,-_nrstyle.underline_position);
@@ -393,21 +390,32 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are
bool firsty = true;
bool decorate = true;
double starty = 0.0;
- bool has_stroke, has_fill;
Geom::Affine aff;
using Geom::X;
using Geom::Y;
- has_fill = _nrstyle.prepareFill( ct, _item_bbox);
- has_stroke = _nrstyle.prepareStroke(ct, _item_bbox);
+ // NOTE:
+ // prepareFill / prepareStroke need to be called with _ctm in effect.
+ // However, we might need to apply a different ctm for glyphs.
+ // Therefore, only apply this ctm temporarily.
+ bool has_stroke, has_fill;
+ {
+ Inkscape::DrawingContext::Save save(ct);
+ ct.transform(_ctm);
+
+ has_fill = _nrstyle.prepareFill( ct, _item_bbox);
+ has_stroke = _nrstyle.prepareStroke(ct, _item_bbox);
+ }
if (has_fill || has_stroke) {
Geom::Affine rotinv;
- bool invset=false;
+ bool invset = false;
+
+ // accumulate the path that represents the glyphs
for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i);
if (!g) throw InvalidItemException();
- if(!invset){
+ if (!invset) {
rotinv = g->_ctm.withoutTranslation().inverse();
invset = true;
}
@@ -415,14 +423,14 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are
Inkscape::DrawingContext::Save save(ct);
if (g->_ctm.isSingular()) continue;
ct.transform(g->_ctm);
- if(g->_drawable){
+ if (g->_drawable) {
ct.path(*g->_font->PathVector(g->_glyph));
}
// get the leftmost affine transform (leftmost defined with respect to the x axis of the first transform).
// That way the decoration will work no matter what mix of L->R, R->L text is in the span.
- if(_nrstyle.text_decoration_line != TEXT_DECORATION_LINE_CLEAR){
- Geom::Point pt =g->_ctm.translation() * rotinv;
- if(pt[X] < leftmost){
+ if (_nrstyle.text_decoration_line != TEXT_DECORATION_LINE_CLEAR) {
+ Geom::Point pt = g->_ctm.translation() * rotinv;
+ if (pt[X] < leftmost) {
leftmost = pt[X];
aff = g->_ctm;
phase_length = g->_pl;
@@ -430,18 +438,20 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are
/* If the text has been mapped onto a path, which causes y to vary, drop the text decorations.
To handle that properly would need a conformal map
*/
- if(firsty){
+ if (firsty) {
firsty = false;
starty = pt[Y];
}
- else {
- if(fabs(pt[Y] - starty) > 1.0e-6)decorate=false;
+ else if (fabs(pt[Y] - starty) > 1.0e-6) {
+ decorate = false;
}
}
}
+ // draw the text itself
+ // we need to apply this object's ctm again
Inkscape::DrawingContext::Save save(ct);
- ct.transform(_ctm); // For one thing, this is needed to scale a fill-pattern when zooming in
+ ct.transform(_ctm);
if (has_fill) {
_nrstyle.applyFill(ct);
ct.fillPreserve();
@@ -451,9 +461,11 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are
ct.strokePreserve();
}
ct.newPath(); // clear path
- if(_nrstyle.text_decoration_line != TEXT_DECORATION_LINE_CLEAR && decorate){
+
+ // draw text decoration
+ if (_nrstyle.text_decoration_line != TEXT_DECORATION_LINE_CLEAR && decorate) {
guint32 ergba;
- if(_nrstyle.text_decoration_useColor){ // color different from the glyph
+ if (_nrstyle.text_decoration_useColor) { // color different from the glyph
ergba = SP_RGBA32_F_COMPOSE(
_nrstyle.text_decoration_color.color.v.c[0],
_nrstyle.text_decoration_color.color.v.c[1],
diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h
index 99b46bc8a..fd122b54b 100644
--- a/src/display/drawing-text.h
+++ b/src/display/drawing-text.h
@@ -68,8 +68,8 @@ protected:
virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags);
virtual bool _canClip();
- double decorateItem(DrawingContext &ct, Geom::Affine aff, double phase_length);
- void decorateStyle(DrawingContext &ct, double vextent, double xphase, Geom::Point p1, Geom::Point p2);
+ double decorateItem(DrawingContext &ct, Geom::Affine const &aff, double phase_length);
+ void decorateStyle(DrawingContext &ct, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2);
NRStyle _nrstyle;
friend class DrawingGlyphs;
diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp
index 9d7c32585..b96e24cbc 100644
--- a/src/display/nr-filter-gaussian.cpp
+++ b/src/display/nr-filter-gaussian.cpp
@@ -304,10 +304,9 @@ filter2D_IIR(PT *const dest, int const dstr1, int const dstr2,
#define PREMUL_ALPHA_LOOP for(unsigned int c=1; c<PC; ++c)
#endif
+INK_UNUSED(num_threads); // to suppress unused argument compiler warning
#if HAVE_OPENMP
#pragma omp parallel for num_threads(num_threads)
-#else
- INK_UNUSED(num_threads);
#endif // HAVE_OPENMP
for ( int c2 = 0 ; c2 < n2 ; c2++ ) {
#if HAVE_OPENMP
@@ -375,10 +374,9 @@ filter2D_FIR(PT *const dst, int const dstr1, int const dstr2,
// Past pixels seen (to enable in-place operation)
PT history[scr_len+1][PC];
+INK_UNUSED(num_threads); // suppresses unused argument compiler warning
#if HAVE_OPENMP
#pragma omp parallel for num_threads(num_threads) private(history)
-#else
- INK_UNUSED(num_threads);
#endif // HAVE_OPENMP
for ( int c2 = 0 ; c2 < n2 ; c2++ ) {
diff --git a/src/display/nr-filter-morphology.cpp b/src/display/nr-filter-morphology.cpp
index b058307cf..b6e5052e1 100644
--- a/src/display/nr-filter-morphology.cpp
+++ b/src/display/nr-filter-morphology.cpp
@@ -69,6 +69,7 @@ void morphologicalFilter1D(cairo_surface_t * const input, cairo_surface_t * cons
int limit = w * h;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int numOfThreads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256);
+ (void) numOfThreads; // suppress unused variable warning
#pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(numOfThreads)
#endif // HAVE_OPENMP
for (int i = 0; i < h; ++i) {
diff --git a/src/display/nr-filter-primitive.cpp b/src/display/nr-filter-primitive.cpp
index fca82c810..95d5d4b09 100644
--- a/src/display/nr-filter-primitive.cpp
+++ b/src/display/nr-filter-primitive.cpp
@@ -110,8 +110,16 @@ void FilterPrimitive::set_subregion(SVGLength const &x, SVGLength const &y,
Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units)
{
- Geom::OptRect bb = units.get_item_bbox();
- Geom::OptRect fa = units.get_filter_area();
+ Geom::OptRect const bb_opt = units.get_item_bbox();
+ Geom::OptRect const fa_opt = units.get_filter_area();
+ Geom::Rect bb;
+ Geom::Rect fa;
+ if (!bb_opt || !fa_opt) {
+ return Geom::Rect (Geom::Point(0.,0.), Geom::Point(0.,0.));
+ } else {
+ bb = *bb_opt;
+ fa = *fa_opt;
+ }
// This is definitely a hack... but what else to do?
// Current viewport might not be document viewport... but how to find?
@@ -127,8 +135,8 @@ Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units)
/* Update computed values for ex, em, %. For %, assumes primitive unit is objectBoundingBox. */
/* TODO: fetch somehow the object ex and em lengths; 12, 6 are just dummy values. */
- double len_x = bb->width();
- double len_y = bb->height();
+ double len_x = bb.width();
+ double len_y = bb.height();
_subregion_x.update(12, 6, len_x);
_subregion_y.update(12, 6, len_y);
_subregion_width.update(12, 6, len_x);
@@ -143,44 +151,37 @@ Geom::Rect FilterPrimitive::filter_primitive_area(FilterUnits const &units)
double height = 0;
// If subregion not set, by special case use filter region.
- if( !_subregion_x._set ) x = fa->min()[X];
- if( !_subregion_y._set ) y = fa->min()[Y];
- if( !_subregion_width._set ) width = fa->width();
- if( !_subregion_height._set ) height = fa->height();
+ if( !_subregion_x._set ) x = fa.min()[X];
+ if( !_subregion_y._set ) y = fa.min()[Y];
+ if( !_subregion_width._set ) width = fa.width();
+ if( !_subregion_height._set ) height = fa.height();
if( units.get_primitive_units() == SP_FILTER_UNITS_OBJECTBOUNDINGBOX ) {
// Values are in terms of fraction of bounding box.
- if( _subregion_x._set && _subregion_x.unit != SVGLength::PERCENT ) x = bb->min()[X] + bb->width() * _subregion_x.value;
- if( _subregion_y._set && _subregion_y.unit != SVGLength::PERCENT ) y = bb->min()[Y] + bb->height() * _subregion_y.value;
- if( _subregion_width._set && _subregion_width.unit != SVGLength::PERCENT ) width = bb->width() * _subregion_width.value;
- if( _subregion_height._set && _subregion_height.unit != SVGLength::PERCENT ) height = bb->height() * _subregion_height.value;
- // Values are in terms of percent
- if( _subregion_x._set && _subregion_x.unit == SVGLength::PERCENT ) x = bb->min()[X] + _subregion_x.computed;
- if( _subregion_y._set && _subregion_y.unit == SVGLength::PERCENT ) y = bb->min()[Y] + _subregion_y.computed;
- if( _subregion_width._set && _subregion_width.unit == SVGLength::PERCENT ) width = _subregion_width.computed;
- if( _subregion_height._set && _subregion_height.unit == SVGLength::PERCENT ) height = _subregion_height.computed;
+ if( _subregion_x._set && (_subregion_x.unit != SVGLength::PERCENT) ) x = bb.min()[X] + bb.width() * _subregion_x.value;
+ if( _subregion_y._set && (_subregion_y.unit != SVGLength::PERCENT) ) y = bb.min()[Y] + bb.height() * _subregion_y.value;
+ if( _subregion_width._set && (_subregion_width.unit != SVGLength::PERCENT) ) width = bb.width() * _subregion_width.value;
+ if( _subregion_height._set && (_subregion_height.unit != SVGLength::PERCENT) ) height = bb.height() * _subregion_height.value;
+ // Values are in terms of percent
+ if( _subregion_x._set && (_subregion_x.unit == SVGLength::PERCENT) ) x = bb.min()[X] + _subregion_x.computed;
+ if( _subregion_y._set && (_subregion_y.unit == SVGLength::PERCENT) ) y = bb.min()[Y] + _subregion_y.computed;
+ if( _subregion_width._set && (_subregion_width.unit == SVGLength::PERCENT) ) width = _subregion_width.computed;
+ if( _subregion_height._set && (_subregion_height.unit == SVGLength::PERCENT) ) height = _subregion_height.computed;
} else {
// Values are in terms of user space coordinates or percent of viewbox (yuck!),
// which is usually the size of SVG drawing. Default.
- if( _subregion_x._set && _subregion_x.unit != SVGLength::PERCENT ) x = _subregion_x.computed;
- if( _subregion_y._set && _subregion_y.unit != SVGLength::PERCENT ) y = _subregion_y.computed;
- if( _subregion_width._set && _subregion_width.unit != SVGLength::PERCENT ) width = _subregion_width.computed;
- if( _subregion_height._set && _subregion_height.unit != SVGLength::PERCENT ) height = _subregion_height.computed;
+ if( _subregion_x._set && (_subregion_x.unit != SVGLength::PERCENT) ) x = _subregion_x.computed;
+ if( _subregion_y._set && (_subregion_y.unit != SVGLength::PERCENT) ) y = _subregion_y.computed;
+ if( _subregion_width._set && (_subregion_width.unit != SVGLength::PERCENT) ) width = _subregion_width.computed;
+ if( _subregion_height._set && (_subregion_height.unit != SVGLength::PERCENT) ) height = _subregion_height.computed;
// Percent of viewport
- if( _subregion_x._set && _subregion_x.unit == SVGLength::PERCENT ) x = _subregion_x.value * viewport.width();
- if( _subregion_y._set && _subregion_y.unit == SVGLength::PERCENT ) y = _subregion_y.value * viewport.height();
- if( _subregion_width._set && _subregion_width.unit == SVGLength::PERCENT ) width = _subregion_width.value * viewport.width();
- if( _subregion_height._set && _subregion_height.unit == SVGLength::PERCENT ) height = _subregion_height.value * viewport.height();
+ if( _subregion_x._set && (_subregion_x.unit == SVGLength::PERCENT) ) x = _subregion_x.value * viewport.width();
+ if( _subregion_y._set && (_subregion_y.unit == SVGLength::PERCENT) ) y = _subregion_y.value * viewport.height();
+ if( _subregion_width._set && (_subregion_width.unit == SVGLength::PERCENT) ) width = _subregion_width.value * viewport.width();
+ if( _subregion_height._set && (_subregion_height.unit == SVGLength::PERCENT) ) height = _subregion_height.value * viewport.height();
}
- Geom::Point minp, maxp;
- minp[X] = x;
- minp[Y] = y;
- maxp[X] = x + width;
- maxp[Y] = y + height;
-
- Geom::Rect area(minp, maxp);
- return area;
+ return Geom::Rect (Geom::Point(x,y), Geom::Point(x + width, y + height));
}
void FilterPrimitive::setStyle(SPStyle *style)