summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomasz Boczkowski <penginsbacon@gmail.com>2014-05-16 20:53:46 +0000
committerTomasz Boczkowski <penginsbacon@gmail.com>2014-05-16 20:53:46 +0000
commitb4c6736390839c53251011ab5c536e020c02bda0 (patch)
treeaafe6c9366af1974c9969583b870e7453c456e8b /src
parentfurther tweaks to build-x64.xml. (diff)
downloadinkscape-b4c6736390839c53251011ab5c536e020c02bda0.tar.gz
inkscape-b4c6736390839c53251011ab5c536e020c02bda0.zip
fix compliance test pservers-pattern-03-f - using fallback when pattern is empty
(bzr r13341.1.34)
Diffstat (limited to 'src')
-rw-r--r--src/display/nr-style.cpp18
-rw-r--r--src/sp-paint-server.cpp5
-rw-r--r--src/sp-paint-server.h1
-rw-r--r--src/sp-pattern.cpp10
-rw-r--r--src/sp-pattern.h2
5 files changed, 34 insertions, 2 deletions
diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp
index ec3117079..a9f101f69 100644
--- a/src/display/nr-style.cpp
+++ b/src/display/nr-style.cpp
@@ -95,7 +95,14 @@ NRStyle::~NRStyle()
void NRStyle::set(SPStyle *style)
{
if ( style->fill.isPaintserver() ) {
- fill.set(style->getFillPaintServer());
+ SPPaintServer* server = style->getFillPaintServer();
+ if ( server && server->isValid() ) {
+ fill.set(server);
+ } else if ( style->fill.colorSet ) {
+ fill.set(style->fill.value.color);
+ } else {
+ fill.clear();
+ }
} else if ( style->fill.isColor() ) {
fill.set(style->fill.value.color);
} else if ( style->fill.isNone() ) {
@@ -117,7 +124,14 @@ void NRStyle::set(SPStyle *style)
}
if ( style->stroke.isPaintserver() ) {
- stroke.set(style->getStrokePaintServer());
+ SPPaintServer* server = style->getStrokePaintServer();
+ if ( server && server->isValid() ) {
+ stroke.set(server);
+ } else if ( style->stroke.isColor() ) {
+ stroke.set(style->stroke.colorSet);
+ } else {
+ stroke.clear();
+ }
} else if ( style->stroke.isColor() ) {
stroke.set(style->stroke.value.color);
} else if ( style->stroke.isNone() ) {
diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp
index 692265bd8..77ad7a35f 100644
--- a/src/sp-paint-server.cpp
+++ b/src/sp-paint-server.cpp
@@ -58,6 +58,11 @@ bool SPPaintServer::isSolid() const
return solid;
}
+bool SPPaintServer::isValid() const
+{
+ return true;
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h
index 02e2f10ec..c1c8d651e 100644
--- a/src/sp-paint-server.h
+++ b/src/sp-paint-server.h
@@ -29,6 +29,7 @@ public:
bool isSwatch() const;
bool isSolid() const;
+ virtual bool isValid() const;
virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) = 0;
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index cc82c637e..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;
diff --git a/src/sp-pattern.h b/src/sp-pattern.h
index f69ba10b3..eb34b6714 100644
--- a/src/sp-pattern.h
+++ b/src/sp-pattern.h
@@ -56,6 +56,8 @@ public:
sigc::connection modified_connection;
+ bool isValid() const;
+
virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity);
protected: