EXA: Fix overlapping glyphs in glyph cache

Allocate each cache at a different vertical position in the
per-format pixmap. Fix width/height confusion when choosing
the cache for a glyph.
This commit is contained in:
Owen Taylor 2008-04-28 21:00:54 +02:00 committed by Michel Dänzer
parent 40eb14c948
commit fcb5949928
2 changed files with 18 additions and 10 deletions

View File

@ -173,12 +173,13 @@ exaRealizeGlyphCaches(ScreenPtr pScreen,
for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) { for (i = 0; i < EXA_NUM_GLYPH_CACHES; i++) {
ExaGlyphCachePtr cache = &pExaScr->glyphCaches[i]; ExaGlyphCachePtr cache = &pExaScr->glyphCaches[i];
int rows; int rows;
if (cache->format != format) if (cache->format != format)
continue; continue;
rows = (cache->size + cache->columns - 1) / cache->columns; cache->yOffset = height;
rows = (cache->size + cache->columns - 1) / cache->columns;
height += rows * cache->glyphHeight; height += rows * cache->glyphHeight;
} }
@ -346,6 +347,9 @@ exaGlyphCacheHashRemove(ExaGlyphCachePtr cache,
} }
} }
#define CACHE_X(pos) (((pos) % cache->columns) * cache->glyphWidth)
#define CACHE_Y(pos) (cache->yOffset + ((pos) / cache->columns) * cache->glyphHeight)
static ExaGlyphCacheResult static ExaGlyphCacheResult
exaGlyphCacheBufferGlyph(ScreenPtr pScreen, exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
ExaGlyphCachePtr cache, ExaGlyphCachePtr cache,
@ -393,8 +397,8 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
int x, y; int x, y;
int i; int i;
x = (pos % cache->columns) * cache->glyphWidth; x = CACHE_X(pos);
y = (pos / cache->columns) * cache->glyphHeight; y = CACHE_Y(pos);
for (i = 0; i < buffer->count; i++) { for (i = 0; i < buffer->count; i++) {
if (buffer->rects[i].xSrc == x && buffer->rects[i].ySrc == y) { if (buffer->rects[i].xSrc == x && buffer->rects[i].ySrc == y) {
@ -420,8 +424,8 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
cache->picture, cache->picture,
0, 0, 0, 0,
0, 0, 0, 0,
(pos % cache->columns) * cache->glyphWidth, CACHE_X(pos),
(pos / cache->columns) * cache->glyphHeight, CACHE_Y(pos),
pGlyph->info.width, pGlyph->info.width,
pGlyph->info.height); pGlyph->info.height);
} }
@ -430,8 +434,8 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
buffer->source = cache->picture; buffer->source = cache->picture;
rect = &buffer->rects[buffer->count]; rect = &buffer->rects[buffer->count];
rect->xSrc = (pos % cache->columns) * cache->glyphWidth; rect->xSrc = CACHE_X(pos);
rect->ySrc = (pos / cache->columns) * cache->glyphHeight; rect->ySrc = CACHE_Y(pos);
rect->xDst = xGlyph - pGlyph->info.x; rect->xDst = xGlyph - pGlyph->info.x;
rect->yDst = yGlyph - pGlyph->info.y; rect->yDst = yGlyph - pGlyph->info.y;
rect->width = pGlyph->info.width; rect->width = pGlyph->info.width;
@ -442,6 +446,9 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
return ExaGlyphSuccess; return ExaGlyphSuccess;
} }
#undef CACHE_X
#undef CACHE_Y
static ExaGlyphCacheResult static ExaGlyphCacheResult
exaBufferGlyph(ScreenPtr pScreen, exaBufferGlyph(ScreenPtr pScreen,
ExaGlyphBufferPtr buffer, ExaGlyphBufferPtr buffer,
@ -452,7 +459,7 @@ exaBufferGlyph(ScreenPtr pScreen,
ExaScreenPriv(pScreen); ExaScreenPriv(pScreen);
unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format; unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format;
int width = pGlyph->info.width; int width = pGlyph->info.width;
int height = pGlyph->info.width; int height = pGlyph->info.height;
ExaCompositeRectPtr rect; ExaCompositeRectPtr rect;
PicturePtr source; PicturePtr source;
int i; int i;

View File

@ -61,7 +61,7 @@
#define DEBUG_MIGRATE 0 #define DEBUG_MIGRATE 0
#define DEBUG_PIXMAP 0 #define DEBUG_PIXMAP 0
#define DEBUG_OFFSCREEN 0 #define DEBUG_OFFSCREEN 0
#define DEBUG_GLYPH_CACHE 0 #define DEBUG_GLYPH_CACHE 1
#if DEBUG_TRACE_FALL #if DEBUG_TRACE_FALL
#define EXA_FALLBACK(x) \ #define EXA_FALLBACK(x) \
@ -121,6 +121,7 @@ typedef struct {
int glyphCount; /* Current number of glyphs */ int glyphCount; /* Current number of glyphs */
PicturePtr picture; /* Where the glyphs of the cache are stored */ PicturePtr picture; /* Where the glyphs of the cache are stored */
int yOffset; /* y location within the picture where the cache starts */
int columns; /* Number of columns the glyphs are layed out in */ int columns; /* Number of columns the glyphs are layed out in */
int evictionPosition; /* Next random position to evict a glyph */ int evictionPosition; /* Next random position to evict a glyph */
} ExaGlyphCacheRec, *ExaGlyphCachePtr; } ExaGlyphCacheRec, *ExaGlyphCachePtr;