EXA: Only calculate cache position once for each glyph.
This commit is contained in:
parent
c11678cc18
commit
abb8108fb4
|
@ -359,7 +359,8 @@ exaGlyphCacheHashRemove(ExaGlyphCachePtr cache,
|
||||||
static void
|
static void
|
||||||
exaGlyphCacheUploadGlyph(ScreenPtr pScreen,
|
exaGlyphCacheUploadGlyph(ScreenPtr pScreen,
|
||||||
ExaGlyphCachePtr cache,
|
ExaGlyphCachePtr cache,
|
||||||
int pos,
|
int x,
|
||||||
|
int y,
|
||||||
GlyphPtr pGlyph)
|
GlyphPtr pGlyph)
|
||||||
{
|
{
|
||||||
ExaScreenPriv(pScreen);
|
ExaScreenPriv(pScreen);
|
||||||
|
@ -394,10 +395,10 @@ exaGlyphCacheUploadGlyph(ScreenPtr pScreen,
|
||||||
if (!exaPixmapIsOffscreen(pCachePixmap))
|
if (!exaPixmapIsOffscreen(pCachePixmap))
|
||||||
goto composite;
|
goto composite;
|
||||||
|
|
||||||
/* CACHE_{X,Y} are in pixmap coordinates, no need for cache{X,Y}off */
|
/* x,y are in pixmap coordinates, no need for cache{X,Y}off */
|
||||||
if (pExaScr->info->UploadToScreen(pCachePixmap,
|
if (pExaScr->info->UploadToScreen(pCachePixmap,
|
||||||
CACHE_X(pos),
|
x,
|
||||||
CACHE_Y(pos),
|
y,
|
||||||
pGlyph->info.width,
|
pGlyph->info.width,
|
||||||
pGlyph->info.height,
|
pGlyph->info.height,
|
||||||
(char *)pExaPixmap->sys_ptr,
|
(char *)pExaPixmap->sys_ptr,
|
||||||
|
@ -411,18 +412,18 @@ composite:
|
||||||
cache->picture,
|
cache->picture,
|
||||||
0, 0,
|
0, 0,
|
||||||
0, 0,
|
0, 0,
|
||||||
CACHE_X(pos),
|
x,
|
||||||
CACHE_Y(pos),
|
y,
|
||||||
pGlyph->info.width,
|
pGlyph->info.width,
|
||||||
pGlyph->info.height);
|
pGlyph->info.height);
|
||||||
|
|
||||||
damage:
|
damage:
|
||||||
/* The cache pixmap isn't a window, so no need to offset coordinates. */
|
/* The cache pixmap isn't a window, so no need to offset coordinates. */
|
||||||
exaPixmapDirty (pCachePixmap,
|
exaPixmapDirty (pCachePixmap,
|
||||||
CACHE_X(pos),
|
x,
|
||||||
CACHE_Y(pos),
|
y,
|
||||||
CACHE_X(pos) + cache->glyphWidth,
|
x + cache->glyphWidth,
|
||||||
CACHE_Y(pos) + cache->glyphHeight);
|
y + cache->glyphHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ExaGlyphCacheResult
|
static ExaGlyphCacheResult
|
||||||
|
@ -441,6 +442,7 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
|
||||||
{
|
{
|
||||||
ExaCompositeRectPtr rect;
|
ExaCompositeRectPtr rect;
|
||||||
int pos;
|
int pos;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
if (buffer->mask && buffer->mask != cache->picture)
|
if (buffer->mask && buffer->mask != cache->picture)
|
||||||
return ExaGlyphNeedFlush;
|
return ExaGlyphNeedFlush;
|
||||||
|
@ -457,10 +459,14 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
|
||||||
pos = exaGlyphCacheHashLookup(cache, pGlyph);
|
pos = exaGlyphCacheHashLookup(cache, pGlyph);
|
||||||
if (pos != -1) {
|
if (pos != -1) {
|
||||||
DBG_GLYPH_CACHE((" found existing glyph at %d\n", pos));
|
DBG_GLYPH_CACHE((" found existing glyph at %d\n", pos));
|
||||||
|
x = CACHE_X(pos);
|
||||||
|
y = CACHE_Y(pos);
|
||||||
} else {
|
} else {
|
||||||
if (cache->glyphCount < cache->size) {
|
if (cache->glyphCount < cache->size) {
|
||||||
/* Space remaining; we fill from the start */
|
/* Space remaining; we fill from the start */
|
||||||
pos = cache->glyphCount;
|
pos = cache->glyphCount;
|
||||||
|
x = CACHE_X(pos);
|
||||||
|
y = CACHE_Y(pos);
|
||||||
cache->glyphCount++;
|
cache->glyphCount++;
|
||||||
DBG_GLYPH_CACHE((" storing glyph in free space at %d\n", pos));
|
DBG_GLYPH_CACHE((" storing glyph in free space at %d\n", pos));
|
||||||
|
|
||||||
|
@ -472,14 +478,12 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
|
||||||
* the cache
|
* the cache
|
||||||
*/
|
*/
|
||||||
pos = cache->evictionPosition;
|
pos = cache->evictionPosition;
|
||||||
|
x = CACHE_X(pos);
|
||||||
|
y = CACHE_Y(pos);
|
||||||
DBG_GLYPH_CACHE((" evicting glyph at %d\n", pos));
|
DBG_GLYPH_CACHE((" evicting glyph at %d\n", pos));
|
||||||
if (buffer->count) {
|
if (buffer->count) {
|
||||||
int x, y;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
x = CACHE_X(pos);
|
|
||||||
y = CACHE_Y(pos);
|
|
||||||
|
|
||||||
for (i = 0; i < buffer->count; i++) {
|
for (i = 0; i < buffer->count; i++) {
|
||||||
if (pSrc ?
|
if (pSrc ?
|
||||||
(buffer->rects[i].xMask == x && buffer->rects[i].yMask == y) :
|
(buffer->rects[i].xMask == x && buffer->rects[i].yMask == y) :
|
||||||
|
@ -498,7 +502,7 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
|
||||||
cache->evictionPosition = rand() % cache->size;
|
cache->evictionPosition = rand() % cache->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
exaGlyphCacheUploadGlyph(pScreen, cache, pos, pGlyph);
|
exaGlyphCacheUploadGlyph(pScreen, cache, x, y, pGlyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->mask = cache->picture;
|
buffer->mask = cache->picture;
|
||||||
|
@ -509,13 +513,13 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen,
|
||||||
{
|
{
|
||||||
rect->xSrc = xSrc;
|
rect->xSrc = xSrc;
|
||||||
rect->ySrc = ySrc;
|
rect->ySrc = ySrc;
|
||||||
rect->xMask = CACHE_X(pos);
|
rect->xMask = x;
|
||||||
rect->yMask = CACHE_Y(pos);
|
rect->yMask = y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rect->xSrc = CACHE_X(pos);
|
rect->xSrc = x;
|
||||||
rect->ySrc = CACHE_Y(pos);
|
rect->ySrc = y;
|
||||||
rect->xMask = 0;
|
rect->xMask = 0;
|
||||||
rect->yMask = 0;
|
rect->yMask = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue