Use an alpha map instead of an ARGB picture for shadows. Update last_update
only when actually updating windows.
This commit is contained in:
parent
54fb13fa32
commit
91c293c7e9
|
@ -1,3 +1,10 @@
|
||||||
|
2003-11-13 Keith Packard <keithp@keithp.com>
|
||||||
|
|
||||||
|
* xcompmgr.c: (make_gaussian_map), (sum_gaussian), (make_shadow),
|
||||||
|
(shadow_picture), (paint_all), (main):
|
||||||
|
Use an alpha map instead of an ARGB picture for shadows.
|
||||||
|
Update last_update only when actually updating windows.
|
||||||
|
|
||||||
2003-11-11 Keith Packard <keithp@keithp.com>
|
2003-11-11 Keith Packard <keithp@keithp.com>
|
||||||
|
|
||||||
* xcompmgr.c: (win_extents), (paint_all), (add_win), (main):
|
* xcompmgr.c: (win_extents), (paint_all), (add_win), (main):
|
||||||
|
|
41
xcompmgr.c
41
xcompmgr.c
|
@ -61,6 +61,7 @@ Window root;
|
||||||
Picture rootPicture;
|
Picture rootPicture;
|
||||||
Picture rootBuffer;
|
Picture rootBuffer;
|
||||||
Picture transPicture;
|
Picture transPicture;
|
||||||
|
Picture blackPicture;
|
||||||
Picture rootTile;
|
Picture rootTile;
|
||||||
XserverRegion allDamage;
|
XserverRegion allDamage;
|
||||||
int root_height, root_width;
|
int root_height, root_width;
|
||||||
|
@ -110,7 +111,7 @@ make_gaussian_map (Display *dpy, double r)
|
||||||
t += g;
|
t += g;
|
||||||
c->data[y * size + x] = g;
|
c->data[y * size + x] = g;
|
||||||
}
|
}
|
||||||
printf ("gaussian total %f\n", t);
|
/* printf ("gaussian total %f\n", t); */
|
||||||
for (y = 0; y < size; y++)
|
for (y = 0; y < size; y++)
|
||||||
for (x = 0; x < size; x++)
|
for (x = 0; x < size; x++)
|
||||||
{
|
{
|
||||||
|
@ -136,7 +137,7 @@ make_gaussian_map (Display *dpy, double r)
|
||||||
* center +-----+-------------------+-----+
|
* center +-----+-------------------+-----+
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned int
|
unsigned char
|
||||||
sum_gaussian (conv *map, double opacity, int x, int y, int width, int height)
|
sum_gaussian (conv *map, double opacity, int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
int fx, fy;
|
int fx, fy;
|
||||||
|
@ -187,7 +188,7 @@ sum_gaussian (conv *map, double opacity, int x, int y, int width, int height)
|
||||||
if (v > 1)
|
if (v > 1)
|
||||||
v = 1;
|
v = 1;
|
||||||
|
|
||||||
return ((unsigned int) (v * opacity * 255.0)) << 24;
|
return ((unsigned int) (v * opacity * 255.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
XImage *
|
XImage *
|
||||||
|
@ -196,7 +197,7 @@ make_shadow (Display *dpy, double opacity, double r, int width, int height)
|
||||||
conv *map = make_gaussian_map (dpy, r);
|
conv *map = make_gaussian_map (dpy, r);
|
||||||
XImage *ximage;
|
XImage *ximage;
|
||||||
double *gdata = map->data;
|
double *gdata = map->data;
|
||||||
unsigned int *data;
|
unsigned char *data;
|
||||||
int gsize = map->size;
|
int gsize = map->size;
|
||||||
int ylimit, xlimit;
|
int ylimit, xlimit;
|
||||||
int swidth = width + gsize;
|
int swidth = width + gsize;
|
||||||
|
@ -205,18 +206,18 @@ make_shadow (Display *dpy, double opacity, double r, int width, int height)
|
||||||
int x, y;
|
int x, y;
|
||||||
int fx, fy;
|
int fx, fy;
|
||||||
int sx, sy;
|
int sx, sy;
|
||||||
unsigned int d;
|
unsigned char d;
|
||||||
double v;
|
double v;
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
|
|
||||||
data = malloc (swidth * sheight * sizeof (int));
|
data = malloc (swidth * sheight * sizeof (unsigned char));
|
||||||
ximage = XCreateImage (dpy,
|
ximage = XCreateImage (dpy,
|
||||||
DefaultVisual(dpy, DefaultScreen(dpy)),
|
DefaultVisual(dpy, DefaultScreen(dpy)),
|
||||||
32,
|
8,
|
||||||
ZPixmap,
|
ZPixmap,
|
||||||
0,
|
0,
|
||||||
(char *) data,
|
(char *) data,
|
||||||
swidth, sheight, 32, swidth * sizeof (int));
|
swidth, sheight, 8, swidth * sizeof (unsigned char));
|
||||||
/*
|
/*
|
||||||
* Build the gaussian in sections
|
* Build the gaussian in sections
|
||||||
*/
|
*/
|
||||||
|
@ -288,9 +289,9 @@ shadow_picture (Display *dpy, double opacity, double r, int width, int height, i
|
||||||
Pixmap shadowPixmap = XCreatePixmap (dpy, root,
|
Pixmap shadowPixmap = XCreatePixmap (dpy, root,
|
||||||
shadowImage->width,
|
shadowImage->width,
|
||||||
shadowImage->height,
|
shadowImage->height,
|
||||||
32);
|
8);
|
||||||
Picture shadowPicture = XRenderCreatePicture (dpy, shadowPixmap,
|
Picture shadowPicture = XRenderCreatePicture (dpy, shadowPixmap,
|
||||||
XRenderFindStandardFormat (dpy, PictStandardARGB32),
|
XRenderFindStandardFormat (dpy, PictStandardA8),
|
||||||
0, 0);
|
0, 0);
|
||||||
GC gc = XCreateGC (dpy, shadowPixmap, 0, 0);
|
GC gc = XCreateGC (dpy, shadowPixmap, 0, 0);
|
||||||
|
|
||||||
|
@ -478,7 +479,7 @@ paint_all (Display *dpy, XserverRegion region)
|
||||||
XFixesSetPictureClipRegion (dpy, rootBuffer, 0, 0, w->borderClip);
|
XFixesSetPictureClipRegion (dpy, rootBuffer, 0, 0, w->borderClip);
|
||||||
if (w->shadow)
|
if (w->shadow)
|
||||||
{
|
{
|
||||||
XRenderComposite (dpy, PictOpOver, w->shadow, None, rootBuffer,
|
XRenderComposite (dpy, PictOpOver, blackPicture, w->shadow, rootBuffer,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
w->a.x + w->a.border_width + w->shadow_dx,
|
w->a.x + w->a.border_width + w->shadow_dx,
|
||||||
w->a.y + w->a.border_width + w->shadow_dy,
|
w->a.y + w->a.border_width + w->shadow_dy,
|
||||||
|
@ -776,6 +777,7 @@ main ()
|
||||||
Window root_return, parent_return;
|
Window root_return, parent_return;
|
||||||
Window *children;
|
Window *children;
|
||||||
Pixmap transPixmap;
|
Pixmap transPixmap;
|
||||||
|
Pixmap blackPixmap;
|
||||||
unsigned int nchildren;
|
unsigned int nchildren;
|
||||||
int i;
|
int i;
|
||||||
int damage_event, damage_error;
|
int damage_event, damage_error;
|
||||||
|
@ -820,6 +822,15 @@ main ()
|
||||||
DefaultVisual (dpy, scr)),
|
DefaultVisual (dpy, scr)),
|
||||||
CPSubwindowMode,
|
CPSubwindowMode,
|
||||||
&pa);
|
&pa);
|
||||||
|
blackPixmap = XCreatePixmap (dpy, root, 1, 1, 32);
|
||||||
|
pa.repeat = True;
|
||||||
|
blackPicture = XRenderCreatePicture (dpy, blackPixmap,
|
||||||
|
XRenderFindStandardFormat (dpy, PictStandardARGB32),
|
||||||
|
CPRepeat,
|
||||||
|
&pa);
|
||||||
|
c.red = c.green = c.blue = 0;
|
||||||
|
c.alpha = 0xffff;
|
||||||
|
XRenderFillRectangle (dpy, PictOpSrc, blackPicture, &c, 0, 0, 1, 1);
|
||||||
if (!XCompositeQueryExtension (dpy, &event_base, &error_base))
|
if (!XCompositeQueryExtension (dpy, &event_base, &error_base))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "No composite extension\n");
|
fprintf (stderr, "No composite extension\n");
|
||||||
|
@ -855,9 +866,12 @@ main ()
|
||||||
last_update = time_in_millis ();
|
last_update = time_in_millis ();
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
int busy_start = 0;
|
||||||
/* dump_wins (); */
|
/* dump_wins (); */
|
||||||
do {
|
do {
|
||||||
XNextEvent (dpy, &ev);
|
XNextEvent (dpy, &ev);
|
||||||
|
if (!busy_start)
|
||||||
|
busy_start = time_in_millis();
|
||||||
/* printf ("event %d\n", ev.type); */
|
/* printf ("event %d\n", ev.type); */
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case CreateNotify:
|
case CreateNotify:
|
||||||
|
@ -930,6 +944,7 @@ main ()
|
||||||
}
|
}
|
||||||
} while (XEventsQueued (dpy, QueuedAfterReading));
|
} while (XEventsQueued (dpy, QueuedAfterReading));
|
||||||
now = time_in_millis ();
|
now = time_in_millis ();
|
||||||
|
/* printf ("\t\tbusy %d\n", now - busy_start); */
|
||||||
timeout = INTERVAL - (now - last_update);
|
timeout = INTERVAL - (now - last_update);
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
{
|
{
|
||||||
|
@ -939,9 +954,11 @@ main ()
|
||||||
if (n > 0 && (ufd.revents & POLLIN) && XEventsQueued (dpy, QueuedAfterReading))
|
if (n > 0 && (ufd.revents & POLLIN) && XEventsQueued (dpy, QueuedAfterReading))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
last_update = time_in_millis();
|
|
||||||
if (allDamage)
|
if (allDamage)
|
||||||
{
|
{
|
||||||
|
int old_update = last_update;
|
||||||
|
last_update = time_in_millis();
|
||||||
|
/* printf ("delta %d\n", last_update - old_update); */
|
||||||
paint_all (dpy, allDamage);
|
paint_all (dpy, allDamage);
|
||||||
allDamage = None;
|
allDamage = None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue