From 927588ff91c017f1aa17ccd74a777228e4f94d47 Mon Sep 17 00:00:00 2001 From: mental Date: Mon, 31 Mar 2008 02:44:19 +0000 Subject: [PATCH] lay groundwork for non-filter view mode --- src/desktop.cpp | 15 ++++++++------- src/desktop.h | 6 ++++-- src/display/Makefile_insert | 1 + src/display/canvas-arena.cpp | 4 ++-- src/display/nr-arena-glyphs.cpp | 10 +++++----- src/display/nr-arena-image.cpp | 4 ++-- src/display/nr-arena-item.cpp | 14 ++++++++------ src/display/nr-arena-shape.cpp | 8 ++++---- src/display/nr-arena.cpp | 2 +- src/display/nr-arena.h | 10 +++------- src/display/rendermode.h | 29 +++++++++++++++++++++++++++++ src/display/sp-canvas.cpp | 13 ++++--------- src/widgets/desktop-widget.cpp | 4 ++-- 13 files changed, 73 insertions(+), 47 deletions(-) create mode 100644 src/display/rendermode.h diff --git a/src/desktop.cpp b/src/desktop.cpp index 922da935d..657d42304 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -145,6 +145,7 @@ SPDesktop::SPDesktop() : gr_point_type( 0 ), gr_point_i( 0 ), gr_fill_or_stroke( true ), + displayMode(Inkscape::RENDERMODE_NORMAL), _layer_hierarchy( 0 ), _reconstruction_old_layer_id( 0 ), _widget( 0 ), @@ -415,25 +416,25 @@ SPDesktop::remove_temporary_canvasitem (Inkscape::Display::TemporaryItem * tempi void SPDesktop::setDisplayModeNormal() { - SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_NORMAL; - canvas->rendermode = RENDERMODE_NORMAL; // canvas needs that for choosing the best buffer size - displayMode = RENDERMODE_NORMAL; + SP_CANVAS_ARENA (drawing)->arena->rendermode = Inkscape::RENDERMODE_NORMAL; + canvas->rendermode = Inkscape::RENDERMODE_NORMAL; // canvas needs that for choosing the best buffer size + displayMode = Inkscape::RENDERMODE_NORMAL; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw _widget->setTitle(SP_DOCUMENT_NAME(sp_desktop_document(this))); } void SPDesktop::setDisplayModeOutline() { - SP_CANVAS_ARENA (drawing)->arena->rendermode = RENDERMODE_OUTLINE; - canvas->rendermode = RENDERMODE_OUTLINE; // canvas needs that for choosing the best buffer size - displayMode = RENDERMODE_OUTLINE; + SP_CANVAS_ARENA (drawing)->arena->rendermode = Inkscape::RENDERMODE_OUTLINE; + canvas->rendermode = Inkscape::RENDERMODE_OUTLINE; // canvas needs that for choosing the best buffer size + displayMode = Inkscape::RENDERMODE_OUTLINE; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw _widget->setTitle(SP_DOCUMENT_NAME(sp_desktop_document(this))); } void SPDesktop::displayModeToggle() { - if (displayMode == RENDERMODE_OUTLINE) + if (displayMode == Inkscape::RENDERMODE_OUTLINE) setDisplayModeNormal(); else setDisplayModeOutline(); diff --git a/src/desktop.h b/src/desktop.h index 52bb91c76..672cd2b5c 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -35,6 +35,8 @@ #include "ui/view/view.h" #include "ui/view/edit-widget-interface.h" +#include "display/rendermode.h" + class NRRect; class SPCSSAttr; struct _GtkWidget; @@ -188,8 +190,8 @@ struct SPDesktop : public Inkscape::UI::View::View void setDisplayModeNormal(); void setDisplayModeOutline(); void displayModeToggle(); - int displayMode; - int getMode() const { return displayMode; } + Inkscape::RenderMode displayMode; + Inkscape::RenderMode getMode() const { return displayMode; } Inkscape::UI::Widget::Dock* getDock() { return _widget->getDock(); } diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert index d7b0fb608..2e27cc188 100644 --- a/src/display/Makefile_insert +++ b/src/display/Makefile_insert @@ -55,6 +55,7 @@ display_libspdisplay_a_SOURCES = \ display/nr-plain-stuff-gdk.h \ display/nr-plain-stuff.cpp \ display/nr-plain-stuff.h \ + display/rendermode.h \ display/snap-indicator.cpp \ display/snap-indicator.h \ display/sodipodi-ctrl.cpp \ diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index f1a991434..f813a03c9 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -212,7 +212,7 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) // from here the sw/sh calculation, the loop, and creating the intermediate buffer, allowing arena // just render into buf in one go. - if (arena->arena->rendermode != RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients + if (arena->arena->rendermode != Inkscape::RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients /* 256K is the cached buffer and we need 4 channels */ if (bw * bh < 65536) { // 256K/4 /* We can go with single buffer */ @@ -294,7 +294,7 @@ streamline rendering. if (pb.empty == FALSE) { - if (arena->arena->rendermode == RENDERMODE_OUTLINE) { + if (arena->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { // currently we only use cairo in outline mode // ENDIANNESS FIX diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 9456e8a7e..6ee1be796 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -444,7 +444,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi guint ret = item->state; - if (item->arena->rendermode == RENDERMODE_OUTLINE) { + if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { if (!ct) return item->state; @@ -473,7 +473,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi /* Fill */ - if (!style->fill.isNone() || item->arena->rendermode == RENDERMODE_OUTLINE) { + if (!style->fill.isNone() || item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { NRPixBlock m; nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE); @@ -499,9 +499,9 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi if (ggroup->fill_painter) { nr_arena_render_paintserver_fill(pb, area, ggroup->fill_painter, SP_SCALE24_TO_FLOAT(style->fill_opacity.value), &m); } - } else if (style->fill.isColor() || item->arena->rendermode == RENDERMODE_OUTLINE) { + } else if (style->fill.isColor() || item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { guint32 rgba; - if (item->arena->rendermode == RENDERMODE_OUTLINE) { + if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) { // In outline mode, render fill only, using outlinecolor rgba = item->arena->outlinecolor; } else if ( item->render_opacity ) { @@ -518,7 +518,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi } /* Stroke */ - if (!style->stroke.isNone() && !(item->arena->rendermode == RENDERMODE_OUTLINE)) { + if (!style->stroke.isNone() && !(item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE)) { NRPixBlock m; guint32 rgba; nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE); diff --git a/src/display/nr-arena-image.cpp b/src/display/nr-arena-image.cpp index a2050f75c..fa250e52e 100644 --- a/src/display/nr-arena-image.cpp +++ b/src/display/nr-arena-image.cpp @@ -180,7 +180,7 @@ nr_arena_image_render( cairo_t *ct, NRArenaItem *item, NRRectL */*area*/, NRPixB nr_arena_image_x_sample = prefs_get_int_attribute ("options.bitmapoversample", "value", 1); nr_arena_image_y_sample = nr_arena_image_x_sample; - bool outline = (item->arena->rendermode == RENDERMODE_OUTLINE); + bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); NRArenaImage *image = NR_ARENA_IMAGE (item); @@ -294,7 +294,7 @@ nr_arena_image_pick( NRArenaItem *item, NR::Point p, double delta, unsigned int if (!image->px) return NULL; - bool outline = (item->arena->rendermode == RENDERMODE_OUTLINE); + bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); if (outline) { diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index f04146f20..195dba2f0 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -207,6 +207,7 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, unsigned int state, unsigned int reset) { NRGC childgc (gc); + bool filter = (item->arena->rendermode == Inkscape::RENDERMODE_NORMAL); nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), @@ -259,7 +260,7 @@ nr_arena_item_invoke_update (NRArenaItem *item, NRRectL *area, NRGC *gc, if (item->state & NR_ARENA_ITEM_STATE_INVALID) return item->state; /* Enlarge the bounding box to contain filter effects */ - if (item->filter) { + if (item->filter && filter) { item->filter->bbox_enlarge (item->bbox); } // fixme: to fix the display glitches, in outline mode bbox must be a combination of @@ -300,7 +301,8 @@ unsigned int nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area, NRPixBlock *pb, unsigned int flags) { - bool outline = (item->arena->rendermode == RENDERMODE_OUTLINE); + bool outline = (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); + bool filter = (item->arena->rendermode == Inkscape::RENDERMODE_NORMAL); nr_return_val_if_fail (item != NULL, NR_ARENA_ITEM_STATE_INVALID); nr_return_val_if_fail (NR_IS_ARENA_ITEM (item), @@ -321,7 +323,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area nr_rect_l_intersect (&carea, area, &item->bbox); if (nr_rect_l_test_empty (&carea)) return item->state | NR_ARENA_ITEM_STATE_RENDER; - if (item->filter && !outline) { + if (item->filter && filter) { item->filter->area_enlarge (carea, item->ctm); nr_rect_l_intersect (&carea, &carea, &item->bbox); } @@ -400,7 +402,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area /* Determine, whether we need temporary buffer */ if (item->clip || item->mask || ((item->opacity != 255) && !item->render_opacity) - || (item->filter) || item->background_new + || (item->filter && filter) || item->background_new || (item->parent && item->parent->background_pb)) { /* Setup and render item buffer */ @@ -423,7 +425,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area } ipb.visible_area = pb->visible_area; - if (item->filter) { + if (item->filter && filter) { item->filter->area_enlarge (ipb.visible_area, item->ctm); } @@ -439,7 +441,7 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area ipb.empty = FALSE; /* Run filtering, if a filter is set for this object */ - if (item->filter) { + if (item->filter && filter) { item->filter->render (item, &ipb); } diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 8e53e7262..5676b3ce6 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -273,7 +273,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g bbox.x0 = bbox.y0 = NR_HUGE; bbox.x1 = bbox.y1 = -NR_HUGE; - bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE); + bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); if (shape->curve) { NRBPath bp; @@ -521,7 +521,7 @@ nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc, NRRectL *area) float const scale = NR::expansion(gc->transform); - bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE); + bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); if (outline) { // cairo does not need the livarot path for rendering @@ -852,7 +852,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock if (!shape->curve) return item->state; if (!shape->style) return item->state; - bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE); + bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); if (outline) { // cairo outline rendering @@ -1089,7 +1089,7 @@ nr_arena_shape_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int / GTimeVal tstart, tfinish; g_get_current_time (&tstart); - bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == RENDERMODE_OUTLINE); + bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE); double width; if (outline) { diff --git a/src/display/nr-arena.cpp b/src/display/nr-arena.cpp index f125cd0f8..77701d249 100644 --- a/src/display/nr-arena.cpp +++ b/src/display/nr-arena.cpp @@ -52,7 +52,7 @@ static void nr_arena_init (NRArena *arena) { arena->delta = 0; // to be set by desktop from prefs - arena->rendermode = RENDERMODE_NORMAL; // default is normal render + arena->rendermode = Inkscape::RENDERMODE_NORMAL; // default is normal render arena->outlinecolor = 0xff; // black; to be set by desktop from bg color arena->canvasarena = NULL; } diff --git a/src/display/nr-arena.h b/src/display/nr-arena.h index b6d5a4539..1a042b355 100644 --- a/src/display/nr-arena.h +++ b/src/display/nr-arena.h @@ -15,6 +15,8 @@ #include +#include "display/rendermode.h" + G_BEGIN_DECLS typedef struct _SPCanvasArena SPCanvasArena; @@ -38,19 +40,13 @@ struct NRArenaEventVector { void (* request_render) (NRArena *arena, NRRectL *area, void *data); }; -enum { - RENDERMODE_NORMAL, - RENDERMODE_NOAA, - RENDERMODE_OUTLINE -}; - struct NRArena : public NRActiveObject { static NRArena *create() { return reinterpret_cast(nr_object_new(NR_TYPE_ARENA)); } double delta; - int rendermode; + Inkscape::RenderMode rendermode; guint32 outlinecolor; SPCanvasArena *canvasarena; // may be NULL is this arena is not the screen but used for export etc. }; diff --git a/src/display/rendermode.h b/src/display/rendermode.h new file mode 100644 index 000000000..3153a979c --- /dev/null +++ b/src/display/rendermode.h @@ -0,0 +1,29 @@ +/* + * RenderMode enumeration. + * + * Trivially public domain. + */ + +#ifndef SEEN_INKSCAPE_DISPLAY_RENDERMODE_H +#define SEEN_INKSCAPE_DISPLAY_RENDERMODE_H + +namespace Inkscape { + +enum RenderMode { + RENDERMODE_NORMAL, + RENDERMODE_OUTLINE +}; + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 86b1e9eab..357d6ade7 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -39,6 +39,7 @@ #if ENABLE_LCMS #include "color-profile-fns.h" #endif // ENABLE_LCMS +#include "display/rendermode.h" // Define this to visualize the regions to be redrawn //#define DEBUG_REDRAW 1; @@ -48,12 +49,6 @@ // If any part of it is dirtied, the entire tile is dirtied (its int is nonzero) and repainted. #define TILE_SIZE 16 -enum { - RENDERMODE_NORMAL, - RENDERMODE_NOAA, - RENDERMODE_OUTLINE -}; - static gint const sp_canvas_update_priority = G_PRIORITY_HIGH_IDLE; #define SP_CANVAS_WINDOW(c) (((GtkWidget *) (c))->window) @@ -1563,7 +1558,7 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, GtkWidget *widget = GTK_WIDGET (canvas); SPCanvasBuf buf; - if (canvas->rendermode != RENDERMODE_OUTLINE) { + if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { buf.buf = nr_pixelstore_256K_new (FALSE, 0); } else { buf.buf = nr_pixelstore_1M_new (FALSE, 0); @@ -1655,7 +1650,7 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, x0 - canvas->x0, y0 - canvas->y0); } - if (canvas->rendermode != RENDERMODE_OUTLINE) { + if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { nr_pixelstore_256K_free (buf.buf); } else { nr_pixelstore_1M_free (buf.buf); @@ -1826,7 +1821,7 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1) setup.mouse_loc = sp_canvas_window_to_world (canvas, NR::Point(x,y)); // CAIRO FIXME: the sw/sh calculations below all assume 24bpp, need fixing for 32bpp - if (canvas->rendermode != RENDERMODE_OUTLINE) { + if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients // 256K is the cached buffer and we need 3 channels setup.max_pixels = 87381; // 256K/3 diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index b8e01eb6c..997b9c86f 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -612,13 +612,13 @@ SPDesktopWidget::updateTitle(gchar const* uri) : g_basename(uri) ); GString *name = g_string_new (""); if (this->desktop->number > 1) { - if (this->desktop->getMode() == RENDERMODE_OUTLINE) { + if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) { g_string_printf (name, _("%s: %d (outline) - Inkscape"), fname, this->desktop->number); } else { g_string_printf (name, _("%s: %d - Inkscape"), fname, this->desktop->number); } } else { - if (this->desktop->getMode() == RENDERMODE_OUTLINE) { + if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) { g_string_printf (name, _("%s (outline) - Inkscape"), fname); } else { g_string_printf (name, _("%s - Inkscape"), fname); -- 2.30.2