summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7fa0549)
raw | patch | inline | side by side (parent: 7fa0549)
author | pjrm <pjrm@users.sourceforge.net> | |
Mon, 3 Apr 2006 05:12:46 +0000 (05:12 +0000) | ||
committer | pjrm <pjrm@users.sourceforge.net> | |
Mon, 3 Apr 2006 05:12:46 +0000 (05:12 +0000) |
src/style.cpp | patch | blob | history | |
src/style.h | patch | blob | history |
diff --git a/src/style.cpp b/src/style.cpp
index c826c2831c46f8fd819eababa700e4e50cd53dbe..3693c5d2b9a76af7e723f26f221f80eccad1a8ae 100644 (file)
--- a/src/style.cpp
+++ b/src/style.cpp
#include "svg/svg.h"
#include "svg/svg-color.h"
+#include "svg/svg-icc-color.h"
#include "display/canvas-bpath.h"
#include "attributes.h"
#include "xml/repr.h"
#include "unit-constants.h"
#include "isnan.h"
+using Inkscape::CSSOStringStream;
+using std::vector;
namespace Inkscape {
@@ -2899,13 +2902,20 @@ sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocume
}
}
} else {
- guint32 const rgb0 = sp_svg_read_color(str, 0xff);
+ guint32 const rgb0 = sp_svg_read_color(str, &str, 0xff);
if (rgb0 != 0xff) {
paint->type = SP_PAINT_TYPE_COLOR;
sp_color_set_rgb_rgba32(&paint->value.color, rgb0);
paint->set = TRUE;
paint->inherit = FALSE;
paint->currentcolor = FALSE;
+
+ while (g_ascii_isspace(*str)) {
+ ++str;
+ }
+ if (strneq(str, "icc-color(", 10)) {
+ /* fixme: Parse icc-color to paint->iccColor here. */
+ }
}
}
}
if (a->type != b->type)
return true;
if (a->type == SP_PAINT_TYPE_COLOR)
- return !sp_color_is_equal(&a->value.color, &b->value.color);
+ return !(sp_color_is_equal(&a->value.color, &b->value.color)
+ && ((a->iccColor == b->iccColor)
+ || (a->iccColor && b->iccColor
+ && (a->iccColor->colorProfile == b->iccColor->colorProfile)
+ && (a->iccColor->colors == b->iccColor->colors))));
+ /* todo: Allow for epsilon differences in iccColor->colors, e.g. changes small enough not to show up
+ * in the string representation. */
if (a->type == SP_PAINT_TYPE_PAINTSERVER)
return (a->value.paint.server != b->value.paint.server);
return false;
case SP_PAINT_TYPE_COLOR: {
char color_buf[8];
sp_svg_write_color(color_buf, sizeof(color_buf), sp_color_get_rgba32_ualpha(&paint->value.color, 0));
- return g_snprintf(b, len, "%s:%s;", key, color_buf);
+ if (paint->iccColor) {
+ CSSOStringStream css;
+ css << color_buf << " icc-color(" << paint->iccColor->colorProfile;
+ for (vector<double>::const_iterator i(paint->iccColor->colors.begin()),
+ iEnd(paint->iccColor->colors.end());
+ i != iEnd; ++i) {
+ css << ", " << *i;
+ }
+ css << ')';
+ return g_snprintf(b, len, "%s:%s;", key, css.gcharp());
+ } else {
+ return g_snprintf(b, len, "%s:%s;", key, color_buf);
+ }
}
case SP_PAINT_TYPE_PAINTSERVER:
return g_snprintf(b, len, "%s:url(%s);", key, paint->value.paint.uri);
}
paint->value.paint.server = NULL;
- paint->value.paint.uri = NULL;
- paint->type = SP_PAINT_TYPE_NONE;
}
+ paint->value.paint.uri = NULL;
+ paint->type = SP_PAINT_TYPE_NONE;
+ delete paint->iccColor;
+ paint->iccColor = NULL;
}
/**
diff --git a/src/style.h b/src/style.h
index cfd3334cc9c50de4a6ba1c9a86b7836cd8e6845f..703a55fdb9c8bfb3b0b2e69b66927a036c291088 100644 (file)
--- a/src/style.h
+++ b/src/style.h
SP_PAINT_TYPE_IMPOSSIBLE
};
+class SVGICCColor;
+
/// Paint type internal to SPStyle.
struct SPIPaint {
unsigned set : 1;
gchar *uri;
} paint;
} value;
+ SVGICCColor *iccColor;
};
enum {