Merge lp:~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell.0 into lp:compiz/0.9.10

Proposed by MC Return
Status: Work in progress
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell.0
Merge into: lp:compiz/0.9.10
Diff against target: 64 lines (+2/-13)
2 files modified
plugins/screenshot/src/screenshot.cpp (+2/-12)
plugins/screenshot/src/screenshot.h (+0/-1)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell.0
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+165112@code.launchpad.net

Commit message

Screenshot plugin:
We have to redraw and damage the painted region the whole time,
if unityshell is enabled, not only when it's size changed.
Otherwise the constant whole-screen damaging of Unity makes the
screenshot selection box disappear.

Note:
Screenshot is less efficient now, so this should probably be
reverted, once unityshell has learned to correctly damage just
repainted regions.

(LP: #1182794)

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
MC Return (mc-return) wrote :

Sam, I am setting this back to WIP as it seems to need the additional damage call - otherwise it can get into a flickering condition...

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

Hmm, I'm not really a fan of that approach as it causes spurious redraws due to the repaint-rescheduling happening every time a draw function is called (eg, all the time). Overdraw will certainly be the cause of flickering in some cases though.

The other option is to grab the current damage region and clip drawing to that so there is no overdraw. For example:

bool scissoringEnabled = glIsEnabled (GL_SCISSOR_TEST);
GLint lastScissorBox[4];

glGetIntegerv (GL_SCISSOR_BOX, lastScissorBox);

glEnable (GL_SCISSOR_TEST);

CompRect::vector rects = region.rects ();

foreach (const CompRect &rect, rects)
{
    glScissor (rect.x1 (),
               screen->height () - rect.y2 (),
               rect.width (),
               rect.height ());

    streamingBuffer->render ();
}

/* Reset scissor state */
if (!scissoringEnabled)
    glDisable (GL_SCISSOR_TEST);

/* Reset scissor box to old value */
glScissor (lastScissorBox[0],
           lastScissorBox[1],
           lastScissorBox[2],
           lastScissorBox[3]);

This reminds me that GLVertexBuffer could probably use a clip () or renderClipped () method so that we don't have to repeat this everywhere.

Revision history for this message
MC Return (mc-return) wrote :

I am not really a fan of re-fixing screenshot again as I really have the strong feeling Unity is to blame for the disappearing-screenshot-selection-box-bug...

Although the damage code could still be improved, the "non-redrawing and non-re-damaging when not moving the mouse" version seems to be very efficient and working perfectly in all cases, even with video underneath the selection box, except when Unity decides to redraw the whole screen/all screens without reason (or because one pixel in the panel changed) :(
This also leads to other nasty side-effects, like flickering annotate boxes and ellipses and really should be fixed there, not worked around in all other plugins IMHO...

Sam, don't you have some damaging fixes for nux/unity ready somewhere or am I hallucinating ?

It would really be nice if Unity could learn some efficiency in screen damaging as currently it not only creates bugs, but also degrades Compiz' performance massively... :(

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

I do - but they don't completely fix the problem. Its only able to
make the panels and redraw (to the extent that they are just blitted
back to the backbuffer) once some damage intersects them, but it
doesn't do any of the vertex clipping stuff that compiz does.

To be honest though the problem is with the screenshot plugin and more
generally plugins that draw stuff on top of the screen directly.
There's no way to clip to damage regions with those, which is what
causes overdraw related flickering.

On Tue, May 28, 2013 at 12:37 AM, MC Return <email address hidden> wrote:
> I am not really a fan of re-fixing screenshot again as I really have the strong feeling Unity is to blame for the disappearing-screenshot-selection-box-bug...
>
> Although the damage code could still be improved, the "non-redrawing and non-re-damaging when not moving the mouse" version seems to be very efficient and working perfectly in all cases, even with video underneath the selection box, except when Unity decides to redraw the whole screen/all screens without reason (or because one pixel in the panel changed) :(
> This also leads to other nasty side-effects, like flickering annotate boxes and ellipses and really should be fixed there, not worked around in all other plugins IMHO...
>
> Sam, don't you have some damaging fixes for nux/unity ready somewhere or am I hallucinating ?
>
> It would really be nice if Unity could learn some efficiency in screen damaging as currently it not only creates bugs, but also degrades Compiz' performance massively... :(
> --
> https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell.0/+merge/165112
> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell.0 into lp:compiz.

--
Sam Spilsbury

Revision history for this message
MC Return (mc-return) wrote :

I am waiting with the final fix for this until the damage handling of Unity has been improved or until shortly before the release of 0.9.10, although I really would like to finish the work on screenshot and maybe just add features to this plugin (like the possibility of taking screenshots of individual windows)...

Unmerged revisions

3723. By MC Return

Reduced the .diff to make review easier

3722. By MC Return

Screenshot plugin:
We have to redraw and damage the painted region the whole time,
if unityshell is enabled, not only when it's size changed
Otherwise the constant whole-screen damaging of Unity makes the
screenshot selection box disappear

Note:
Screenshot is less efficient now, so this should probably be
reverted, once unityshell has learned to correctly damage just
repainted regions

(LP: #1182794)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/screenshot/src/screenshot.cpp'
2--- plugins/screenshot/src/screenshot.cpp 2013-05-09 13:43:07 +0000
3+++ plugins/screenshot/src/screenshot.cpp 2013-05-22 13:30:54 +0000
4@@ -456,8 +456,7 @@
5 if (status && mGrab)
6 {
7 /* We just want to draw the screenshot selection box if
8- * we are grabbed, the size has changed and the CCSM
9- * option to draw it is enabled. */
10+ * we are grabbed and the CCSM option to draw it is enabled. */
11
12 CompRect selectionRect (std::min (mX1, mX2),
13 std::min (mY1, mY2),
14@@ -465,7 +464,6 @@
15 std::abs (mY2 - mY1));
16
17 if (mGrabIndex &&
18- selectionSizeChanged &&
19 optionGetDrawSelectionIndicator ())
20 {
21 GLMatrix transform (matrix);
22@@ -481,10 +479,6 @@
23 optionGetSelectionOutlineColor (),
24 streamingBuffer,
25 transform);
26-
27- /* we finished painting the selection box,
28- * reset selectionSizeChanged now */
29- selectionSizeChanged = false;
30 }
31 else if (!mGrabIndex)
32 {
33@@ -508,9 +502,6 @@
34 if (mGrabIndex &&
35 (mX2 != xRoot || mY2 != yRoot))
36 {
37- /* the size has changed now */
38- selectionSizeChanged = true;
39-
40 int x1 = MIN (mX1, mX2) - 1;
41 int y1 = MIN (mY1, mY2) - 1;
42 int x2 = MAX (mX1, mX2) + 1;
43@@ -558,8 +549,7 @@
44 cScreen (CompositeScreen::get (screen)),
45 gScreen (GLScreen::get (screen)),
46 mGrabIndex (0),
47- mGrab (false),
48- selectionSizeChanged (false)
49+ mGrab (false)
50 {
51 optionSetInitiateButtonInitiate (boost::bind (&ShotScreen::initiate, this,
52 _1, _2, _3));
53
54=== modified file 'plugins/screenshot/src/screenshot.h'
55--- plugins/screenshot/src/screenshot.h 2013-04-24 11:38:36 +0000
56+++ plugins/screenshot/src/screenshot.h 2013-05-22 13:30:54 +0000
57@@ -66,7 +66,6 @@
58
59 CompScreen::GrabHandle mGrabIndex;
60 bool mGrab;
61- bool selectionSizeChanged;
62
63 int mX1, mY1, mX2, mY2;
64 };

Subscribers

People subscribed via source and target branches

to all changes: