Allow storing more flags in the special glyph cache
This commit is contained in:
@@ -37,11 +37,13 @@ struct SpritePosition {
|
|||||||
ExtraGlyphs extra_glyphs;
|
ExtraGlyphs extra_glyphs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SPECIAL_FILLED_MASK 1
|
||||||
|
#define SPECIAL_VALUE_MASK 2
|
||||||
|
|
||||||
struct SpecialGlyphCache {
|
struct SpecialGlyphCache {
|
||||||
SpecialGlyphCache *next;
|
SpecialGlyphCache *next;
|
||||||
glyph_index glyph;
|
glyph_index glyph;
|
||||||
bool is_special, filled;
|
uint8_t data;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -155,9 +157,9 @@ static SpecialGlyphCache*
|
|||||||
special_glyph_cache_for(Font *font, glyph_index glyph) {
|
special_glyph_cache_for(Font *font, glyph_index glyph) {
|
||||||
SpecialGlyphCache *s = font->special_glyph_cache + (glyph & 0x3ff);
|
SpecialGlyphCache *s = font->special_glyph_cache + (glyph & 0x3ff);
|
||||||
// Optimize for the common case of glyph under 1024 already in the cache
|
// Optimize for the common case of glyph under 1024 already in the cache
|
||||||
if (LIKELY(s->glyph == glyph && s->filled)) return s; // Cache hit
|
if (LIKELY(s->glyph == glyph && s->data & SPECIAL_FILLED_MASK)) return s; // Cache hit
|
||||||
while(true) {
|
while(true) {
|
||||||
if (s->filled) {
|
if (s->data & SPECIAL_FILLED_MASK) {
|
||||||
if (s->glyph == glyph) return s; // Cache hit
|
if (s->glyph == glyph) return s; // Cache hit
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@@ -212,7 +214,7 @@ clear_sprite_map(Font *font) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
clear_special_glyph_cache(Font *font) {
|
clear_special_glyph_cache(Font *font) {
|
||||||
#define CLEAR(s) s->filled = false; s->glyph = 0;
|
#define CLEAR(s) s->data = 0; s->glyph = 0;
|
||||||
SpecialGlyphCache *s;
|
SpecialGlyphCache *s;
|
||||||
for (size_t i = 0; i < sizeof(font->special_glyph_cache)/sizeof(font->special_glyph_cache[0]); i++) {
|
for (size_t i = 0; i < sizeof(font->special_glyph_cache)/sizeof(font->special_glyph_cache[0]); i++) {
|
||||||
s = font->special_glyph_cache + i;
|
s = font->special_glyph_cache + i;
|
||||||
@@ -613,14 +615,15 @@ is_special_glyph(glyph_index glyph_id, Font *font, CellData* cell_data) {
|
|||||||
// different glyph in the font
|
// different glyph in the font
|
||||||
SpecialGlyphCache *s = special_glyph_cache_for(font, glyph_id);
|
SpecialGlyphCache *s = special_glyph_cache_for(font, glyph_id);
|
||||||
if (s == NULL) return false;
|
if (s == NULL) return false;
|
||||||
if (!s->filled) {
|
if (!(s->data & SPECIAL_FILLED_MASK)) {
|
||||||
s->is_special = cell_data->current_codepoint ? (
|
bool is_special = cell_data->current_codepoint ? (
|
||||||
glyph_id != glyph_id_for_codepoint(font->face, cell_data->current_codepoint) ? true : false)
|
glyph_id != glyph_id_for_codepoint(font->face, cell_data->current_codepoint) ? true : false)
|
||||||
:
|
:
|
||||||
false;
|
false;
|
||||||
s->filled = true;
|
uint8_t val = is_special ? SPECIAL_VALUE_MASK : 0;
|
||||||
|
s->data |= val | SPECIAL_FILLED_MASK;
|
||||||
}
|
}
|
||||||
return s->is_special;
|
return s->data & SPECIAL_VALUE_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int
|
static inline unsigned int
|
||||||
|
|||||||
Reference in New Issue
Block a user