diff options
author | Danny Baumann <dannybaumann@web.de> | 2008-07-29 14:24:18 +0200 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2008-07-29 14:24:18 +0200 |
commit | 75ee20c08c5132fba1a3ec9486550b9fde8ec4fc (patch) | |
tree | 6d7a1bec72b3ff1b31f68c60ed03181ad37dc7d3 /plugins | |
parent | c47b6aa052a8066c83367f034c994de2b758525b (diff) |
Simplify calculations.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/fade.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/plugins/fade.c b/plugins/fade.c index e50c3226..2727a349 100644 --- a/plugins/fade.c +++ b/plugins/fade.c @@ -88,9 +88,9 @@ typedef struct _FadeWindow { int fadeTime; - GLushort sourceOpacity; - GLushort sourceBrightness; - GLushort sourceSaturation; + int opacityDiff; + int brightnessDiff; + int saturationDiff; GLushort targetOpacity; GLushort targetBrightness; @@ -307,9 +307,9 @@ fadePaintWindow (CompWindow *w, fw->fadeTime = fs->opt[FADE_SCREEN_OPTION_FADE_TIME].value.i; fw->steps = 1; - fw->sourceOpacity = fw->opacity; - fw->sourceBrightness = fw->brightness; - fw->sourceSaturation = fw->saturation; + fw->opacityDiff = fAttrib.opacity - fw->opacity; + fw->brightnessDiff = fAttrib.brightness - fw->brightness; + fw->saturationDiff = fAttrib.saturation - fw->saturation; fw->targetOpacity = fAttrib.opacity; fw->targetBrightness = fAttrib.brightness; @@ -373,17 +373,14 @@ fadePaintWindow (CompWindow *w, } else if (mode == FADE_MODE_CONSTANTTIME) { - int fadeTime, elapsed; - - fadeTime = fs->opt[FADE_SCREEN_OPTION_FADE_TIME].value.i; - elapsed = fadeTime - fw->fadeTime; - - opacity = ((fw->sourceOpacity * fw->fadeTime) + - (fAttrib.opacity * elapsed)) / fadeTime; - brightness = ((fw->sourceBrightness * fw->fadeTime) + - (fAttrib.brightness * elapsed)) / fadeTime; - saturation = ((fw->sourceSaturation * fw->fadeTime) + - (fAttrib.saturation * elapsed)) / fadeTime; + int fadeTime = fs->opt[FADE_SCREEN_OPTION_FADE_TIME].value.i; + + opacity = fAttrib.opacity - + (fw->opacityDiff * fw->fadeTime / fadeTime); + brightness = fAttrib.brightness - + (fw->brightnessDiff * fw->fadeTime / fadeTime); + saturation = fAttrib.saturation - + (fw->saturationDiff * fw->fadeTime / fadeTime); } fw->steps = 0; @@ -874,9 +871,13 @@ fadeInitWindow (CompPlugin *p, fw->brightness = w->paint.brightness; fw->saturation = w->paint.saturation; - fw->targetOpacity = fw->sourceOpacity = fw->opacity; - fw->targetBrightness = fw->sourceBrightness = fw->brightness; - fw->targetSaturation = fw->sourceSaturation = fw->saturation; + fw->targetOpacity = fw->opacity; + fw->targetBrightness = fw->brightness; + fw->targetSaturation = fw->saturation; + + fw->opacityDiff = 0; + fw->brightnessDiff = 0; + fw->saturationDiff = 0; fw->dModal = 0; |