summaryrefslogtreecommitdiffstats
path: root/src/sp-pattern.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-11-23 23:36:49 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-11-23 23:36:49 +0000
commit0969085ddf607a7a98cf7fd6d9b10da5fbebe62d (patch)
tree59b2bc9ed3412ab2de4c703ef30342dfe2401704 /src/sp-pattern.cpp
parentrefactor from lastApplied (diff)
parentFixed a bug pointed by suv running from comand line, also removed another des... (diff)
downloadinkscape-0969085ddf607a7a98cf7fd6d9b10da5fbebe62d.tar.gz
inkscape-0969085ddf607a7a98cf7fd6d9b10da5fbebe62d.zip
fixing to trunk
(bzr r12588.1.34)
Diffstat (limited to 'src/sp-pattern.cpp')
-rw-r--r--src/sp-pattern.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index e465565c4..961ab0f84 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -18,7 +18,9 @@
#include <cstring>
#include <string>
+#include <glibmm.h>
#include <2geom/transforms.h>
+
#include "macros.h"
#include "svg/svg.h"
#include "display/cairo-utils.h"
@@ -541,6 +543,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 +605,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();
@@ -605,16 +617,17 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b
// Content to tile (pattern space)
Geom::Affine content2ps;
- if (this->viewBox_set) {
+ Geom::OptRect effective_view_box = pattern_viewBox(this);
+ if (effective_view_box) {
// viewBox to pattern server (using SPViewBox)
- viewBox = *pattern_viewBox(this);
+ viewBox = *effective_view_box;
c2p.setIdentity();
apply_viewbox( pattern_tile );
content2ps = c2p;
} 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);
}
}