index 906d9166c9d63edc85cc89807215893c5240d67d..d5a098c391d91ef390ea47a3aa8d32f65a241311 100644 (file)
#include "display/nr-filter.h"
#include <typeinfo>
#include <cairo.h>
+#include "preferences.h"
+#include "svg/svg-device-color.h"
#include <glib.h>
#include "svg/svg.h"
@@ -365,7 +367,6 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
item->bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F);
item->bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.0F);
item->bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.0F);
- nr_arena_request_render_rect(item->arena, &item->bbox);
item->render_opacity = TRUE;
if ( shape->_fill.paint.type() == NRArenaShape::Paint::SERVER ) {
if (!shape->style) return item->state;
bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE);
+ bool print_colors = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW);
if (outline) { // cairo outline rendering
@@ -874,7 +876,22 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
}
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
SPStyle const *style = shape->style;
+ bool render_cyan = prefs->getBool("/options/printcolorspreview/cyan", true);
+ bool render_magenta = prefs->getBool("/options/printcolorspreview/magenta", true);
+ bool render_yellow = prefs->getBool("/options/printcolorspreview/yellow", true);
+ bool render_black = prefs->getBool("/options/printcolorspreview/black", true);
+
+ float rgb_v[3];
+ float cmyk_v[4];
+#define FLOAT_TO_UINT8(f) (int(f*255))
+#define RGBA_R(v) ((v) >> 24)
+#define RGBA_G(v) (((v) >> 16) & 0xff)
+#define RGBA_B(v) (((v) >> 8) & 0xff)
+#define RGBA_A(v) ((v) & 0xff)
+
if (shape->fill_shp) {
NRPixBlock m;
guint32 rgba;
@@ -894,12 +911,24 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
if (shape->_fill.paint.type() == NRArenaShape::Paint::NONE) {
// do not render fill in any way
} else if (shape->_fill.paint.type() == NRArenaShape::Paint::COLOR) {
+
+ const SPColor* fill_color = &shape->_fill.paint.color();
if ( item->render_opacity ) {
- rgba = shape->_fill.paint.color().toRGBA32( shape->_fill.opacity *
- SP_SCALE24_TO_FLOAT(style->opacity.value) );
+ rgba = fill_color->toRGBA32( shape->_fill.opacity *
+ SP_SCALE24_TO_FLOAT(style->opacity.value) );
} else {
- rgba = shape->_fill.paint.color().toRGBA32( shape->_fill.opacity );
+ rgba = fill_color->toRGBA32( shape->_fill.opacity );
+ }
+
+ if (print_colors){
+ sp_color_rgb_to_cmyk_floatv (cmyk_v, RGBA_R(rgba)/256.0, RGBA_G(rgba)/256.0, RGBA_B(rgba)/256.0);
+ sp_color_cmyk_to_rgb_floatv (rgb_v, render_cyan ? cmyk_v[0] : 0,
+ render_magenta ? cmyk_v[1] : 0,
+ render_yellow ? cmyk_v[2] : 0,
+ render_black ? cmyk_v[3] : 0);
+ rgba = (FLOAT_TO_UINT8(rgb_v[0])<<24) + (FLOAT_TO_UINT8(rgb_v[1])<<16) + (FLOAT_TO_UINT8(rgb_v[2])<<8) + 0xff;
}
+
nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
pb->empty = FALSE;
} else if (shape->_fill.paint.type() == NRArenaShape::Paint::SERVER) {
@@ -930,14 +959,25 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
nr_pixblock_render_shape_mask_or(m, shape->stroke_shp);
m.empty = FALSE;
- if ( item->render_opacity ) {
- rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity *
- SP_SCALE24_TO_FLOAT(style->opacity.value) );
- } else {
- rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity );
- }
- nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
- pb->empty = FALSE;
+ const SPColor* stroke_color = &shape->_stroke.paint.color();
+ if ( item->render_opacity ) {
+ rgba = stroke_color->toRGBA32( shape->_stroke.opacity *
+ SP_SCALE24_TO_FLOAT(style->opacity.value) );
+ } else {
+ rgba = stroke_color->toRGBA32( shape->_stroke.opacity );
+ }
+
+ if (print_colors){
+ sp_color_rgb_to_cmyk_floatv (cmyk_v, RGBA_R(rgba)/256.0, RGBA_G(rgba)/256.0, RGBA_B(rgba)/256.0);
+ sp_color_cmyk_to_rgb_floatv (rgb_v, render_cyan ? cmyk_v[0] : 0,
+ render_magenta ? cmyk_v[1] : 0,
+ render_yellow ? cmyk_v[2] : 0,
+ render_black ? cmyk_v[3] : 0);
+ rgba = (FLOAT_TO_UINT8(rgb_v[0])<<24) + (FLOAT_TO_UINT8(rgb_v[1])<<16) + (FLOAT_TO_UINT8(rgb_v[2])<<8) + 0xff;
+ }
+
+ nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
+ pb->empty = FALSE;
nr_pixblock_release(&m);
if (style->filter.set && style->getFilter()) {
if (!shape->filter) {
int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter()));
- shape->filter = new NR::Filter(primitives);
+ shape->filter = new Inkscape::Filters::Filter(primitives);
}
sp_filter_build_renderer(SP_FILTER(style->getFilter()), shape->filter);
} else {