diff options
author | Owen Taylor <otaylor@huygens.home.fishsoup.net> | 2008-04-28 21:00:54 +0200 |
---|---|---|
committer | Michel Dänzer <michel@tungstengraphics.com> | 2008-04-28 21:00:54 +0200 |
commit | 40eb14c9482457969e0bde97c49edad536285e02 (patch) | |
tree | 9dd0886b5a138f45e39fc5b777a1b544d6527b45 /exa/exa_glyphs.c | |
parent | 54184110f6f3e5d7276d5431e739a4fcf0c3523e (diff) |
EXA: Add exaCompositeRects()
Add a function to composite multiple independent rectangles
from the same source to the same destination in a single
operation: this is useful for building a glyph mask.
Diffstat (limited to 'exa/exa_glyphs.c')
-rw-r--r-- | exa/exa_glyphs.c | 83 |
1 files changed, 29 insertions, 54 deletions
diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c index 3fe433aa7..55fdb0197 100644 --- a/exa/exa_glyphs.c +++ b/exa/exa_glyphs.c @@ -56,16 +56,6 @@ #define DBG_GLYPH_CACHE(a) #endif -/* Instructions for rendering a single glyph */ -typedef struct { - INT16 xSrc; - INT16 ySrc; - INT16 xDst; - INT16 yDst; - INT16 width; - INT16 height; -} ExaGlyphRenderRec, *ExaGlyphRenderPtr; - /* Width of the pixmaps we use for the caches; this should be less than * max texture size of the driver; this may need to actually come from * the driver. @@ -79,7 +69,7 @@ typedef struct { typedef struct { PicturePtr source; - ExaGlyphRenderRec glyphs[GLYPH_BUFFER_SIZE]; + ExaCompositeRectRec rects[GLYPH_BUFFER_SIZE]; int count; } ExaGlyphBuffer, *ExaGlyphBufferPtr; @@ -364,7 +354,7 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen, int xGlyph, int yGlyph) { - ExaGlyphRenderPtr glyphRec; + ExaCompositeRectPtr rect; int pos; if (buffer->source && buffer->source != cache->picture) @@ -407,7 +397,7 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen, y = (pos / cache->columns) * cache->glyphHeight; for (i = 0; i < buffer->count; i++) { - if (buffer->glyphs[i].xSrc == x && buffer->glyphs[i].ySrc == y) { + if (buffer->rects[i].xSrc == x && buffer->rects[i].ySrc == y) { DBG_GLYPH_CACHE((" must flush buffer\n")); return ExaGlyphNeedFlush; } @@ -439,13 +429,13 @@ exaGlyphCacheBufferGlyph(ScreenPtr pScreen, buffer->source = cache->picture; - glyphRec = &buffer->glyphs[buffer->count]; - glyphRec->xSrc = (pos % cache->columns) * cache->glyphWidth; - glyphRec->ySrc = (pos / cache->columns) * cache->glyphHeight; - glyphRec->xDst = xGlyph - pGlyph->info.x; - glyphRec->yDst = yGlyph - pGlyph->info.y; - glyphRec->width = pGlyph->info.width; - glyphRec->height = pGlyph->info.height; + rect = &buffer->rects[buffer->count]; + rect->xSrc = (pos % cache->columns) * cache->glyphWidth; + rect->ySrc = (pos / cache->columns) * cache->glyphHeight; + rect->xDst = xGlyph - pGlyph->info.x; + rect->yDst = yGlyph - pGlyph->info.y; + rect->width = pGlyph->info.width; + rect->height = pGlyph->info.height; buffer->count++; @@ -463,7 +453,7 @@ exaBufferGlyph(ScreenPtr pScreen, unsigned int format = (GlyphPicture(pGlyph)[pScreen->myNum])->format; int width = pGlyph->info.width; int height = pGlyph->info.width; - ExaGlyphRenderPtr glyphRec; + ExaCompositeRectPtr rect; PicturePtr source; int i; @@ -497,13 +487,13 @@ exaBufferGlyph(ScreenPtr pScreen, buffer->source = source; - glyphRec = &buffer->glyphs[buffer->count]; - glyphRec->xSrc = 0; - glyphRec->ySrc = 0; - glyphRec->xDst = xGlyph - pGlyph->info.x; - glyphRec->yDst = yGlyph - pGlyph->info.y; - glyphRec->width = pGlyph->info.width; - glyphRec->height = pGlyph->info.height; + rect = &buffer->rects[buffer->count]; + rect->xSrc = 0; + rect->ySrc = 0; + rect->xDst = xGlyph - pGlyph->info.x; + rect->yDst = yGlyph - pGlyph->info.y; + rect->width = pGlyph->info.width; + rect->height = pGlyph->info.height; buffer->count++; @@ -514,23 +504,8 @@ static void exaGlyphsToMask(PicturePtr pMask, ExaGlyphBufferPtr buffer) { - int i; - - for (i = 0; i < buffer->count; i++) { - ExaGlyphRenderPtr glyphRec = &buffer->glyphs[i]; - - CompositePicture (PictOpAdd, - buffer->source, - None, - pMask, - glyphRec->xSrc, - glyphRec->ySrc, - 0, 0, - glyphRec->xDst, - glyphRec->yDst, - glyphRec->width, - glyphRec->height); - } + exaCompositeRects(PictOpAdd, buffer->source, pMask, + buffer->count, buffer->rects); buffer->count = 0; buffer->source = NULL; @@ -549,20 +524,20 @@ exaGlyphsToDst(CARD8 op, int i; for (i = 0; i < buffer->count; i++) { - ExaGlyphRenderPtr glyphRec = &buffer->glyphs[i]; + ExaCompositeRectPtr rect = &buffer->rects[i]; CompositePicture (op, pSrc, buffer->source, pDst, - xSrc + glyphRec->xDst - xDst, - ySrc + glyphRec->yDst - yDst, - glyphRec->xSrc, - glyphRec->ySrc, - glyphRec->xDst, - glyphRec->yDst, - glyphRec->width, - glyphRec->height); + xSrc + rect->xDst - xDst, + ySrc + rect->yDst - yDst, + rect->xSrc, + rect->ySrc, + rect->xDst, + rect->yDst, + rect->width, + rect->height); } buffer->count = 0; |