Merge lp:~mc-return/compiz/compiz.merge-fix-1075578-workspacenames-flickering-during-display into lp:compiz/0.9.9

Proposed by MC Return
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3469
Merged at revision: 3643
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix-1075578-workspacenames-flickering-during-display
Merge into: lp:compiz/0.9.9
Diff against target: 224 lines (+82/-39)
2 files modified
plugins/workspacenames/src/workspacenames.cpp (+72/-39)
plugins/workspacenames/src/workspacenames.h (+10/-0)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix-1075578-workspacenames-flickering-during-display
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Sam Spilsbury Approve
Daniel van Vugt Pending
MC Return Pending
Review via email: mp+156271@code.launchpad.net

This proposal supersedes a proposal from 2013-02-27.

Commit message

Workspacenames:

Damage the text area correctly.
Extract the method used to determine where the text area was
into a separate function and use that to determine where our
damage area should be.
Also fix a few errors that happened on the last frame of animation.

This also fixes the flickering during display.

Other minor code refactoring.

(LP: #1075578, LP: #1162246)

Description of the change

Note:
Sophisticated damage handling is now implemented and fully working.
Credits and thanks for this work go to Sam !
Once again a *top job*.

This is fully tested and works perfectly :)

Now this plugin is ready for daily use.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

I think we should fix the FIXME. damageScreen is too expensive in some cases, and always when unityshell is loaded.

Please try using damageRegion instead. Similar to:
https://code.launchpad.net/~vanvugt/compiz/fix-1068518/+merge/131552

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> I think we should fix the FIXME. damageScreen is too expensive in some cases,
> and always when unityshell is loaded.
>

I agree. Using the show repaint plug-in even shows that visually. This should be improved indeed.

> Please try using damageRegion instead. Similar to:
> https://code.launchpad.net/~vanvugt/compiz/fix-1068518/+merge/131552

I will try to do it.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Somebody (Sam ? ;)) needs to help me with the implementation of the damage rectangle handling as I have no idea how to correctly implement it.

Nevertheless I would suggest to merge this branch for now as it fixes the flickering during display of the workspacename reliably.
Sophisticated damage handling can be implemented at a later stage as well, fixing the bug, every user of workspace naming experiences currently, should have priority.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> Sophisticated damage rectangle calculation and thus the FIXME is still missing.

Huh, surely it can't be that difficult.

Talk to me on IRC about it later today.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> > Sophisticated damage rectangle calculation and thus the FIXME is still
> missing.
>
> Huh, surely it can't be that difficult.
>
For me it still is ;)

Sam, please take over this branch and implement the correct damage rectangle handling.
I will study your .diff then and try to learn from that ;)

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

I'll have a look into this as soon as I get time to. I'm pretty busy
with uni and stuff at the moment.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> I'll have a look into this as soon as I get time to. I'm pretty busy
> with uni and stuff at the moment.

Thanks :)
No stress with that, but IMHO this MP can also be merged *as is* and the TODO
can also be implemented at a later stage...
This MP reliably fixes bug # #1075578, no more flickering.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> > I'll have a look into this as soon as I get time to. I'm pretty busy
> > with uni and stuff at the moment.
>
> Thanks :)
> No stress with that, but IMHO this MP can also be merged *as is* and the TODO
> can also be implemented at a later stage...
> This MP reliably fixes bug # #1075578, no more flickering.

Well, not quite. It does fix the bug yes, but the whole point of patch review is to ensure that we don't put things into the codebase that we know are bad. In this case, damageScreen on every frame (note: it really is on *every* *frame* regardless of whether the text box is active or not) is a pretty bad thing to go into the code, and currently causes other plugins using the damage region to go into serious overdrive.

So I think this one is at least worth looking into.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> > > I'll have a look into this as soon as I get time to. I'm pretty busy
> > > with uni and stuff at the moment.
> >
> > Thanks :)
> > No stress with that, but IMHO this MP can also be merged *as is* and the
> TODO
> > can also be implemented at a later stage...
> > This MP reliably fixes bug # #1075578, no more flickering.
>
> Well, not quite. It does fix the bug yes, but the whole point of patch review
> is to ensure that we don't put things into the codebase that we know are bad.
> In this case, damageScreen on every frame (note: it really is on *every*
> *frame* regardless of whether the text box is active or not) is a pretty bad
> thing to go into the code, and currently causes other plugins using the damage
> region to go into serious overdrive.
>
> So I think this one is at least worth looking into.

Urgh, you are right. :( I am sorry - I did not notice it was that bad (reproduced now with showrepaint).
I 100% agree that it is worth looking into (and I tried)...

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Sam, I've merged your branch into this one here now.
Thanks a lot (again) :)

I can confirm it works perfectly (have tested it with showrepaint).
The border could even be smaller I guess, as the damage rectangle
is bigger than actually needed, but that is a minor thingy ;)...

Or do you want me to fix that also ?

review: Approve
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

A minor problem still remains:

It seems the text is not fading in anymore (just out).
Investigating...

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Nope - never was fading in -> Sorry ;)

review: Approve
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

One minor improvement maybe:

We could change

+ const float TEXT_BORDER = 10.0f;

to

+ const unsigned short TEXT_BORDER = 2;

Did that in r3469.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

The change to TEXT_BORDER is fine.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/workspacenames/src/workspacenames.cpp'
--- plugins/workspacenames/src/workspacenames.cpp 2012-12-04 15:06:12 +0000
+++ plugins/workspacenames/src/workspacenames.cpp 2013-03-30 17:00:28 +0000
@@ -24,21 +24,23 @@
2424
25#include "workspacenames.h"25#include "workspacenames.h"
2626
27namespace
28{
29 const unsigned short TEXT_BORDER = 2;
30}
31
32
27CompString33CompString
28WSNamesScreen::getCurrentWSName ()34WSNamesScreen::getCurrentWSName ()
29{35{
30 int currentVp;
31 int listSize;
32 CompString ret;36 CompString ret;
33 CompOption::Value::Vector names;37
34 CompOption::Value::Vector vpNumbers;38 CompOption::Value::Vector vpNumbers = optionGetViewports ();
3539 CompOption::Value::Vector names = optionGetNames ();
36 vpNumbers = optionGetViewports ();40
37 names = optionGetNames ();41 int currentVp = screen->vp ().y () * screen->vpSize ().width () +
38
39 currentVp = screen->vp ().y () * screen->vpSize ().width () +
40 screen->vp ().x () + 1;42 screen->vp ().x () + 1;
41 listSize = MIN (vpNumbers.size (), names.size ());43 int listSize = MIN (vpNumbers.size (), names.size ());
4244
43 for (int i = 0; i < listSize; i++)45 for (int i = 0; i < listSize; i++)
44 if (vpNumbers[i].i () == currentVp)46 if (vpNumbers[i].i () == currentVp)
@@ -51,11 +53,10 @@
51WSNamesScreen::renderNameText ()53WSNamesScreen::renderNameText ()
52{54{
53 CompText::Attrib attrib;55 CompText::Attrib attrib;
54 CompString name;
5556
56 textData.clear ();57 textData.clear ();
5758
58 name = getCurrentWSName ();59 CompString name = getCurrentWSName ();
5960
60 if (name.empty ())61 if (name.empty ())
61 return;62 return;
@@ -86,16 +87,14 @@
86 textData.renderText (name, attrib);87 textData.renderText (name, attrib);
87}88}
8889
89void90CompPoint
90WSNamesScreen::drawText (const GLMatrix &matrix)91WSNamesScreen::getTextPlacementPosition ()
91{92{
92 GLfloat alpha;
93 float x, y, border = 10.0f;
94 CompRect oe = screen->getCurrentOutputExtents ();93 CompRect oe = screen->getCurrentOutputExtents ();
9594 float x = oe.centerX () - textData.getWidth () / 2;
96 x = oe.centerX () - textData.getWidth () / 2;95 float y = 0;
9796 const float border = TEXT_BORDER;
98 /* assign y (for the lower corner!) according to the setting */97
99 switch (optionGetTextPlacement ())98 switch (optionGetTextPlacement ())
100 {99 {
101 case WorkspacenamesOptions::TextPlacementCenteredOnScreen:100 case WorkspacenamesOptions::TextPlacementCenteredOnScreen:
@@ -108,7 +107,7 @@
108107
109 if (optionGetTextPlacement () ==108 if (optionGetTextPlacement () ==
110 WorkspacenamesOptions::TextPlacementTopOfScreen)109 WorkspacenamesOptions::TextPlacementTopOfScreen)
111 y = oe.y1 () + workArea.y () +110 y = oe.y1 () + workArea.y () +
112 (2 * border) + textData.getHeight ();111 (2 * border) + textData.getHeight ();
113 else112 else
114 y = oe.y1 () + workArea.y () +113 y = oe.y1 () + workArea.y () +
@@ -116,16 +115,49 @@
116 }115 }
117 break;116 break;
118 default:117 default:
119 return;118 return CompPoint (floor (x),
119 oe.centerY () - textData.getHeight () / 2);
120 break;120 break;
121 }121 }
122122
123 return CompPoint (floor (x), floor (y));
124}
125
126void
127WSNamesScreen::damageTextArea ()
128{
129 const CompPoint pos (getTextPlacementPosition ());
130
131 /* The placement position is from the lower corner, so we
132 * need to move it back up by height */
133 CompRect area (pos.x () - TEXT_BORDER,
134 pos.y () - TEXT_BORDER - textData.getHeight () ,
135 textData.getWidth () + TEXT_BORDER * 2,
136 textData.getHeight () + TEXT_BORDER * 2);
137
138 cScreen->damageRegion (area);
139}
140
141void
142WSNamesScreen::drawText (const GLMatrix &matrix)
143{
144 GLfloat alpha = 0.0f;
145
146 /* assign y (for the lower corner!) according to the setting */
147 const CompPoint p = getTextPlacementPosition ();
148
123 if (timer)149 if (timer)
124 alpha = timer / (optionGetFadeTime () * 1000.0f);150 alpha = timer / (optionGetFadeTime () * 1000.0f);
125 else151 else if (timeoutHandle.active ())
126 alpha = 1.0f;152 alpha = 1.0f;
127153
128 textData.draw (matrix, floor (x), floor (y), alpha);154 textData.draw (matrix, p.x (), p.y (), alpha);
155}
156
157bool
158WSNamesScreen::shouldDrawText ()
159{
160 return textData.getWidth () && textData.getHeight ();
129}161}
130162
131bool163bool
@@ -135,11 +167,9 @@
135 CompOutput *output,167 CompOutput *output,
136 unsigned int mask)168 unsigned int mask)
137{169{
138 bool status;170 bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
139171
140 status = gScreen->glPaintOutput (attrib, transform, region, output, mask);172 if (shouldDrawText ())
141
142 if (textData.getWidth () && textData.getHeight ())
143 {173 {
144 GLMatrix sTransform (transform);174 GLMatrix sTransform (transform);
145175
@@ -158,9 +188,6 @@
158 {188 {
159 timer -= msSinceLastPaint;189 timer -= msSinceLastPaint;
160 timer = MAX (timer, 0);190 timer = MAX (timer, 0);
161
162 if (!timer)
163 textData.clear ();
164 }191 }
165192
166 cScreen->preparePaint (msSinceLastPaint);193 cScreen->preparePaint (msSinceLastPaint);
@@ -169,21 +196,27 @@
169void196void
170WSNamesScreen::donePaint ()197WSNamesScreen::donePaint ()
171{198{
172 /* FIXME: better only damage paint region */199 /* Only damage when the */
173 if (timer)200 if (shouldDrawText ())
174 cScreen->damageScreen ();201 damageTextArea ();
202
203 cScreen->donePaint ();
175204
176 cScreen->donePaint ();205 /* Clear text data if done with fadeout */
206 if (!timer && !timeoutHandle.active ())
207 textData.clear ();
177}208}
178209
179bool210bool
180WSNamesScreen::hideTimeout ()211WSNamesScreen::hideTimeout ()
181{212{
182 timer = optionGetFadeTime () * 1000;213 timer = optionGetFadeTime () * 1000;
214
215 /* Clear immediately if there is no fadeout */
183 if (!timer)216 if (!timer)
184 textData.clear ();217 textData.clear ();
185218
186 cScreen->damageScreen ();219 damageTextArea ();
187220
188 timeoutHandle.stop ();221 timeoutHandle.stop ();
189222
@@ -209,7 +242,7 @@
209 renderNameText ();242 renderNameText ();
210 timeoutHandle.start (timeout, timeout + 200);243 timeoutHandle.start (timeout, timeout + 200);
211244
212 cScreen->damageScreen ();245 damageTextArea ();
213 }246 }
214}247}
215248
216249
=== modified file 'plugins/workspacenames/src/workspacenames.h'
--- plugins/workspacenames/src/workspacenames.h 2012-06-22 12:27:42 +0000
+++ plugins/workspacenames/src/workspacenames.h 2013-03-30 17:00:28 +0000
@@ -79,6 +79,16 @@
7979
80 void80 void
81 handleEvent (XEvent *);81 handleEvent (XEvent *);
82
83 CompPoint
84 getTextPlacementPosition ();
85
86 void
87 damageTextArea ();
88
89 private:
90
91 bool shouldDrawText ();
82};92};
8393
84class WorkspacenamesPluginVTable :94class WorkspacenamesPluginVTable :

Subscribers

People subscribed via source and target branches