summaryrefslogtreecommitdiffstats
path: root/src/sp-pattern.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp-pattern.cpp')
-rw-r--r--src/sp-pattern.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index e465565c4..9aa54eadf 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -541,6 +541,16 @@ static bool pattern_hasItemChildren (SPPattern const *pat)
return hasChildren;
}
+bool SPPattern::isValid() const
+{
+ double tile_width = pattern_width(this);
+ double tile_height = pattern_height(this);
+
+ if (tile_width <= 0 || tile_height <= 0)
+ return false;
+ return true;
+}
+
cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &bbox, double opacity) {
bool needs_opacity = (1.0 - opacity) >= 1e-3;
@@ -593,7 +603,7 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b
double tile_y = pattern_y(this);
double tile_width = pattern_width(this);
double tile_height = pattern_height(this);
- if (pattern_patternUnits(this) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
+ if ( bbox && (pattern_patternUnits(this) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) ) {
tile_x *= bbox->width();
tile_y *= bbox->height();
tile_width *= bbox->width();
@@ -614,7 +624,7 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b
} else {
// Content to bbox
- if (pattern_patternContentUnits (this) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
+ if (bbox && (pattern_patternContentUnits(this) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) ) {
content2ps = Geom::Affine(bbox->width(), 0.0, 0.0, bbox->height(), 0,0);
}
}