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
1=== modified file 'plugins/workspacenames/src/workspacenames.cpp'
2--- plugins/workspacenames/src/workspacenames.cpp 2012-12-04 15:06:12 +0000
3+++ plugins/workspacenames/src/workspacenames.cpp 2013-03-30 17:00:28 +0000
4@@ -24,21 +24,23 @@
5
6 #include "workspacenames.h"
7
8+namespace
9+{
10+ const unsigned short TEXT_BORDER = 2;
11+}
12+
13+
14 CompString
15 WSNamesScreen::getCurrentWSName ()
16 {
17- int currentVp;
18- int listSize;
19 CompString ret;
20- CompOption::Value::Vector names;
21- CompOption::Value::Vector vpNumbers;
22-
23- vpNumbers = optionGetViewports ();
24- names = optionGetNames ();
25-
26- currentVp = screen->vp ().y () * screen->vpSize ().width () +
27+
28+ CompOption::Value::Vector vpNumbers = optionGetViewports ();
29+ CompOption::Value::Vector names = optionGetNames ();
30+
31+ int currentVp = screen->vp ().y () * screen->vpSize ().width () +
32 screen->vp ().x () + 1;
33- listSize = MIN (vpNumbers.size (), names.size ());
34+ int listSize = MIN (vpNumbers.size (), names.size ());
35
36 for (int i = 0; i < listSize; i++)
37 if (vpNumbers[i].i () == currentVp)
38@@ -51,11 +53,10 @@
39 WSNamesScreen::renderNameText ()
40 {
41 CompText::Attrib attrib;
42- CompString name;
43
44 textData.clear ();
45
46- name = getCurrentWSName ();
47+ CompString name = getCurrentWSName ();
48
49 if (name.empty ())
50 return;
51@@ -86,16 +87,14 @@
52 textData.renderText (name, attrib);
53 }
54
55-void
56-WSNamesScreen::drawText (const GLMatrix &matrix)
57+CompPoint
58+WSNamesScreen::getTextPlacementPosition ()
59 {
60- GLfloat alpha;
61- float x, y, border = 10.0f;
62 CompRect oe = screen->getCurrentOutputExtents ();
63-
64- x = oe.centerX () - textData.getWidth () / 2;
65-
66- /* assign y (for the lower corner!) according to the setting */
67+ float x = oe.centerX () - textData.getWidth () / 2;
68+ float y = 0;
69+ const float border = TEXT_BORDER;
70+
71 switch (optionGetTextPlacement ())
72 {
73 case WorkspacenamesOptions::TextPlacementCenteredOnScreen:
74@@ -108,7 +107,7 @@
75
76 if (optionGetTextPlacement () ==
77 WorkspacenamesOptions::TextPlacementTopOfScreen)
78- y = oe.y1 () + workArea.y () +
79+ y = oe.y1 () + workArea.y () +
80 (2 * border) + textData.getHeight ();
81 else
82 y = oe.y1 () + workArea.y () +
83@@ -116,16 +115,49 @@
84 }
85 break;
86 default:
87- return;
88+ return CompPoint (floor (x),
89+ oe.centerY () - textData.getHeight () / 2);
90 break;
91 }
92
93+ return CompPoint (floor (x), floor (y));
94+}
95+
96+void
97+WSNamesScreen::damageTextArea ()
98+{
99+ const CompPoint pos (getTextPlacementPosition ());
100+
101+ /* The placement position is from the lower corner, so we
102+ * need to move it back up by height */
103+ CompRect area (pos.x () - TEXT_BORDER,
104+ pos.y () - TEXT_BORDER - textData.getHeight () ,
105+ textData.getWidth () + TEXT_BORDER * 2,
106+ textData.getHeight () + TEXT_BORDER * 2);
107+
108+ cScreen->damageRegion (area);
109+}
110+
111+void
112+WSNamesScreen::drawText (const GLMatrix &matrix)
113+{
114+ GLfloat alpha = 0.0f;
115+
116+ /* assign y (for the lower corner!) according to the setting */
117+ const CompPoint p = getTextPlacementPosition ();
118+
119 if (timer)
120 alpha = timer / (optionGetFadeTime () * 1000.0f);
121- else
122+ else if (timeoutHandle.active ())
123 alpha = 1.0f;
124
125- textData.draw (matrix, floor (x), floor (y), alpha);
126+ textData.draw (matrix, p.x (), p.y (), alpha);
127+}
128+
129+bool
130+WSNamesScreen::shouldDrawText ()
131+{
132+ return textData.getWidth () && textData.getHeight ();
133 }
134
135 bool
136@@ -135,11 +167,9 @@
137 CompOutput *output,
138 unsigned int mask)
139 {
140- bool status;
141-
142- status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
143-
144- if (textData.getWidth () && textData.getHeight ())
145+ bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
146+
147+ if (shouldDrawText ())
148 {
149 GLMatrix sTransform (transform);
150
151@@ -158,9 +188,6 @@
152 {
153 timer -= msSinceLastPaint;
154 timer = MAX (timer, 0);
155-
156- if (!timer)
157- textData.clear ();
158 }
159
160 cScreen->preparePaint (msSinceLastPaint);
161@@ -169,21 +196,27 @@
162 void
163 WSNamesScreen::donePaint ()
164 {
165- /* FIXME: better only damage paint region */
166- if (timer)
167- cScreen->damageScreen ();
168+ /* Only damage when the */
169+ if (shouldDrawText ())
170+ damageTextArea ();
171+
172+ cScreen->donePaint ();
173
174- cScreen->donePaint ();
175+ /* Clear text data if done with fadeout */
176+ if (!timer && !timeoutHandle.active ())
177+ textData.clear ();
178 }
179
180 bool
181 WSNamesScreen::hideTimeout ()
182 {
183 timer = optionGetFadeTime () * 1000;
184+
185+ /* Clear immediately if there is no fadeout */
186 if (!timer)
187 textData.clear ();
188-
189- cScreen->damageScreen ();
190+
191+ damageTextArea ();
192
193 timeoutHandle.stop ();
194
195@@ -209,7 +242,7 @@
196 renderNameText ();
197 timeoutHandle.start (timeout, timeout + 200);
198
199- cScreen->damageScreen ();
200+ damageTextArea ();
201 }
202 }
203
204
205=== modified file 'plugins/workspacenames/src/workspacenames.h'
206--- plugins/workspacenames/src/workspacenames.h 2012-06-22 12:27:42 +0000
207+++ plugins/workspacenames/src/workspacenames.h 2013-03-30 17:00:28 +0000
208@@ -79,6 +79,16 @@
209
210 void
211 handleEvent (XEvent *);
212+
213+ CompPoint
214+ getTextPlacementPosition ();
215+
216+ void
217+ damageTextArea ();
218+
219+ private:
220+
221+ bool shouldDrawText ();
222 };
223
224 class WorkspacenamesPluginVTable :

Subscribers

People subscribed via source and target branches