From 50ccd73592e2e6c73826e9d1929846b180910249 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Sat, 16 Jun 2018 20:22:53 -0700 Subject: [PATCH] visualizers: use double instead of float To give us less changes of incorrect values when converting between scales (at the cost of 2x the array size). --- lib/util/pointcache.c | 4 ++-- lib/util/pointcache.h | 8 ++++---- lib/visualizers/sp-line-visualizer-row.c | 14 +++++++------- lib/visualizers/sp-visualizer-row.h | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/util/pointcache.c b/lib/util/pointcache.c index 6530e46d..ccdf1406 100644 --- a/lib/util/pointcache.c +++ b/lib/util/pointcache.c @@ -80,8 +80,8 @@ point_cache_contains_set (PointCache *self, void point_cache_add_point_to_set (PointCache *self, guint set_id, - gfloat x, - gfloat y) + gdouble x, + gdouble y) { GArray *ar; Point point = { x, y }; diff --git a/lib/util/pointcache.h b/lib/util/pointcache.h index 1058df79..5accceb7 100644 --- a/lib/util/pointcache.h +++ b/lib/util/pointcache.h @@ -27,8 +27,8 @@ typedef struct _PointCache PointCache; typedef struct { - gfloat x; - gfloat y; + gdouble x; + gdouble y; } Point; PointCache *point_cache_new (void); @@ -40,8 +40,8 @@ gboolean point_cache_contains_set (PointCache *self, guint set_id); void point_cache_add_point_to_set (PointCache *self, guint set_id, - gfloat x, - gfloat y); + gdouble x, + gdouble y); const Point *point_cache_get_points (PointCache *self, guint set_id, guint *n_points); diff --git a/lib/visualizers/sp-line-visualizer-row.c b/lib/visualizers/sp-line-visualizer-row.c index e00594b7..b69d8840 100644 --- a/lib/visualizers/sp-line-visualizer-row.c +++ b/lib/visualizers/sp-line-visualizer-row.c @@ -170,8 +170,8 @@ sp_line_visualizer_row_draw (GtkWidget *widget, if (n_fpoints > 0) { - gfloat last_x; - gfloat last_y; + gdouble last_x; + gdouble last_y; points = g_new0 (SpVisualizerRowAbsolutePoint, n_fpoints); @@ -534,7 +534,7 @@ counter_type (LoadData *load, return SP_CAPTURE_COUNTER_DOUBLE; } -static inline gfloat +static inline gdouble calc_x (gint64 lower, gint64 upper, gint64 value) @@ -542,7 +542,7 @@ calc_x (gint64 lower, return (gdouble)(value - lower) / (gdouble)(upper - lower); } -static inline gfloat +static inline gdouble calc_y_double (gdouble lower, gdouble upper, gdouble value) @@ -550,7 +550,7 @@ calc_y_double (gdouble lower, return (value - lower) / (upper - lower); } -static inline gfloat +static inline gdouble calc_y_int64 (gint64 lower, gint64 upper, gint64 value) @@ -572,7 +572,7 @@ sp_line_visualizer_row_load_data_frame_cb (const SpCaptureFrame *frame, if (frame->type == SP_CAPTURE_FRAME_CTRSET) { const SpCaptureFrameCounterSet *set = (SpCaptureFrameCounterSet *)frame; - gfloat x = calc_x (load->begin_time, load->end_time, frame->time); + gdouble x = calc_x (load->begin_time, load->end_time, frame->time); for (guint i = 0; i < set->n_values; i++) { @@ -584,7 +584,7 @@ sp_line_visualizer_row_load_data_frame_cb (const SpCaptureFrame *frame, if (counter_id != 0 && contains_id (load->lines, counter_id)) { - gfloat y; + gdouble y; if (counter_type (load, counter_id) == SP_CAPTURE_COUNTER_DOUBLE) y = calc_y_double (load->y_lower, load->y_upper, group->values[j].vdbl); diff --git a/lib/visualizers/sp-visualizer-row.h b/lib/visualizers/sp-visualizer-row.h index c7f61631..2f15d959 100644 --- a/lib/visualizers/sp-visualizer-row.h +++ b/lib/visualizers/sp-visualizer-row.h @@ -32,8 +32,8 @@ G_DECLARE_DERIVABLE_TYPE (SpVisualizerRow, sp_visualizer_row, SP, VISUALIZER_ROW typedef struct { - gfloat x; - gfloat y; + gdouble x; + gdouble y; } SpVisualizerRowRelativePoint; typedef struct