Commit e3f06bfca50599315e5d70526b0307cd90ce5617

Authored by Marco Trevisan (Treviño)
Committed by Bileto Bot
2 parents 98a7518c 216e6b33

grid: ignore alpha in colors when not blending, and fix animations

The fade-out animation was still happening when the duration was set to 1,
while it was broken when it was 0. Fixed both.

In unity-lowgfx.ini set the animation duration to 0 in grid and d not
draw stretched windows. Enable blending again as it's really not
expensive in this case, while not having it, really makes the user
experience a lot poorer. (LP: #1700859)

Approved by: Andrea Azzarone
debian/unity-lowgfx.ini
... ... @@ -12,8 +12,8 @@ s0_fade_mode = 1
12 12 s0_fade_time = 1
13 13  
14 14 [grid]
15   -s0_animation_duration = 1
16   -s0_disable_blend = true
  15 +s0_animation_duration = 0
  16 +s0_draw_stretched_window = false
17 17  
18 18 [resize]
19 19 s0_mode = 2
... ...
plugins/grid/src/grid.cpp
... ... @@ -532,7 +532,7 @@ GridScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib,
532 532 Animation& anim = *iter;
533 533  
534 534 float curve = powf (CURVE_ANIMATION, -anim.progress);
535   - float alpha = (optionGetFillColorAlpha () / MaxUShortFloat) * anim.opacity;
  535 + float alpha = blend ? (optionGetFillColorAlpha () / MaxUShortFloat) * anim.opacity : 0.85;
536 536 color = optionGetFillColor ();
537 537  
538 538 colorData[0] = alpha * color[0];
... ... @@ -570,7 +570,7 @@ GridScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib,
570 570 anim.currentRect.height () - 2);
571 571  
572 572 /* draw outline */
573   - alpha = (optionGetOutlineColorAlpha () / MaxUShortFloat) * anim.opacity;
  573 + alpha = blend ? (optionGetOutlineColorAlpha () / MaxUShortFloat) * anim.opacity : 1;
574 574 color = optionGetOutlineColor ();
575 575  
576 576 colorData[0] = alpha * color[0];
... ... @@ -603,7 +603,7 @@ GridScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib,
603 603 if (!animating)
604 604 {
605 605 /* draw filled rectangle */
606   - float alpha = optionGetFillColorAlpha () / MaxUShortFloat;
  606 + float alpha = blend ? optionGetFillColorAlpha () / MaxUShortFloat : 0.85;
607 607 color = optionGetFillColor ();
608 608  
609 609 colorData[0] = alpha * color[0];
... ... @@ -885,7 +885,7 @@ GridScreen::handleEvent (XEvent *event)
885 885 animations.at (current).fromRect = w->serverBorderRect ();
886 886 animations.at (current).currentRect = w->serverBorderRect ();
887 887 animations.at (current).duration = optionGetAnimationDuration ();
888   - animations.at (current).timer = animations.at (current).duration;
  888 + animations.at (current).progress = 0.0f;
889 889 animations.at (current).targetRect = desiredSlot;
890 890 animations.at (current).window = w->id();
891 891  
... ... @@ -1199,18 +1199,24 @@ GridScreen::preparePaint (int msSinceLastPaint)
1199 1199 for (iter = animations.begin (); iter != animations.end (); ++iter)
1200 1200 {
1201 1201 Animation& anim = *iter;
1202   - anim.timer -= msSinceLastPaint;
  1202 + GLfloat msSinceLastPaintFloat = static_cast<GLfloat>(msSinceLastPaint);
  1203 + GLfloat animDurationFloat = static_cast<GLfloat>(anim.duration);
  1204 + GLfloat progress_delta = 1.0f;
1203 1205  
1204   - if (anim.timer < 0)
1205   - anim.timer = 0;
  1206 + if (animDurationFloat > 0.0f)
  1207 + progress_delta = msSinceLastPaintFloat / animDurationFloat;
1206 1208  
1207 1209 if (anim.fadingOut)
1208   - anim.opacity -= msSinceLastPaint * 0.002;
  1210 + {
  1211 + anim.opacity -= progress_delta;
  1212 + }
1209 1213 else
  1214 + {
1210 1215 if (anim.opacity < 1.0f)
1211 1216 anim.opacity = anim.progress * anim.progress;
1212 1217 else
1213 1218 anim.opacity = 1.0f;
  1219 + }
1214 1220  
1215 1221 if (anim.opacity < 0)
1216 1222 {
... ... @@ -1219,10 +1225,10 @@ GridScreen::preparePaint (int msSinceLastPaint)
1219 1225 anim.complete = true;
1220 1226 }
1221 1227  
1222   - anim.progress = (anim.duration - anim.timer) / anim.duration;
  1228 + anim.progress = std::min<GLfloat>(anim.progress + progress_delta, 1.0);
1223 1229 }
1224 1230  
1225   - if (optionGetDrawStretchedWindow ())
  1231 + if (optionGetDrawStretchedWindow () && !optionGetDisableBlend ())
1226 1232 {
1227 1233 CompWindow *cw = screen->findWindow (CompOption::getIntOptionNamed (o, "window"));
1228 1234  
... ... @@ -1292,7 +1298,6 @@ Animation::Animation ()
1292 1298 targetRect = CompRect (0, 0, 0, 0);
1293 1299 currentRect = CompRect (0, 0, 0, 0);
1294 1300 opacity = 0.0f;
1295   - timer = 0.0f;
1296 1301 duration = 0;
1297 1302 complete = false;
1298 1303 fadingOut = false;
... ... @@ -1400,7 +1405,7 @@ GridWindow::glPaint (const GLWindowPaintAttrib&amp; attrib, const GLMatrix&amp; matrix,
1400 1405 {
1401 1406 Animation& anim = *iter;
1402 1407  
1403   - if (anim.timer > 0.0f && anim.window == window->id())
  1408 + if (anim.progress < 1.0f && anim.window == window->id())
1404 1409 {
1405 1410 GLWindowPaintAttrib wAttrib(attrib);
1406 1411 GLMatrix wTransform (matrix);
... ...
plugins/grid/src/grid.h
... ... @@ -96,7 +96,6 @@ class Animation
96 96 CompRect targetRect;
97 97 CompRect currentRect;
98 98 GLfloat opacity;
99   - GLfloat timer;
100 99 Window window;
101 100 int duration;
102 101 bool complete;
... ...