Merge lp:~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell 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
Merge into: lp:compiz/0.9.10
Diff against target: 128 lines (+17/-24)
2 files modified
plugins/screenshot/src/screenshot.cpp (+7/-20)
plugins/screenshot/src/screenshot.h (+10/-4)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell
Reviewer Review Type Date Requested Status
Sam Spilsbury Needs Information
Review via email: mp+165066@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.

Minor indentation fixes.

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.
3723. By MC Return

Removed line committed by accident

3724. By MC Return

Added newline

3725. By MC Return

Fixed indentation

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

"Otherwise the constant whole-screen damaging of Unity makes the
screenshot selection box disappear."

Can you explain more why you think that's happening? I don't see why an expanded damage region would cause some elements not to paint.

review: Needs Information
3726. By MC Return

Fixed comment

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

> "Otherwise the constant whole-screen damaging of Unity makes the
> screenshot selection box disappear."
>
> Can you explain more why you think that's happening? I don't see why an
> expanded damage region would cause some elements not to paint.

No, not really - as I've not investigated the exact cause, but just analyzed
the symptomps.
I have indicator-multiload running here, which paints on top of the Unity panel
each 30 millisecs, which makes unityshell damage the whole screen each 30ms
(very efficient by the way ;) - see bug ##1182803).
When I turn off indicator-multiload, unityshell will damage the whole screen
each second, because the time display redraw (seconds) in the panel will cause
the whole screen damage each second.
Once unityshell damages the whole screen the selection box disappears, if the mouse
is not moved, but the mousebutton is not released.
Without unityshell the selection box never disappears (I had unityshell disabled,
when I tested screenshot, so I didn't notice before...).

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

Note:
I tested this behaviour on 2 different machines, with different gfx-hardware (intel/amd) -> both act exactly the same way...

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

That sounds more like a case where the screenshot paint function is
disabled and not called when the screen next gets repainted.

On Wed, May 22, 2013 at 7:44 PM, MC Return <email address hidden> wrote:
>> "Otherwise the constant whole-screen damaging of Unity makes the
>> screenshot selection box disappear."
>>
>> Can you explain more why you think that's happening? I don't see why an
>> expanded damage region would cause some elements not to paint.
>
> No, not really - as I've not investigated the exact cause, but just analyzed
> the symptomps.
> I have indicator-multiload running here, which paints on top of the Unity panel
> each 30 millisecs, which makes unityshell damage the whole screen each 30ms
> (very efficient by the way ;) - see bug ##1182803).
> When I turn off indicator-multiload, unityshell will damage the whole screen
> each second, because the time display redraw (seconds) in the panel will cause
> the whole screen damage each second.
> Once unityshell damages the whole screen the selection box disappears, if the mouse
> is not moved, but the mousebutton is not released.
> Without unityshell the selection box never disappears (I had unityshell disabled,
> when I tested screenshot, so I didn't notice before...).
> --
> https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell/+merge/165066
> You are reviewing the proposed merge of lp:~mc-return/compiz/compiz.merge-fix1182794-screenshot-not-compatible-with-unityshell into lp:compiz.

--
Sam Spilsbury

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

> That sounds more like a case where the screenshot paint function is
> disabled and not called when the screen next gets repainted.
>
Maybe. If you say so -> probably. I have not checked the unity code yet.

Nevertheless, this MP here should be merged anyway, as the difference
in performance is just marginal:

1. Just the painted region (screenhot selection rectangle) gets repainted and redamaged, not the whole screen.
2. The additional damaging of this region is only happening for the time the user is holding the left-mousebutton, which in most cases will be under a half second more per screenshot.

It is the same way we handle the damaging of the zoom selection box by the way, but there it is implemented even slightly better (less damage calls)...
That could be improved here as well...

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

I think you've got the right idea now, on a quick look it would appear that the selectionSizeChanged stuff is probably what's causing all the problems (it doesn't make sense to say "we've painted this now, don't paint it again until it changes" because it ignores intermediate frames).

Just two notes:

1.

61 + cScreen->damageRegion (CompRegion (selectionRect));

This is unnecessary. You only need to add a new region to mark damaged if the selection rectangle has changed size (as we do in handleMotionEvent). For all other paint passes caused by other damage events, the redraw will effectively be clipped to the currently processed damage. That means that if the painted selection rectangle intersects the draw region then it will be repainted just fine. Then again, the other bits are effectively overdraw, which is bad for other reasons - but its better than causing spurious repaints to be triggered from within a paint function.

2.

The unrelated code cleanups made this difficult to review properly. Try and split them out if you can, or localize them to the area of the code that's being changed.

3727. By MC Return

Removed redundant damage call

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

> I think you've got the right idea now, on a quick look it would appear that
> the selectionSizeChanged stuff is probably what's causing all the problems (it
> doesn't make sense to say "we've painted this now, don't paint it again until
> it changes" because it ignores intermediate frames).
>
> Just two notes:
>
> 1.
>
> 61 + cScreen->damageRegion (CompRegion (selectionRect));
>
> This is unnecessary. You only need to add a new region to mark damaged if the
> selection rectangle has changed size (as we do in handleMotionEvent). For all
> other paint passes caused by other damage events, the redraw will effectively
> be clipped to the currently processed damage. That means that if the painted
> selection rectangle intersects the draw region then it will be repainted just
> fine. Then again, the other bits are effectively overdraw, which is bad for
> other reasons - but its better than causing spurious repaints to be triggered
> from within a paint function.
>

Oh - you are right.
I think we could even optimize it some more, but I'll leave it for now... ;)

Removed the redundant damage call.

> 2.
>
> The unrelated code cleanups made this difficult to review properly. Try and
> split them out if you can, or localize them to the area of the code that's
> being changed.

I will split out the fix from this MP.

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

Unmerged revisions

3727. By MC Return

Removed redundant damage call

3726. By MC Return

Fixed comment

3725. By MC Return

Fixed indentation

3724. By MC Return

Added newline

3723. By MC Return

Removed line committed by accident

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

Indentation fixes

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:00:49 +0000
4@@ -226,8 +226,8 @@
5 GLVertexBuffer *streamingBuffer,
6 const GLMatrix &transform)
7 {
8- GLfloat vertexData[12];
9- GLushort colorData[4];
10+ GLfloat vertexData[12];
11+ GLushort colorData[4];
12
13 int x1 = rect.x1 ();
14 int y1 = rect.y1 ();
15@@ -430,14 +430,11 @@
16 rect.height (), path);
17 }
18 else
19- {
20 compLogMessage ("screenshot", CompLogLevelWarn, "glReadPixels failed");
21- }
22
23 if (!success)
24- success =
25- launchApplicationAndTakeScreenshot (alternativeApplication,
26- directory);
27+ success = launchApplicationAndTakeScreenshot (alternativeApplication,
28+ directory);
29
30 return success;
31
32@@ -456,8 +453,7 @@
33 if (status && mGrab)
34 {
35 /* We just want to draw the screenshot selection box if
36- * we are grabbed, the size has changed and the CCSM
37- * option to draw it is enabled. */
38+ * we are grabbed and the CCSM option to draw it is enabled. */
39
40 CompRect selectionRect (std::min (mX1, mX2),
41 std::min (mY1, mY2),
42@@ -465,10 +461,9 @@
43 std::abs (mY2 - mY1));
44
45 if (mGrabIndex &&
46- selectionSizeChanged &&
47 optionGetDrawSelectionIndicator ())
48 {
49- GLMatrix transform (matrix);
50+ GLMatrix transform (matrix);
51 GLVertexBuffer *streamingBuffer (GLVertexBuffer::streamingBuffer ());
52 transform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
53
54@@ -481,10 +476,6 @@
55 optionGetSelectionOutlineColor (),
56 streamingBuffer,
57 transform);
58-
59- /* we finished painting the selection box,
60- * reset selectionSizeChanged now */
61- selectionSizeChanged = false;
62 }
63 else if (!mGrabIndex)
64 {
65@@ -508,9 +499,6 @@
66 if (mGrabIndex &&
67 (mX2 != xRoot || mY2 != yRoot))
68 {
69- /* the size has changed now */
70- selectionSizeChanged = true;
71-
72 int x1 = MIN (mX1, mX2) - 1;
73 int y1 = MIN (mY1, mY2) - 1;
74 int x2 = MAX (mX1, mX2) + 1;
75@@ -558,8 +546,7 @@
76 cScreen (CompositeScreen::get (screen)),
77 gScreen (GLScreen::get (screen)),
78 mGrabIndex (0),
79- mGrab (false),
80- selectionSizeChanged (false)
81+ mGrab (false)
82 {
83 optionSetInitiateButtonInitiate (boost::bind (&ShotScreen::initiate, this,
84 _1, _2, _3));
85
86=== modified file 'plugins/screenshot/src/screenshot.h'
87--- plugins/screenshot/src/screenshot.h 2013-04-24 11:38:36 +0000
88+++ plugins/screenshot/src/screenshot.h 2013-05-22 13:00:49 +0000
89@@ -46,29 +46,35 @@
90 bool initiate (CompAction *action,
91 CompAction::State state,
92 CompOption::Vector &options);
93+
94 bool terminate (CompAction *action,
95 CompAction::State state,
96 CompOption::Vector &options);
97+
98 void handleMotionEvent (int xRoot,
99 int yRoot);
100
101 void handleEvent (XEvent *event);
102+
103 bool glPaintOutput (const GLScreenPaintAttrib &attrib,
104 const GLMatrix &matrix,
105 const CompRegion &region,
106 CompOutput *output,
107 unsigned int mask);
108+
109 void paint (CompOutput::ptrList &outputs,
110 unsigned int mask);
111
112- CompositeScreen *cScreen;
113- GLScreen *gScreen;
114+ CompositeScreen *cScreen;
115+ GLScreen *gScreen;
116
117 CompScreen::GrabHandle mGrabIndex;
118 bool mGrab;
119- bool selectionSizeChanged;
120
121- int mX1, mY1, mX2, mY2;
122+ int mX1;
123+ int mY1;
124+ int mX2;
125+ int mY2;
126 };
127
128 class ShotPluginVTable :

Subscribers

People subscribed via source and target branches

to all changes: