From: joncruz Date: Sun, 27 Jul 2008 06:22:56 +0000 (+0000) Subject: Add tracking of skew factor and display in warning message. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1d55f93a54a61c40523eaa9e1d55fc836ac880f9;p=inkscape.git Add tracking of skew factor and display in warning message. --- diff --git a/src/debug/gdk-event-latency-tracker.cpp b/src/debug/gdk-event-latency-tracker.cpp index 6a8a48eb3..cfd5a9b71 100644 --- a/src/debug/gdk-event-latency-tracker.cpp +++ b/src/debug/gdk-event-latency-tracker.cpp @@ -16,7 +16,7 @@ namespace Inkscape { namespace Debug { GdkEventLatencyTracker::GdkEventLatencyTracker() - : start_seconds(0.0), max_latency(0.0), skew(1.0) + : start_seconds(0.0), max_latency(0.0), skew(1.0), last_elapsed(0.0), last_seconds(0.0) { elapsed.stop(); elapsed.reset(); @@ -35,7 +35,9 @@ boost::optional GdkEventLatencyTracker::process(GdkEvent const *event) { skew = prefs_get_double_attribute_limited("debug.latency", "skew", 1.0, 0.5, 2.0); return boost::optional(0.0); } else { - double const current_seconds = (elapsed.elapsed() * skew) + start_seconds; + last_elapsed = elapsed.elapsed(); + last_seconds = timestamp_seconds; + double const current_seconds = (last_elapsed * skew) + start_seconds; double delta = current_seconds - timestamp_seconds; if (delta < 0.0) { start_seconds += -delta; @@ -47,6 +49,14 @@ boost::optional GdkEventLatencyTracker::process(GdkEvent const *event) { } } +double GdkEventLatencyTracker::getSkew() { + double val = 0.0; + if ((last_elapsed > 0.0) && (last_seconds > 0.0)) { + val = (last_seconds - start_seconds) / last_elapsed; + } + return val; +} + GdkEventLatencyTracker &GdkEventLatencyTracker::default_tracker() { static GdkEventLatencyTracker tracker; return tracker; diff --git a/src/debug/gdk-event-latency-tracker.h b/src/debug/gdk-event-latency-tracker.h index cb04ee035..5a05baf48 100644 --- a/src/debug/gdk-event-latency-tracker.h +++ b/src/debug/gdk-event-latency-tracker.h @@ -24,6 +24,7 @@ public: GdkEventLatencyTracker(); boost::optional process(GdkEvent const *e); double maxLatency() const { return max_latency; } + double getSkew(); static GdkEventLatencyTracker &default_tracker(); @@ -34,6 +35,8 @@ private: double start_seconds; double max_latency; double skew; + double last_elapsed; + double last_seconds; Glib::Timer elapsed; }; diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ba0209969..592085bcd 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1105,7 +1105,7 @@ static void track_latency(GdkEvent const *event) { GdkEventLatencyTracker &tracker = GdkEventLatencyTracker::default_tracker(); boost::optional latency = tracker.process(event); if (latency && *latency > 2.0) { - g_warning("Event latency reached %f sec", *latency); + g_warning("Event latency reached %f sec (%1.4f)", *latency, tracker.getSkew()); } }