From 3453dc5d8538fe216b1d078eeebef3065fe2d26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 28 Jun 2017 05:51:58 +0200 Subject: [PATCH 1/5] grid: don't use alpha in colors if not using blending --- plugins/grid/src/grid.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/grid/src/grid.cpp b/plugins/grid/src/grid.cpp index c1cb7e036..62d09fdaf 100755 --- a/plugins/grid/src/grid.cpp +++ b/plugins/grid/src/grid.cpp @@ -532,7 +532,7 @@ GridScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib, Animation& anim = *iter; float curve = powf (CURVE_ANIMATION, -anim.progress); - float alpha = (optionGetFillColorAlpha () / MaxUShortFloat) * anim.opacity; + float alpha = blend ? (optionGetFillColorAlpha () / MaxUShortFloat) * anim.opacity : 0.85; color = optionGetFillColor (); colorData[0] = alpha * color[0]; @@ -570,7 +570,7 @@ GridScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib, anim.currentRect.height () - 2); /* draw outline */ - alpha = (optionGetOutlineColorAlpha () / MaxUShortFloat) * anim.opacity; + alpha = blend ? (optionGetOutlineColorAlpha () / MaxUShortFloat) * anim.opacity : 1; color = optionGetOutlineColor (); colorData[0] = alpha * color[0]; @@ -603,7 +603,7 @@ GridScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib, if (!animating) { /* draw filled rectangle */ - float alpha = optionGetFillColorAlpha () / MaxUShortFloat; + float alpha = blend ? optionGetFillColorAlpha () / MaxUShortFloat : 0.85; color = optionGetFillColor (); colorData[0] = alpha * color[0]; -- GitLab From d7a768d605cf42d9908fbae4fa70b00e1145ba5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 29 Jun 2017 02:13:44 +0200 Subject: [PATCH 2/5] grid: take care of the user-set animation duration even on fade-out --- plugins/grid/src/grid.cpp | 10 ++++++++-- plugins/grid/src/grid.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/grid/src/grid.cpp b/plugins/grid/src/grid.cpp index 62d09fdaf..32afb2811 100755 --- a/plugins/grid/src/grid.cpp +++ b/plugins/grid/src/grid.cpp @@ -886,6 +886,7 @@ GridScreen::handleEvent (XEvent *event) animations.at (current).currentRect = w->serverBorderRect (); animations.at (current).duration = optionGetAnimationDuration (); animations.at (current).timer = animations.at (current).duration; + animations.at (current).fadeOutTimer = animations.at (current).duration; animations.at (current).targetRect = desiredSlot; animations.at (current).window = w->id(); @@ -1205,7 +1206,11 @@ GridScreen::preparePaint (int msSinceLastPaint) anim.timer = 0; if (anim.fadingOut) - anim.opacity -= msSinceLastPaint * 0.002; + { + anim.fadeOutTimer -= msSinceLastPaint; + double progress = (anim.duration - anim.fadeOutTimer) / anim.duration;anim.opacity = 1.0 - progress; + anim.opacity = 1.0 - progress; + } else if (anim.opacity < 1.0f) anim.opacity = anim.progress * anim.progress; @@ -1222,7 +1227,7 @@ GridScreen::preparePaint (int msSinceLastPaint) anim.progress = (anim.duration - anim.timer) / anim.duration; } - if (optionGetDrawStretchedWindow ()) + if (optionGetDrawStretchedWindow () && !optionGetDisableBlend ()) { CompWindow *cw = screen->findWindow (CompOption::getIntOptionNamed (o, "window")); @@ -1296,6 +1301,7 @@ Animation::Animation () duration = 0; complete = false; fadingOut = false; + fadeOutTimer = 0.0f; window = 0; } diff --git a/plugins/grid/src/grid.h b/plugins/grid/src/grid.h index 8390f4c39..03a2c346e 100644 --- a/plugins/grid/src/grid.h +++ b/plugins/grid/src/grid.h @@ -97,6 +97,7 @@ class Animation CompRect currentRect; GLfloat opacity; GLfloat timer; + GLfloat fadeOutTimer; Window window; int duration; bool complete; -- GitLab From 8783ff2c3664838e55946cb6ec3b38ca00910498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 29 Jun 2017 02:22:38 +0200 Subject: [PATCH 3/5] grid: no need to use a timer for fadeout, just define the progress delta. --- plugins/grid/src/grid.cpp | 9 ++++----- plugins/grid/src/grid.h | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/grid/src/grid.cpp b/plugins/grid/src/grid.cpp index 32afb2811..f70518b84 100755 --- a/plugins/grid/src/grid.cpp +++ b/plugins/grid/src/grid.cpp @@ -886,7 +886,6 @@ GridScreen::handleEvent (XEvent *event) animations.at (current).currentRect = w->serverBorderRect (); animations.at (current).duration = optionGetAnimationDuration (); animations.at (current).timer = animations.at (current).duration; - animations.at (current).fadeOutTimer = animations.at (current).duration; animations.at (current).targetRect = desiredSlot; animations.at (current).window = w->id(); @@ -1207,15 +1206,16 @@ GridScreen::preparePaint (int msSinceLastPaint) if (anim.fadingOut) { - anim.fadeOutTimer -= msSinceLastPaint; - double progress = (anim.duration - anim.fadeOutTimer) / anim.duration;anim.opacity = 1.0 - progress; - anim.opacity = 1.0 - progress; + GLfloat progress_delta = static_cast(msSinceLastPaint) / static_cast(anim.duration); + anim.opacity -= progress_delta; } else + { if (anim.opacity < 1.0f) anim.opacity = anim.progress * anim.progress; else anim.opacity = 1.0f; + } if (anim.opacity < 0) { @@ -1301,7 +1301,6 @@ Animation::Animation () duration = 0; complete = false; fadingOut = false; - fadeOutTimer = 0.0f; window = 0; } diff --git a/plugins/grid/src/grid.h b/plugins/grid/src/grid.h index 03a2c346e..8390f4c39 100644 --- a/plugins/grid/src/grid.h +++ b/plugins/grid/src/grid.h @@ -97,7 +97,6 @@ class Animation CompRect currentRect; GLfloat opacity; GLfloat timer; - GLfloat fadeOutTimer; Window window; int duration; bool complete; -- GitLab From d2eb4171bee5e422e3f94f2d84e7d06d04c3fc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 29 Jun 2017 02:42:16 +0200 Subject: [PATCH 4/5] grid: don't use timer in animation and allow to set animation duration to 0 --- plugins/grid/src/grid.cpp | 16 ++++++++-------- plugins/grid/src/grid.h | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/plugins/grid/src/grid.cpp b/plugins/grid/src/grid.cpp index f70518b84..1532b2622 100755 --- a/plugins/grid/src/grid.cpp +++ b/plugins/grid/src/grid.cpp @@ -885,7 +885,7 @@ GridScreen::handleEvent (XEvent *event) animations.at (current).fromRect = w->serverBorderRect (); animations.at (current).currentRect = w->serverBorderRect (); animations.at (current).duration = optionGetAnimationDuration (); - animations.at (current).timer = animations.at (current).duration; + animations.at (current).progress = 0.0f; animations.at (current).targetRect = desiredSlot; animations.at (current).window = w->id(); @@ -1199,14 +1199,15 @@ GridScreen::preparePaint (int msSinceLastPaint) for (iter = animations.begin (); iter != animations.end (); ++iter) { Animation& anim = *iter; - anim.timer -= msSinceLastPaint; + GLfloat msSinceLastPaintFloat = static_cast(msSinceLastPaint); + GLfloat animDurationFloat = static_cast(anim.duration); + GLfloat progress_delta = 1.0f; - if (anim.timer < 0) - anim.timer = 0; + if (animDurationFloat > 0.0f) + progress_delta = msSinceLastPaintFloat / animDurationFloat; if (anim.fadingOut) { - GLfloat progress_delta = static_cast(msSinceLastPaint) / static_cast(anim.duration); anim.opacity -= progress_delta; } else @@ -1224,7 +1225,7 @@ GridScreen::preparePaint (int msSinceLastPaint) anim.complete = true; } - anim.progress = (anim.duration - anim.timer) / anim.duration; + anim.progress = std::min(anim.progress + progress_delta, 1.0); } if (optionGetDrawStretchedWindow () && !optionGetDisableBlend ()) @@ -1297,7 +1298,6 @@ Animation::Animation () targetRect = CompRect (0, 0, 0, 0); currentRect = CompRect (0, 0, 0, 0); opacity = 0.0f; - timer = 0.0f; duration = 0; complete = false; fadingOut = false; @@ -1405,7 +1405,7 @@ GridWindow::glPaint (const GLWindowPaintAttrib& attrib, const GLMatrix& matrix, { Animation& anim = *iter; - if (anim.timer > 0.0f && anim.window == window->id()) + if (anim.progress < 1.0f && anim.window == window->id()) { GLWindowPaintAttrib wAttrib(attrib); GLMatrix wTransform (matrix); diff --git a/plugins/grid/src/grid.h b/plugins/grid/src/grid.h index 8390f4c39..40b18017f 100644 --- a/plugins/grid/src/grid.h +++ b/plugins/grid/src/grid.h @@ -96,7 +96,6 @@ class Animation CompRect targetRect; CompRect currentRect; GLfloat opacity; - GLfloat timer; Window window; int duration; bool complete; -- GitLab From 216e6b33fd8deecf1aa072f8a123007a4f1522c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 29 Jun 2017 02:53:31 +0200 Subject: [PATCH 5/5] unity-lowgfx.ini: set the animation duration to 0 in grid and no stretched windows Enable blending again as it's really not expensive in this case, while not having it, really reduces the user experience a lot. --- debian/unity-lowgfx.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/unity-lowgfx.ini b/debian/unity-lowgfx.ini index 88570689d..b0ed77fe3 100644 --- a/debian/unity-lowgfx.ini +++ b/debian/unity-lowgfx.ini @@ -12,8 +12,8 @@ s0_fade_mode = 1 s0_fade_time = 1 [grid] -s0_animation_duration = 1 -s0_disable_blend = true +s0_animation_duration = 0 +s0_draw_stretched_window = false [resize] s0_mode = 2 -- GitLab