diff options
| author | Dana Jansens <danakj@orodu.net> | 2008-02-14 10:47:49 +0100 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2008-02-14 15:09:24 -0500 |
| commit | 4c7cc1cfa64bf5722f059eae0528d510c2ae636f (patch) | |
| tree | bf9657e364a76cdcd11ae86c81335b74d4d56fa0 /render/render.c | |
| parent | 512d93afcc3e7dd5caa42cdb69508964c6338f3d (diff) | |
Introducing the icon cache.
If an icon is the same as one in the cache, then it uses that one.
icons of different sizes (from the same client) are linked together into
one, and resizes of icons are cached and linked to all the various sizes.
so you only need one icon in memory for all your terminals now. ya!
Diffstat (limited to 'render/render.c')
| -rw-r--r-- | render/render.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/render/render.c b/render/render.c index b81e80a6..fd442d26 100644 --- a/render/render.c +++ b/render/render.c @@ -130,6 +130,24 @@ Pixmap RrPaintPixmap(RrAppearance *a, gint w, gint h) } RrPixmapMaskDraw(a->pixmap, &a->texture[i].data.mask, &tarea); break; + case RR_TEXTURE_IMAGE: + g_assert(!transferred); + { + RrRect narea = tarea; + RrTextureImage *img = &a->texture[i].data.image; + if (img->twidth) + narea.width = MIN(tarea.width, img->twidth); + if (img->theight) + narea.height = MIN(tarea.height, img->theight); + narea.x += img->tx; + narea.y += img->ty; + RrImageDrawImage(a->surface.pixel_data, + &a->texture[i].data.image, + a->w, a->h, + &narea); + } + force_transfer = 1; + break; case RR_TEXTURE_RGBA: g_assert(!transferred); { @@ -141,10 +159,10 @@ Pixmap RrPaintPixmap(RrAppearance *a, gint w, gint h) narea.height = MIN(tarea.height, rgb->theight); narea.x += rgb->tx; narea.y += rgb->ty; - RrImageDraw(a->surface.pixel_data, - &a->texture[i].data.rgba, - a->w, a->h, - &narea); + RrImageDrawRGBA(a->surface.pixel_data, + &a->texture[i].data.rgba, + a->w, a->h, + &narea); } force_transfer = 1; break; @@ -202,11 +220,15 @@ void RrAppearanceAddTextures(RrAppearance *a, gint numtex) if (numtex) a->texture = g_new0(RrTexture, numtex); } +void RrAppearanceClearTextures(RrAppearance *a) +{ + memset(a->texture, 0, a->textures * sizeof(RrTexture)); +} + RrAppearance *RrAppearanceCopy(RrAppearance *orig) { RrSurface *spo, *spc; RrAppearance *copy = g_new(RrAppearance, 1); - gint i; copy->inst = orig->inst; @@ -282,10 +304,6 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) copy->textures = orig->textures; copy->texture = g_memdup(orig->texture, orig->textures * sizeof(RrTexture)); - for (i = 0; i < copy->textures; ++i) - if (copy->texture[i].type == RR_TEXTURE_RGBA) { - copy->texture[i].data.rgba.cache = NULL; - } copy->pixmap = None; copy->xftdraw = NULL; copy->w = copy->h = 0; @@ -294,17 +312,10 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) void RrAppearanceFree(RrAppearance *a) { - gint i; - if (a) { RrSurface *p; if (a->pixmap != None) XFreePixmap(RrDisplay(a->inst), a->pixmap); if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw); - for (i = 0; i < a->textures; ++i) - if (a->texture[i].type == RR_TEXTURE_RGBA) { - g_free(a->texture[i].data.rgba.cache); - a->texture[i].data.rgba.cache = NULL; - } if (a->textures) g_free(a->texture); p = &a->surface; @@ -405,6 +416,9 @@ gint RrMinWidth(RrAppearance *a) case RR_TEXTURE_RGBA: w += MAX(w, a->texture[i].data.rgba.width); break; + case RR_TEXTURE_IMAGE: + /* images resize so they don't contribute anything to the min */ + break; case RR_TEXTURE_LINE_ART: w = MAX(w, MAX(a->texture[i].data.lineart.x1 - l - r, a->texture[i].data.lineart.x2 - l - r)); @@ -457,6 +471,9 @@ gint RrMinHeight(RrAppearance *a) case RR_TEXTURE_RGBA: h += MAX(h, a->texture[i].data.rgba.height); break; + case RR_TEXTURE_IMAGE: + /* images resize so they don't contribute anything to the min */ + break; case RR_TEXTURE_LINE_ART: h = MAX(h, MAX(a->texture[i].data.lineart.y1 - t - b, a->texture[i].data.lineart.y2 - t - b)); |
