diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-10-12 12:37:18 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-10-12 12:37:18 +0000 |
| commit | 9248a27415b51ae5674dd79d1738cf8f0549806f (patch) | |
| tree | 7ee74806627058a1cc5c871805ccbb9779990e98 /src/display | |
| parent | Fix rendering issue on panning with text tool (diff) | |
| download | inkscape-9248a27415b51ae5674dd79d1738cf8f0549806f.tar.gz inkscape-9248a27415b51ae5674dd79d1738cf8f0549806f.zip | |
Move from deprecated GTimeVal to g_get_monotonic_time()
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/drawing-shape.cpp | 9 | ||||
| -rw-r--r-- | src/display/sp-canvas.cpp | 68 | ||||
| -rw-r--r-- | src/display/sp-canvas.h | 2 |
3 files changed, 23 insertions, 56 deletions
diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 20544e1be..70995073b 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -345,8 +345,8 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, unsigned flags) // fully transparent, no pick unless outline mode return nullptr; - GTimeVal tstart, tfinish; - g_get_current_time (&tstart); + + gint64 tstart = g_get_monotonic_time(); double width; if (pick_as_clip) { @@ -379,10 +379,9 @@ DrawingShape::_pickItem(Geom::Point const &p, double delta, unsigned flags) pathv_matrix_point_bbox_wind_distance(_curve->get_pathvector(), _ctm, p, nullptr, needfill? &wind : nullptr, &dist, 0.5, nullptr); } - g_get_current_time (&tfinish); - glong this_pick = (tfinish.tv_sec - tstart.tv_sec) * 1000000 + (tfinish.tv_usec - tstart.tv_usec); + gint64 tfinish = g_get_monotonic_time(); + gint64 this_pick = tfinish - tstart; //g_print ("pick time %lu\n", this_pick); - if (this_pick > 10000) { // slow picking, remember to skip several new picks _repick_after = this_pick / 5000; } diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 932e8755c..b33dd20b6 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1022,10 +1022,7 @@ static void sp_canvas_init(SPCanvas *canvas) canvas->_delayrendering = 0; canvas->_totalelapsed = 0; canvas->_scrooling = false; - GTimeZone *tz = g_time_zone_new(nullptr); - canvas->_idle_time = g_date_time_new_now(tz); - g_time_zone_unref(tz); - + canvas->_idle_time = g_get_monotonic_time(); bool _is_dragging; #if defined(HAVE_LIBLCMS2) @@ -1058,9 +1055,6 @@ void SPCanvas::dispose(GObject *object) cairo_surface_destroy(canvas->_backing_store); canvas->_backing_store = nullptr; } - if (canvas->_idle_time) { - g_date_time_unref(canvas->_idle_time); - } #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) if (canvas->_surface_for_similar) { cairo_surface_destroy(canvas->_surface_for_similar); @@ -2071,18 +2065,15 @@ void SPCanvas::paintSpliter() struct PaintRectSetup { Geom::IntRect canvas_rect; - GDateTime *start_time; + gint64 start_time; int max_pixels; Geom::Point mouse_loc; }; int SPCanvas::paintRectInternal(PaintRectSetup const *setup, Geom::IntRect const &this_rect) { - GTimeZone *tz = g_time_zone_new(nullptr); - GDateTime *now = g_date_time_new_now(tz); - g_time_zone_unref(tz); - gint64 elapsed = (gint64)g_date_time_difference(now, setup->start_time); - g_date_time_unref(now); + gint64 now = g_get_monotonic_time(); + gint64 elapsed = now - setup->start_time; // if we do canvas resize or panning we want the canvas not redraw in enought times // to make a smooth response. @@ -2244,13 +2235,9 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) } // Start the clock - GTimeZone *tz = g_time_zone_new(nullptr); - setup.start_time = g_date_time_new_now(tz); - g_time_zone_unref(tz); + setup.start_time = g_get_monotonic_time(); // Go - bool ret = paintRectInternal(&setup, paint_rect); - g_date_time_unref(setup.start_time); - return ret; + return paintRectInternal(&setup, paint_rect); } void SPCanvas::forceFullRedrawAfterInterruptions(unsigned int count) @@ -2557,15 +2544,11 @@ gint SPCanvas::idle_handler(gpointer data) SPCanvas *canvas = SP_CANVAS (data); #ifdef DEBUG_PERFORMANCE static int totaloops = 1; - GTimeZone *tz = nullptr; - GDateTime *now = nullptr; + gint64 now = 0; gint64 elapsed = 0; if (!canvas->_delayrendering) { - tz = g_time_zone_new(nullptr); - now = g_date_time_new_now(tz); - g_time_zone_unref(tz); - elapsed = (gint64)g_date_time_difference(now, canvas->_idle_time); - g_date_time_unref(now); + now = g_get_monotonic_time(); + elapsed = now - canvas->_idle_time; g_message("[%i] start loop %i in split %i at %f", canvas->_idle_id, totaloops, canvas->_splits, canvas->_totalelapsed / (double)1000000 + elapsed / (double)1000000); } @@ -2578,11 +2561,8 @@ gint SPCanvas::idle_handler(gpointer data) #ifdef DEBUG_PERFORMANCE if (ret == 0 && !canvas->_delayrendering) { - tz = g_time_zone_new(nullptr); - now = g_date_time_new_now(tz); - g_time_zone_unref(tz); - elapsed = (gint64)g_date_time_difference(now, canvas->_idle_time); - g_date_time_unref(now); + now = g_get_monotonic_time(); + elapsed = now - canvas->_idle_time; g_message("[%i] loop ended unclean at %f", canvas->_idle_id, canvas->_totalelapsed / (double)1000000 + elapsed / (double)1000000); } @@ -2594,11 +2574,8 @@ gint SPCanvas::idle_handler(gpointer data) canvas->_scrooling = false; canvas->_forcefull = false; canvas->_delayrendering = 0; - tz = g_time_zone_new(nullptr); - now = g_date_time_new_now(tz); - g_time_zone_unref(tz); - elapsed = (gint64)g_date_time_difference(now, canvas->_idle_time); - g_date_time_unref(now); + now = g_get_monotonic_time(); + elapsed = now - canvas->_idle_time; canvas->_totalelapsed += elapsed; SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) { @@ -2635,10 +2612,7 @@ void SPCanvas::addIdle() { if (_idle_id == 0) { #ifdef DEBUG_PERFORMANCE - g_date_time_unref(_idle_time); - GTimeZone *tz = g_time_zone_new(nullptr); - _idle_time = g_date_time_new_now(tz); - g_time_zone_unref(tz); + _idle_time = g_get_monotonic_time(); #endif _idle_id = gdk_threads_add_idle_full(UPDATE_PRIORITY, idle_handler, this, nullptr); #ifdef DEBUG_PERFORMANCE @@ -2779,21 +2753,15 @@ void SPCanvas::updateNow() { if (_need_update) { #ifdef DEBUG_PERFORMANCE - GTimeZone *tz = g_time_zone_new(nullptr); - GDateTime *now = g_date_time_new_now(tz); - g_time_zone_unref(tz); - gint64 elapsed = (gint64)g_date_time_difference(now, _idle_time); - g_date_time_unref(now); + guint64 now = g_get_monotonic_time(); + gint64 elapsed = now - _idle_time; g_message("[%i] start updateNow(): %f at %f", _idle_id, elapsed / (double)1000000, _totalelapsed / (double)1000000 + elapsed / (double)1000000); #endif doUpdate(); #ifdef DEBUG_PERFORMANCE - tz = g_time_zone_new(nullptr); - now = g_date_time_new_now(tz); - g_time_zone_unref(tz); - elapsed = (gint64)g_date_time_difference(now, _idle_time); - g_date_time_unref(now); + now = g_get_monotonic_time(); + elapsed = now - _idle_time; g_message("[%i] end updateNow(): %f at %f", _idle_id, elapsed / (double)1000000, _totalelapsed / (double)1000000 + elapsed / (double)1000000); #endif diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 3e7424363..48a404b43 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -210,7 +210,7 @@ public: bool _scrooling; int _delayrendering; int _device_scale; ///< Scale for high DPI montiors - GDateTime *_idle_time; + gint64 _idle_time; int _splits; gint64 _totalelapsed; |
