ok
This commit is contained in:
parent
09fe22e984
commit
8c1f4f5ee2
@ -169,7 +169,6 @@ const struct font_glyph * font_get_glyph_texture(struct font_atlas *atlas, unsig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: get the advance
|
|
||||||
struct font_glyph g = {
|
struct font_glyph g = {
|
||||||
.codepoint = code,
|
.codepoint = code,
|
||||||
.u = tx,
|
.u = tx,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef _FONT_H
|
#ifndef _FONT_H
|
||||||
#define _FONT_H
|
#define _FONT_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/* width and height of a glyph contain the kering advance
|
/* width and height of a glyph contain the kering advance
|
||||||
* (u,v)
|
* (u,v)
|
||||||
@ -24,9 +25,9 @@
|
|||||||
*/
|
*/
|
||||||
// TODO: the advance isn't unique for every pair of characters
|
// TODO: the advance isn't unique for every pair of characters
|
||||||
struct font_glyph {
|
struct font_glyph {
|
||||||
unsigned int codepoint;
|
uint32_t codepoint;
|
||||||
unsigned int u, v;
|
uint32_t u, v;
|
||||||
unsigned short int w, h, a, x, y;
|
uint16_t w, h, a, x, y;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct font_atlas {
|
struct font_atlas {
|
||||||
|
@ -14,16 +14,22 @@
|
|||||||
// FIXME: this cache implementation is not really generic since it expects an unsigned
|
// FIXME: this cache implementation is not really generic since it expects an unsigned
|
||||||
// as the code and not a generic type
|
// as the code and not a generic type
|
||||||
|
|
||||||
|
// FIXME: when resetting the bitmap all references to overwritten elements are
|
||||||
|
// invalidated, this really means that
|
||||||
|
// 1) we get data mismatches
|
||||||
|
// 2) this is not a good LRU cache
|
||||||
|
|
||||||
#define CACHE_SET(c, x) \
|
#define CACHE_SET(c, x) \
|
||||||
{ \
|
{ \
|
||||||
c->cycles = (c->cycles+1)%CACHE_NCYCLES; \
|
if (++(c->cycles) > CACHE_NCYCLES) { \
|
||||||
if (!c->cycles) CACHE_BRESET(c->bitmap); \
|
CACHE_BRESET(c->bitmap); \
|
||||||
|
c->cycles=0;} \
|
||||||
CACHE_BSET(c->bitmap, x); \
|
CACHE_BSET(c->bitmap, x); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define CACHE_DECL(name, type, hashfn, cmpfn) \
|
#define CACHE_DECL(name, type, hashfn, cmpfn) \
|
||||||
HASH_DECL(name##table, uint32_t, void *, hashfn, cmpfn) \
|
HASH_DECL(name##table, uint32_t, uint32_t, hashfn, cmpfn) \
|
||||||
struct name { \
|
struct name { \
|
||||||
struct name##table_ref *table; \
|
struct name##table_ref *table; \
|
||||||
type *array; \
|
type *array; \
|
||||||
@ -61,8 +67,8 @@ const type * name##_search(struct name *cache, uint32_t code) \
|
|||||||
if (!r || !cmpfn(code, r->code)) \
|
if (!r || !cmpfn(code, r->code)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
/* HIT, set as recently used */ \
|
/* HIT, set as recently used */ \
|
||||||
CACHE_SET(cache, (type *)(r->data)-(cache->array)); \
|
CACHE_SET(cache, r->data); \
|
||||||
return (const type *)(r->data); \
|
return (&cache->array[r->data]); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
\
|
\
|
||||||
@ -92,7 +98,7 @@ const type * name##_insert(struct name *cache, const type *g, uint32_t code, int
|
|||||||
CACHE_SET(cache, x) \
|
CACHE_SET(cache, x) \
|
||||||
spot = &(cache->array[x]); \
|
spot = &(cache->array[x]); \
|
||||||
*spot = *g; \
|
*spot = *g; \
|
||||||
struct name##table_entry e = { .code = code, .data = spot}; \
|
struct name##table_entry e = { .code = code, .data = x}; \
|
||||||
if (!name##table_insert(cache->table, &e)) \
|
if (!name##table_insert(cache->table, &e)) \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
return spot; \
|
return spot; \
|
||||||
|
Loading…
Reference in New Issue
Block a user