]> Dogcows Code - chaz/openbox/commitdiff
don't alloc/free colors every time splitvertical is drawn
authorDana Jansens <danakj@orodu.net>
Wed, 13 Jun 2007 13:48:00 +0000 (13:48 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 13 Jun 2007 13:48:00 +0000 (13:48 +0000)
render/gradient.c
render/render.c
render/render.h
render/theme.c

index ccfd6071d5c3f5c2e08887331ce939013e99c993..41514ac43296bac8ce059e1034cadf0aa35e4fb5 100644 (file)
@@ -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)
index 63c1e7245c53b9ef0591122d30dd1fdd3f7ed781..97ec7b520e149a784caceacdeaff4e585239723c 100644 (file)
@@ -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);
index cf0f7eddbf45eaba28c56063bf3dd919bc92bbb0..33c9c0e9a8fc0b88fdefd6049858fd5e938747c4 100644 (file)
@@ -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 {
index 709449443697aa5052652d42a52592ee70ed47d7..0edc81d7e675e17620a998f3fef03876e40af0a2 100644 (file)
@@ -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;
     }
 
This page took 0.030674 seconds and 4 git commands to generate.