Improvement: Split shadow_pict to shadow_pict & shadow_alpha_pict

Split w->shadow_pict to w->shadow_pict and w->shadow_alpha_pict, so that
the whole w->shadow_pict need not to be rebuild on shadow opacity
change. This greatly reduces CPU usage of compton when a window with
shadow is fading. (My test shows the CPU usage of compton process
dropped from 1.15% to 0.35% when constantly fading in and out a window.)
It uses a rather painful and slow method in shadow_picture() to get
around the limitation of PictStandardA8 to make colored shadows work. I
wonder if there's a better approach.

- Merge variables gsize and cgsize as they seemingly represent the same
  thing.
This commit is contained in:
Richard Grenville
2012-09-29 13:15:09 +08:00
parent 9139d038c2
commit 5a3dfbc064
2 changed files with 63 additions and 42 deletions

View File

@ -228,9 +228,10 @@ typedef struct _win {
int shadow_width;
/// Height of shadow. Affected by window size and commandline argument.
int shadow_height;
/// Alpha mask Picture to render shadow. Affected by window size and
/// shadow opacity.
/// Picture to render shadow. Affected by window size.
Picture shadow_pict;
/// Alpha mask Picture to render shadow. Affected by shadow opacity.
Picture shadow_alpha_pict;
// Dim-related members
/// Whether the window is to be dimmed.