From 7b92f54929315654f0a5ac3417c54d5592227870 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 29 Jul 2019 03:55:31 +0200 Subject: Fix random off-by-one issue when vertically zooming a waveform To mitigate concurrent rendering, the waveform cache adds a random range of pixels centered around the visible waveform. Alignment is using integer half_width = width_samples / 2; This always aligns the left-edge to the left-most cairo-pixel. This fixes an issue with moving moiree patterns in waveforms when zooming vertically (which invalidates the cache and uses a different random number of pixels), --- libs/waveview/wave_view.cc | 4 ++-- libs/waveview/waveview/wave_view_private.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libs/waveview') diff --git a/libs/waveview/wave_view.cc b/libs/waveview/wave_view.cc index 7b7f7c28eb..938e85fd2a 100644 --- a/libs/waveview/wave_view.cc +++ b/libs/waveview/wave_view.cc @@ -1159,8 +1159,8 @@ WaveView::render (Rect const & area, Cairo::RefPtr context) cons double x = self.x0 + image_origin_in_self_coordinates; double y = self.y0; context->user_to_device (x, y); - x = round (x); - y = round (y); + x = floor (x); + y = floor (y); context->device_to_user (x, y); /* the coordinates specify where in "user coordinates" (i.e. what we diff --git a/libs/waveview/waveview/wave_view_private.h b/libs/waveview/waveview/wave_view_private.h index d3cf88c7e7..2a5a94b90b 100644 --- a/libs/waveview/waveview/wave_view_private.h +++ b/libs/waveview/waveview/wave_view_private.h @@ -140,7 +140,7 @@ public: // methods return sample_end - sample_start; } - samplepos_t get_center_sample () + samplepos_t get_center_sample () const { return sample_start + (get_length_samples() / 2); } -- cgit v1.2.3