From: Dana Jansens Date: Wed, 13 Jun 2007 13:48:00 +0000 (+0000) Subject: don't alloc/free colors every time splitvertical is drawn X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=89ade7a8c1a5f825f61657cb185246cefbd4e96e;p=chaz%2Fopenbox don't alloc/free colors every time splitvertical is drawn --- diff --git a/render/gradient.c b/render/gradient.c index ccfd6071..41514ac4 100644 --- a/render/gradient.c +++ b/render/gradient.c @@ -421,50 +421,28 @@ static void gradient_solid(RrAppearance *l, gint w, gint h) static void gradient_splitvertical(RrAppearance *a, gint w, gint h) { - gint x, y1, y2, y3, r, g, b; + gint x, y1, y2, y3; RrSurface *sf = &a->surface; RrPixel32 *data = sf->pixel_data; RrPixel32 current; - RrColor *primary_light, *secondary_light; gint y1sz, y2sz, y3sz; VARS(y1); VARS(y2); VARS(y3); - r = sf->primary->r; - r += r >> 2; - g = sf->primary->g; - g += g >> 2; - b = sf->primary->b; - b += b >> 2; - if (r > 0xFF) r = 0xFF; - if (g > 0xFF) g = 0xFF; - if (b > 0xFF) b = 0xFF; - primary_light = RrColorNew(a->inst, r, g, b); - - r = sf->secondary->r; - r += r >> 4; - g = sf->secondary->g; - g += g >> 4; - b = sf->secondary->b; - b += b >> 4; - if (r > 0xFF) r = 0xFF; - if (g > 0xFF) g = 0xFF; - if (b > 0xFF) b = 0xFF; - secondary_light = RrColorNew(a->inst, r, g, b); y1sz = MAX(h/2 - 1, 1); /* setup to get the colors _in between_ these other 2 */ y2sz = (h < 3 ? 0 : (h % 2 ? 3 : 2)); y3sz = MAX(h/2 - 1, 0); - SETUP(y1, primary_light, sf->primary, y1sz); + SETUP(y1, sf->split_primary, sf->primary, y1sz); if (y2sz) { SETUP(y2, sf->primary, sf->secondary, y2sz); NEXT(y2); /* skip the first one, its the same as the last of y1 */ } - SETUP(y3, sf->secondary, secondary_light, y3sz); + SETUP(y3, sf->secondary, sf->split_secondary, y3sz); for (y1 = y1sz; y1 > 0; --y1) { current = COLOR(y1); @@ -489,9 +467,6 @@ static void gradient_splitvertical(RrAppearance *a, gint w, gint h) NEXT(y3); } - - RrColorFree(primary_light); - RrColorFree(secondary_light); } static void gradient_horizontal(RrSurface *sf, gint w, gint h) diff --git a/render/render.c b/render/render.c index 63c1e724..97ec7b52 100644 --- a/render/render.c +++ b/render/render.c @@ -241,6 +241,20 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) spo->bevel_light->b); else spc->bevel_light = NULL; + if (spo->split_primary != NULL) + spc->split_primary = RrColorNew(copy->inst, + spo->split_primary->r, + spo->split_primary->g, + spo->split_primary->b); + else spc->split_primary = NULL; + + if (spo->split_secondary != NULL) + spc->split_secondary = RrColorNew(copy->inst, + spo->split_secondary->r, + spo->split_secondary->g, + spo->split_secondary->b); + else spc->split_secondary = NULL; + spc->interlaced = spo->interlaced; spc->bevel_light_adjust = spo->bevel_light_adjust; spc->bevel_dark_adjust = spo->bevel_dark_adjust; @@ -284,6 +298,8 @@ void RrAppearanceFree(RrAppearance *a) RrColorFree(p->interlace_color); RrColorFree(p->bevel_dark); RrColorFree(p->bevel_light); + RrColorFree(p->split_primary); + RrColorFree(p->split_secondary); g_free(p->pixel_data); p->pixel_data = NULL; g_free(a); diff --git a/render/render.h b/render/render.h index cf0f7edd..33c9c0e9 100644 --- a/render/render.h +++ b/render/render.h @@ -125,6 +125,8 @@ struct _RrSurface { RrPixel32 *pixel_data; gint bevel_dark_adjust; /* 0-255, default is 64 */ gint bevel_light_adjust; /* 0-255, default is 128 */ + RrColor *split_primary; + RrColor *split_secondary; }; struct _RrTextureText { diff --git a/render/theme.c b/render/theme.c index 70944944..0edc81d7 100644 --- a/render/theme.c +++ b/render/theme.c @@ -1797,6 +1797,33 @@ static gboolean read_appearance(XrmDatabase db, const RrInstance *inst, value->surface.bevel_light_adjust = i; if (read_int(db, sname, &i) && i >= 0 && i <= 256) value->surface.bevel_dark_adjust = i; + + if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) { + gint r, g, b; + + r = value->surface.primary->r; + r += r >> 2; + g = value->surface.primary->g; + g += g >> 2; + b = value->surface.primary->b; + b += b >> 2; + if (r > 0xFF) r = 0xFF; + if (g > 0xFF) g = 0xFF; + if (b > 0xFF) b = 0xFF; + value->surface.split_primary = RrColorNew(inst, r, g, b); + + r = value->surface.secondary->r; + r += r >> 4; + g = value->surface.secondary->g; + g += g >> 4; + b = value->surface.secondary->b; + b += b >> 4; + if (r > 0xFF) r = 0xFF; + if (g > 0xFF) g = 0xFF; + if (b > 0xFF) b = 0xFF; + value->surface.split_secondary = RrColorNew(inst, r, g, b); + } + ret = TRUE; }