summaryrefslogtreecommitdiff
path: root/render/imagecache.c
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2008-02-13 09:14:58 -0500
committerMikael Magnusson <mikachu@comhem.se>2008-02-14 11:44:51 +0100
commit1d62584742f5c95ff3720ad4f50c59afc018a235 (patch)
tree5907855f2e2e543737e671a1fb13e3618ff03c29 /render/imagecache.c
parent0cd9986f87c0ad678fd112e5b8fc286105599228 (diff)
pre-calc the sum of a picture added to an RrImage rather than calculating it every time
Diffstat (limited to 'render/imagecache.c')
-rw-r--r--render/imagecache.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/render/imagecache.c b/render/imagecache.c
index 9ebaec13..9c605f9d 100644
--- a/render/imagecache.c
+++ b/render/imagecache.c
@@ -18,6 +18,7 @@
#include "render.h"
#include "imagecache.h"
+#include "image.h"
static gboolean RrImagePicEqual(const RrImagePic *p1,
const RrImagePic *p2);
@@ -56,9 +57,8 @@ RrImage* RrImageCacheFind(RrImageCache *self,
RrPixel32 *data, gint w, gint h)
{
RrImagePic pic;
- pic.width = w;
- pic.height = h;
- pic.data = data;
+
+ RrImagePicInit(&pic, w, h, data);
return g_hash_table_lookup(self->table, &pic);
}
@@ -139,21 +139,6 @@ guint RrImagePicHash(const RrImagePic *p)
static gboolean RrImagePicEqual(const RrImagePic *p1,
const RrImagePic *p2)
{
- guint s1, s2;
- RrPixel32 *data1, *data2;
- gint i;
-
- if (p1->width != p2->width || p1->height != p2->height) return FALSE;
-
- /* strcmp() would probably suck on 4k of data.. sum all their values and
- see if they get the same thing. they already matched on their hashes
- at this point. */
- s1 = s2 = 0;
- data1 = p1->data;
- data2 = p2->data;
- for (i = 0; i < p1->width * p1->height; ++i, ++data1)
- s1 += *data1;
- for (i = 0; i < p2->width * p2->height; ++i, ++data2)
- s2 += *data2;
- return s1 == s2;
+ return p1->width == p2->width && p1->height == p2->height &&
+ p1->sum == p2->sum;
}