index d5a098c391d91ef390ea47a3aa8d32f65a241311..a3b295a4efcae5b18b255eaec1be3ce2df1f2a6b 100644 (file)
#include <typeinfo>
#include <cairo.h>
#include "preferences.h"
-#include "svg/svg-device-color.h"
#include <glib.h>
#include "svg/svg.h"
@@ -255,12 +254,11 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
if (state & NR_ARENA_ITEM_STATE_BBOX) {
if (shape->curve) {
boundingbox = bounds_exact_transformed(shape->curve->get_pathvector(), gc->transform);
- /// \todo just write item->bbox = boundingbox
if (boundingbox) {
- item->bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F);
- item->bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F);
- item->bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F);
- item->bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F);
+ item->bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0])); // Floor gives the coordinate in which the point resides
+ item->bbox.y0 = static_cast<NR::ICoord>(floor((*boundingbox)[1][0]));
+ item->bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1])); // Ceil gives the first coordinate beyond the point
+ item->bbox.y1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[1][1]));
} else {
item->bbox = NR_RECT_L_EMPTY;
}
@@ -301,10 +299,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
/// \todo just write item->bbox = boundingbox
if (boundingbox) {
- shape->approx_bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F);
- shape->approx_bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F);
- shape->approx_bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F);
- shape->approx_bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F);
+ shape->approx_bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0]));
+ shape->approx_bbox.y0 = static_cast<NR::ICoord>(floor((*boundingbox)[1][0]));
+ shape->approx_bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1]));
+ shape->approx_bbox.y1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[1][1]));
} else {
shape->approx_bbox = NR_RECT_L_EMPTY;
}
@@ -350,10 +348,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
/// \todo just write shape->approx_bbox = boundingbox
if (boundingbox) {
- shape->approx_bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F);
- shape->approx_bbox.y0 = (gint32)((*boundingbox)[1][0] - 1.0F);
- shape->approx_bbox.x1 = (gint32)((*boundingbox)[0][1] + 1.9999F);
- shape->approx_bbox.y1 = (gint32)((*boundingbox)[1][1] + 1.9999F);
+ shape->approx_bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0]));
+ shape->approx_bbox.y0 = static_cast<NR::ICoord>(floor((*boundingbox)[1][0]));
+ shape->approx_bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1]));
+ shape->approx_bbox.y1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[1][1]));
} else {
shape->approx_bbox = NR_RECT_L_EMPTY;
}
@@ -363,10 +361,10 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g
return NR_ARENA_ITEM_STATE_ALL;
/// \todo just write item->bbox = boundingbox
- item->bbox.x0 = (gint32)((*boundingbox)[0][0] - 1.0F);
- 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);
+ item->bbox.x0 = static_cast<NR::ICoord>(floor((*boundingbox)[0][0]));
+ item->bbox.y0 = static_cast<NR::ICoord>(floor((*boundingbox)[1][0]));
+ item->bbox.x1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[0][1]));
+ item->bbox.y1 = static_cast<NR::ICoord>(ceil ((*boundingbox)[1][1]));
item->render_opacity = TRUE;
if ( shape->_fill.paint.type() == NRArenaShape::Paint::SERVER ) {
@@ -833,7 +831,6 @@ cairo_arena_shape_render_stroke(NRArenaItem *item, NRRectL *area, NRPixBlock *pb
pb->empty = FALSE;
}
-
/**
* Renders the item. Markers are just composed into the parent buffer.
*/
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);
+ bool print_colors_preview = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW);
if (outline) { // cairo outline rendering
@@ -876,21 +873,7 @@ 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;
@@ -920,14 +903,8 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
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;
- }
+ if (print_colors_preview)
+ nr_arena_separate_color_plates(&rgba);
nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
pb->empty = FALSE;
@@ -967,14 +944,8 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
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;
- }
+ if (print_colors_preview)
+ nr_arena_separate_color_plates(&rgba);
nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
pb->empty = FALSE;