[libchamplain/libchamplain-0-4] Optimize, don't redraw the scale too often
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain/libchamplain-0-4] Optimize, don't redraw the scale too often
- Date: Wed, 6 Jan 2010 04:39:56 +0000 (UTC)
commit fa8b6f256d7f0437cea1af909d762dca4103b55f
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date: Tue Jan 5 23:25:13 2010 -0500
Optimize, don't redraw the scale too often
champlain/champlain-view.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 2803184..d7a3a5d 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -1101,6 +1101,8 @@ button_release_cb (ClutterActor *actor,
static void
update_scale (ChamplainView *view)
{
+ static gfloat previous_m_per_pixel = 0.0;
+
gboolean is_small_unit = TRUE; /* indicates if using meters */
ClutterActor *text, *line;
gfloat width;
@@ -1113,7 +1115,7 @@ update_scale (ChamplainView *view)
gfloat factor;
gboolean final_unit = FALSE;
- if (!priv || !priv->map || !priv->map->current_level)
+ if (!priv->map || !priv->map->current_level)
return;
if (priv->show_scale)
@@ -1129,6 +1131,12 @@ update_scale (ChamplainView *view)
m_per_pixel = champlain_map_source_get_meters_per_pixel (priv->map_source,
priv->zoom_level, priv->latitude, priv->longitude);
+ /* Don't redraw too often */
+ if (fabs (m_per_pixel - previous_m_per_pixel) < 0.01)
+ return;
+
+ previous_m_per_pixel = m_per_pixel;
+
if (priv->scale_unit == CHAMPLAIN_UNIT_MILES)
m_per_pixel *= 3.28; /* m_per_pixel is now in ft */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]