From: Felipe C. da S. Sanches Date: Fri, 11 Dec 2009 09:16:15 +0000 (-0200) Subject: refactoring of previous commit + add separation to glyph renderer also X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6a5bad17d250040f824f2347b33968a915bee56b;p=inkscape.git refactoring of previous commit + add separation to glyph renderer also --- diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 429f1ed32..db0922915 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -444,6 +444,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi SPStyle const *style = ggroup->style; guint ret = item->state; + bool print_colors_preview = (item->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW); if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { @@ -511,6 +512,10 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi } else { rgba = style->fill.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->fill_opacity.value) ); } + + if (print_colors_preview) + nr_arena_separate_color_plates(&rgba); + nr_blit_pixblock_mask_rgba32(pb, &m, rgba); pb->empty = FALSE; } @@ -551,6 +556,10 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi } else { rgba = style->stroke.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->stroke_opacity.value) ); } + + if (print_colors_preview) + nr_arena_separate_color_plates(&rgba); + nr_blit_pixblock_mask_rgba32(pb, &m, rgba); pb->empty = FALSE; } else { diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index d5a098c39..e2a9e9580 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -36,7 +36,6 @@ #include #include #include "preferences.h" -#include "svg/svg-device-color.h" #include #include "svg/svg.h" @@ -833,7 +832,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. */ @@ -846,7 +844,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock 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 +874,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 +904,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 +945,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; diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index 74e0f409c..33870a118 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -18,6 +18,7 @@ #include "nr-filter-types.h" #include #include "preferences.h" +#include "color.h" static void nr_arena_class_init (NRArenaClass *klass); static void nr_arena_init (NRArena *arena); @@ -181,6 +182,29 @@ nr_arena_set_renderoffscreen (NRArena *arena) } +#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) + +void nr_arena_separate_color_plates(guint32* rgba){ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + 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]; + 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; +} + /* Local Variables: mode:c++ diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h index 1c091b7c7..d2f9dc246 100644 --- a/src/display/nr-arena.h +++ b/src/display/nr-arena.h @@ -64,4 +64,6 @@ void nr_arena_set_renderoffscreen (NRArena *arena); void nr_arena_render_paintserver_fill (NRPixBlock *pb, NRRectL *area, SPPainter *painter, float opacity, NRPixBlock *mask); +void nr_arena_separate_color_plates(guint32* rgba); + #endif