summaryrefslogtreecommitdiffstats
path: root/src/sp-pattern.cpp
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-10-29 22:40:05 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-10-29 22:40:05 +0000
commite9943b70c7bf507b9639ecb0a421bcee7ce93e33 (patch)
tree2d2fe7ee7a566e1ef1a5dcde18296d9f21188f35 /src/sp-pattern.cpp
parenti18n. Fixing untranslated strings. (diff)
parentMerge with trunk r13640 (diff)
downloadinkscape-e9943b70c7bf507b9639ecb0a421bcee7ce93e33.tar.gz
inkscape-e9943b70c7bf507b9639ecb0a421bcee7ce93e33.zip
Merge experimental
(bzr r13641)
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);
}
}