xcompmgr.c optimization
Michael Knorr <[email protected]>
| Newsgroups | gmane.comp.freedesktop.xserver |
|---|---|
| Message-ID | <[email protected]> |
I toyed around with the composite manager and made a little
patch that speeds make_shadow up.
gprof results for make_shadow:
before: self ms/call 146.00
after: self ms/call 28.00
BTW: Is there a way to get a higher refresh rate with the Xvesa server?
-screen 1024x768x32x85 doesn't set the refresh rate to 85hz.
Greetings
Michael Knorr
--- ../freedesktop/xapps/xcompmgr/xcompmgr.c 2003-11-24 20:41:39.000000000 +0100
+++ xcompmgr_changed/xcompmgr.c 2003-11-30 15:32:52.000000000 +0100
@@ -159,17 +159,17 @@
*/
static unsigned char
-sum_gaussian (conv *map, double opacity, int x, int y, int width, int height)
+sum_gaussian (double opacity, int x, int y, int width, int height)
{
int fx, fy;
double *g_data;
- double *g_line = map->data;
- int g_size = map->size;
+ double *g_line = gaussianMap->data;
+ int g_size = gaussianMap->size;
int center = g_size / 2;
int fx_start, fx_end;
int fy_start, fy_end;
double v;
-
+
/*
* Compute set of filter values which are "in range",
* that's the set with:
@@ -195,8 +195,8 @@
fy_end = g_size;
g_line = g_line + fy_start * g_size + fx_start;
-
- v = 0;
+
+ v = 0.0;
for (fy = fy_start; fy < fy_end; fy++)
{
g_data = g_line;
@@ -205,10 +205,10 @@
for (fx = fx_start; fx < fx_end; fx++)
v += *g_data++;
}
- if (v > 1)
- v = 1;
-
- return ((unsigned int) (v * opacity * 255.0));
+ if (v > 1.0)
+ v = 1.0;
+
+ return ((unsigned char) (v * opacity * 255.0));
}
static XImage *
@@ -223,7 +223,8 @@
int center = gsize / 2;
int x, y;
unsigned char d;
-
+ int x_diff;
+
data = malloc (swidth * sheight * sizeof (unsigned char));
ximage = XCreateImage (dpy,
DefaultVisual(dpy, DefaultScreen(dpy)),
@@ -236,6 +237,14 @@
* Build the gaussian in sections
*/
+
+ /*
+ * center (fill the complete data array)
+ */
+
+ d = sum_gaussian (opacity, center, center, width, height);
+ memset(data, d, sheight * swidth);
+
/*
* corners
*/
@@ -249,49 +258,41 @@
for (y = 0; y < ylimit; y++)
for (x = 0; x < xlimit; x++)
{
- d = sum_gaussian (gaussianMap, opacity, x - center, y - center, width, height);
+ d = sum_gaussian (opacity, x - center, y - center, width, height);
data[y * swidth + x] = d;
data[(sheight - y - 1) * swidth + x] = d;
data[(sheight - y - 1) * swidth + (swidth - x - 1)] = d;
data[y * swidth + (swidth - x - 1)] = d;
}
+
+ x_diff = swidth - xlimit - xlimit;
+ if(x_diff < 0) x_diff = 0;
+
/*
* top/bottom
*/
for (y = 0; y < ylimit; y++)
{
- d = sum_gaussian (gaussianMap, opacity, center, y - center, width, height);
- for (x = gsize; x < swidth - gsize; x++)
- {
- data[y * swidth + x] = d;
- data[(sheight - y - 1) * swidth + x] = d;
- }
+ d = sum_gaussian (opacity, center, y - center, width, height);
+ memset(data + y * swidth + xlimit, d, x_diff);
+ memset(data + (sheight - y - 1) * swidth + xlimit, d, x_diff);
}
/*
* sides
*/
-
+
for (x = 0; x < xlimit; x++)
{
- d = sum_gaussian (gaussianMap, opacity, x - center, center, width, height);
- for (y = gsize; y < sheight - gsize; y++)
+ d = sum_gaussian (opacity, x - center, center, width, height);
+ for (y = ylimit; y < sheight - ylimit; y++)
{
data[y * swidth + x] = d;
data[y * swidth + (swidth - x - 1)] = d;
}
}
- /*
- * center
- */
-
- d = sum_gaussian (gaussianMap, opacity, center, center, width, height);
- for (y = ylimit; y < sheight - ylimit; y++)
- for (x = xlimit; x < swidth - xlimit; x++)
- data[y * swidth + x] = d;
-
return ximage;
}
@@ -299,7 +300,7 @@
shadow_picture (Display *dpy, double opacity, int width, int height, int *wp, int *hp)
{
XImage *shadowImage = make_shadow (dpy, opacity, width, height);
- Pixmap shadowPixmap = XCreatePixmap (dpy, root,
+ Pixmap shadowPixmap = XCreatePixmap (dpy, root,
shadowImage->width,
shadowImage->height,
8);
@@ -400,7 +401,7 @@
win_extents (Display *dpy, win *w)
{
XRectangle r;
-
+
r.x = w->a.x;
r.y = w->a.y;
r.width = w->a.width + w->a.border_width * 2;
@@ -408,7 +409,7 @@
if (w->mode != WINDOW_ARGB)
{
XRectangle sr;
-
+
if (!w->shadow)
{
double opacity = SHADOW_OPACITY;