[Xfce4-commits] <ristretto:master> Reduce the nr of floating-point divisions in the scale-calculation
Stephan Arts
noreply at xfce.org
Mon Aug 8 15:04:05 CEST 2011
Updating branch refs/heads/master
to 8b0c6156da53217712113372d804aed1d778b98d (commit)
from b8be2d00e77f3e483613204ebb601c0c273ce56a (commit)
commit 8b0c6156da53217712113372d804aed1d778b98d
Author: Stephan Arts <stephan at xfce.org>
Date: Wed Jul 20 20:39:08 2011 +0200
Reduce the nr of floating-point divisions in the scale-calculation
src/image_viewer.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/image_viewer.c b/src/image_viewer.c
index 102120f..7574698 100644
--- a/src/image_viewer.c
+++ b/src/image_viewer.c
@@ -1011,6 +1011,8 @@ static gboolean
cb_rstto_image_viewer_queued_repaint (RsttoImageViewer *viewer)
{
gint width, height;
+ gdouble v_scale, h_scale;
+
g_source_remove (viewer->priv->repaint.idle_id);
viewer->priv->repaint.idle_id = -1;
viewer->priv->repaint.refresh = FALSE;
@@ -1020,6 +1022,9 @@ cb_rstto_image_viewer_queued_repaint (RsttoImageViewer *viewer)
width = gdk_pixbuf_get_width (viewer->priv->pixbuf);
height = gdk_pixbuf_get_height (viewer->priv->pixbuf);
+ v_scale = (gdouble)(GTK_WIDGET (viewer)->allocation.height) / (gdouble)height;
+ h_scale = (gdouble)(GTK_WIDGET (viewer)->allocation.width) / (gdouble)width;
+
/*
* Scale == -1, this means the image is not loaded before,
* and it should be rendered at the best possible quality.
@@ -1037,14 +1042,13 @@ cb_rstto_image_viewer_queued_repaint (RsttoImageViewer *viewer)
* widget-dimensions and image-dimensions, the smallest
* one is used for scaling the image.
*/
- if ((gdouble)(GTK_WIDGET(viewer)->allocation.width/(gdouble)width) >
- (gdouble)(GTK_WIDGET(viewer)->allocation.height/(gdouble)height))
+ if (h_scale > v_scale)
{
- viewer->priv->scale = (gdouble)(GTK_WIDGET (viewer)->allocation.height) / (gdouble)height;
+ viewer->priv->scale = v_scale;
}
else
{
- viewer->priv->scale = (gdouble)(GTK_WIDGET (viewer)->allocation.width) / (gdouble)width;
+ viewer->priv->scale = h_scale;
}
viewer->priv->auto_scale = TRUE;
@@ -1075,14 +1079,13 @@ cb_rstto_image_viewer_queued_repaint (RsttoImageViewer *viewer)
* widget-dimensions and image-dimensions, the smallest
* one is used for scaling the image.
*/
- if ((gdouble)(GTK_WIDGET(viewer)->allocation.width/(gdouble)width) >
- (gdouble)(GTK_WIDGET(viewer)->allocation.height/(gdouble)height))
+ if (h_scale > v_scale)
{
- viewer->priv->scale = (gdouble)(GTK_WIDGET (viewer)->allocation.height) / (gdouble)height;
+ viewer->priv->scale = v_scale;
}
else
{
- viewer->priv->scale = (gdouble)(GTK_WIDGET (viewer)->allocation.width) / (gdouble)width;
+ viewer->priv->scale = h_scale;
}
}
}
More information about the Xfce4-commits
mailing list