diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-10-09 06:05:56 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-10-09 06:05:56 +0000 |
| commit | 5a2dae366dd8d2797b55b0cd0eb801d2e03f0176 (patch) | |
| tree | 17a5c707895752d7599e211f4d43f3fad16491b6 | |
| parent | Last string change to this file moved today from skip files to translate fil... (diff) | |
| download | inkscape-5a2dae366dd8d2797b55b0cd0eb801d2e03f0176.tar.gz inkscape-5a2dae366dd8d2797b55b0cd0eb801d2e03f0176.zip | |
Improve node selection ~x3 removing unneded updateNow() called in non necesary places. Also ensure canvas is always redraw
| -rw-r--r-- | src/display/sp-canvas.cpp | 33 | ||||
| -rw-r--r-- | src/ui/tool/multi-path-manipulator.cpp | 7 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 10 | ||||
| -rw-r--r-- | src/verbs.cpp | 4 |
4 files changed, 41 insertions, 13 deletions
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 62edc36c4..5014343e0 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -57,7 +57,7 @@ static bool const HAS_BROKEN_MOTION_HINTS = true; // Define this to visualize the regions to be redrawn //#define DEBUG_REDRAW 1; -// Define this to output the time spent in a full iddle loop and the number of "tiles" painted +// Define this to output the time spent in a full idle loop and the number of "tiles" painted //#define DEBUG_PERFORMANCE 1; // Tiles are a way to minimize the number of redraws, eliminating too small redraws. @@ -2535,17 +2535,19 @@ int SPCanvas::doUpdate() gint SPCanvas::idle_handler(gpointer data) { SPCanvas *canvas = SP_CANVAS (data); - int const ret = canvas->doUpdate(); + int ret = canvas->doUpdate(); + int n_rects = cairo_region_num_rectangles(canvas->_clean_region); + if (n_rects > 1) { // not fully painted, maybe clean region is updated in middle of idle, reload again + ret = 0; + } #ifdef DEBUG_PERFORMANCE - static gint totaloops = 1; - if (!ret) { - totaloops++; + static int totaloops = 1; + if (ret == 0) { + totaloops += 1; } -#endif if (ret) { // Reset idle id canvas->_idle_id = 0; -#ifdef DEBUG_PERFORMANCE static glong totalelapsed = 0; GTimeVal now; g_get_current_time (&now); @@ -2567,6 +2569,10 @@ gint SPCanvas::idle_handler(gpointer data) } totaloops = 1; canvas->_splits = 0; +#else + if (ret) { + // Reset idle id + canvas->_idle_id = 0; #endif } return !ret; @@ -2713,7 +2719,20 @@ void SPCanvas::scrollTo( Geom::Point const &c, unsigned int clear, bool is_scrol void SPCanvas::updateNow() { if (_need_update) { +#ifdef DEBUG_PERFORMANCE + GTimeVal now; + g_get_current_time (&now); + glong elapsed = (now.tv_sec - _idle_time.tv_sec) * 1000000 + + (now.tv_usec - _idle_time.tv_usec); + g_message("updateNow() started %f", elapsed/(double)1000000); +#endif doUpdate(); +#ifdef DEBUG_PERFORMANCE + g_get_current_time (&now); + elapsed = (now.tv_sec - _idle_time.tv_sec) * 1000000 + + (now.tv_usec - _idle_time.tv_usec); + g_message("updateNow() ended %f", elapsed/(double)1000000); +#endif } } diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 90662237e..544ababbe 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -181,7 +181,11 @@ void MultiPathManipulator::setItems(std::set<ShapeRecord> const &s) } // add newly selected items + bool updatecanvas = false; for (const auto & r : shapes) { + if (IS_LIVEPATHEFFECT(r.item)) { + updatecanvas = true; + } if (!SP_IS_PATH(r.item) && !IS_LIVEPATHEFFECT(r.item)) continue; std::shared_ptr<PathManipulator> newpm(new PathManipulator(*this, (SPPath*) r.item, r.edit_transform, _getOutlineColor(r.role, r.item), r.lpe_key)); @@ -193,6 +197,9 @@ void MultiPathManipulator::setItems(std::set<ShapeRecord> const &s) newpm->setLiveObjects(_live_objects); _mmap.insert(std::make_pair(r, newpm)); } + if (updatecanvas) { + _desktop->updateNow(); + } } void MultiPathManipulator::selectSubpaths() diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 63161b3cd..937c1a657 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -458,7 +458,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { this->_multipath->setItems(shapes); this->update_tip(nullptr); - this->desktop->updateNow(); + // This not need to be called canvas is updated on selection change on setItems + // this->desktop->updateNow(); } bool NodeTool::root_handler(GdkEvent* event) { @@ -548,7 +549,7 @@ bool NodeTool::root_handler(GdkEvent* event) { SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(flash), 0, SP_WIND_RULE_NONZERO); - + desktop->canvas->forceFullRedrawAfterInterruptions(5); this->flash_tempitem = desktop->add_temporary_canvasitem(flash, prefs->getInt("/tools/nodes/pathflash_timeout", 500)); @@ -631,6 +632,7 @@ bool NodeTool::root_handler(GdkEvent* event) { } } } + desktop->canvas->forceFullRedrawAfterInterruptions(5); break; default: @@ -777,8 +779,8 @@ void NodeTool::select_point(Geom::Point const &/*sel*/, GdkEventButton *event) { } else { selection->set(item_clicked); } - - this->desktop->updateNow(); + // This not need to be called canvas is updated on selection change + // this->desktop->updateNow(); } } diff --git a/src/verbs.cpp b/src/verbs.cpp index 3ba863cdf..d41ae11e0 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2101,8 +2101,8 @@ void ZoomVerb::perform(SPAction *action, void *data) default: break; } - - dt->updateNow(); + // this is not needed canvas is updated correctly in all + // dt->updateNow(); } // end of sp_verb_action_zoom_perform() |
