[librsvg] Avoid repeatedly calculating floor and ceil values here
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Avoid repeatedly calculating floor and ceil values here
- Date: Mon, 7 Nov 2011 19:27:27 +0000 (UTC)
commit e005c4ad97fade8193e077414351a919db0f9447
Author: Christian Persch <chpe gnome org>
Date: Fri Sep 16 01:22:08 2011 +0200
Avoid repeatedly calculating floor and ceil values here
rsvg-filter.c | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/rsvg-filter.c b/rsvg-filter.c
index e63a440..fe694c4 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -172,6 +172,7 @@ gdk_pixbuf_get_interp_pixel (guchar * src, gdouble ox, gdouble oy, guchar ch, Rs
double xmod, ymod;
double dist1, dist2, dist3, dist4;
double c, c1, c2, c3, c4;
+ double fox, foy, cox, coy;
xmod = fmod (ox, 1.0);
ymod = fmod (oy, 1.0);
@@ -181,29 +182,34 @@ gdk_pixbuf_get_interp_pixel (guchar * src, gdouble ox, gdouble oy, guchar ch, Rs
dist3 = (xmod) * (ymod);
dist4 = (1 - xmod) * (ymod);
- if (floor (ox) <= boundarys.x0 || floor (ox) >= boundarys.x1 ||
- floor (oy) <= boundarys.y0 || floor (oy) >= boundarys.y1)
+ fox = floor (ox);
+ foy = floor (oy);
+ cox = ceil (ox);
+ coy = ceil (oy);
+
+ if (fox <= boundarys.x0 || fox >= boundarys.x1 ||
+ foy <= boundarys.y0 || foy >= boundarys.y1)
c1 = 0;
else
- c1 = src[(guint) floor (oy) * rowstride + (guint) floor (ox) * 4 + ch];
+ c1 = src[(guint) foy * rowstride + (guint) fox * 4 + ch];
- if (ceil (ox) <= boundarys.x0 || ceil (ox) >= boundarys.x1 ||
- floor (oy) <= boundarys.y0 || floor (oy) >= boundarys.y1)
+ if (cox <= boundarys.x0 || cox >= boundarys.x1 ||
+ foy <= boundarys.y0 || foy >= boundarys.y1)
c2 = 0;
else
- c2 = src[(guint) floor (oy) * rowstride + (guint) ceil (ox) * 4 + ch];
+ c2 = src[(guint) foy * rowstride + (guint) cox * 4 + ch];
- if (ceil (ox) <= boundarys.x0 || ceil (ox) >= boundarys.x1 ||
- ceil (oy) <= boundarys.y0 || ceil (oy) >= boundarys.y1)
+ if (cox <= boundarys.x0 || cox >= boundarys.x1 ||
+ coy <= boundarys.y0 || coy >= boundarys.y1)
c3 = 0;
else
- c3 = src[(guint) ceil (oy) * rowstride + (guint) ceil (ox) * 4 + ch];
+ c3 = src[(guint) coy * rowstride + (guint) cox * 4 + ch];
- if (floor (ox) <= boundarys.x0 || floor (ox) >= boundarys.x1 ||
- ceil (oy) <= boundarys.y0 || ceil (oy) >= boundarys.y1)
+ if (fox <= boundarys.x0 || fox >= boundarys.x1 ||
+ coy <= boundarys.y0 || coy >= boundarys.y1)
c4 = 0;
else
- c4 = src[(guint) ceil (oy) * rowstride + (guint) floor (ox) * 4 + ch];
+ c4 = src[(guint) coy * rowstride + (guint) fox * 4 + ch];
c = (c1 * dist1 + c2 * dist2 + c3 * dist3 + c4 * dist4) / (dist1 + dist2 + dist3 + dist4);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]