composite_cache = hashmap_init(sizeof(composite_hash_key_t),
sizeof(composite_hash_val_t),
0xFFFF + 13,
- composite_hash_dtor, NULL, NULL);
+ composite_hash_dtor, composite_compare,
+ composite_hash);
return composite_cache;
}
void ass_bitmap_cache_done(hashmap_t *bitmap_cache);
-// Cache for composited bitmaps
-typedef struct composite_hash_key_s {
- int aw, ah, bw, bh;
- int ax, ay, bx, by;
- bitmap_hash_key_t a;
- bitmap_hash_key_t b;
-} composite_hash_key_t;
-
typedef struct composite_hash_val_s {
unsigned char *a;
unsigned char *b;
type member;
#define FTVECTOR(member) \
FT_Vector member;
+#define BITMAPHASHKEY(member) \
+ bitmap_hash_key_t member;
#define END(typedefnamename) \
} typedefnamename;
a->member == b->member &&
#define FTVECTOR(member) \
a->member.x == b->member.x && a->member.y == b->member.y &&
+#define BITMAPHASHKEY(member) \
+ bitmap_compare(&a->member, &b->member, sizeof(a->member)) &&
#define END(typedefname) \
1; \
}
#define GENERIC(type, member) \
hval = fnv_32a_buf(&p->member, sizeof(p->member), hval);
#define FTVECTOR(member) GENERIC(, member.x); GENERIC(, member.y);
+#define BITMAPHASHKEY(member) { \
+ unsigned temp = bitmap_hash(&p->member, sizeof(p->member)); \
+ hval = fnv_32a_buf(&temp, sizeof(temp), hval); \
+ }
#define END(typedefname) \
return hval; \
}
GENERIC(unsigned, outline) // border width, 16.16
END(glyph_hash_key_t)
+// Cache for composited bitmaps
+START(composite, composite_hash_key_s)
+ GENERIC(int, aw)
+ GENERIC(int, ah)
+ GENERIC(int, bw)
+ GENERIC(int, bh)
+ GENERIC(int, ax)
+ GENERIC(int, ay)
+ GENERIC(int, bx)
+ GENERIC(int, by)
+ BITMAPHASHKEY(a)
+ BITMAPHASHKEY(b)
+END(composite_hash_key_t)
+
+
#undef START
#undef GENERIC
#undef FTVECTOR
+#undef BITMAPHASHKEY
#undef END