Merge lp:~mc-return/compiz/compiz.merge-fix1162484-original-cube-top-and-bottom-caps-not-deformed into lp:compiz/0.9.10

Proposed by MC Return
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3648
Merged at revision: 3647
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1162484-original-cube-top-and-bottom-caps-not-deformed
Merge into: lp:compiz/0.9.10
Diff against target: 445 lines (+85/-98)
1 file modified
plugins/cubeaddon/src/cubeaddon.cpp (+85/-98)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1162484-original-cube-top-and-bottom-caps-not-deformed
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+157018@code.launchpad.net

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

Commit message

Cube-addon (Cube Reflection and Deformation):

If the user disables "Draw top face"/"Draw bottom face"
we do not want to draw anything (LP: #1162484).

The original, non-deformed caps will only work for the
non-deformed cube, so we can just use the original function
in that case.

We need to clear the texture if no texture files are
specified in "Image files", otherwise the old texture
would still be drawn, even if all image files are
removed (LP: #1162711).

Now we will default back and use the cube cap
colors and opacities defined in the "Desktop Cube" plugin
(if "Draw top/bottom face" are enabled only, see above).

This way the user can choose between (for top/bottom):

1. Do not draw a cube cap face at all
   ("Draw top/bottom face" option disabled)
2. Use color and opacity specified in "Desktop Cube"
   (empty images list)
3. Use a texture for the cap
   (image is in the list, which is default)

Removed redundant mCurrent = mCurrent % mFiles.size ();
calculation, this has already been done:
cap->mCurrent = (cap->mCurrent + change + count) % count;

count and change both need to be != 0 for mCurrent to change.

Fixed indentation, removed redundant brackets and newlines,
declaration and assignment of local variables in one line,
if possible, minor cleanup.

(LP: #1162484, LP: #1162711)

Description of the change

Note:

Bug #1162740: 'Key-combinations to change top or bottom cap textures do not work' (also regarding the caps) is still open, so the caps functionality is just almost perfect... :(
I am hunting this bug as well, but am currently a bit stuck with it (I added details to
the bug report already).

Bug #1163880: 'Deformation fails during time of window animation' is also still open

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

Please re-target this for lp:compiz/0.9.10

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

I'm a bit confused about this:

5 void
6 CubeaddonScreen::CubeCap::load (bool scale, bool aspect, bool clamp)
7 {
8 - if (mFiles.empty ())
9 - return;
10 -

It seems like the point is to remove the early return if no images are available. However cubeaddon only loads images (to the best of my understanding). I'm pretty sure there's a risk of a segfault or std::out_of_range exeception just a few lines underneath it:

    mCurrent = mCurrent % mFiles.size ();

    CompString imgName = mFiles[mCurrent].s ();
    CompString pname = "cubeaddon";
    mTexture = GLTexture::readImageToTexture (imgName, pname, tSize);

Was this change really needed?

34 - cScreen->damageScreen ();
35 - }

Was there a reason for this one? The function documentation says that we should be posting a full-screen damage at that point.

/*
 * Switch cap, load it and damage screen if possible
 */
bool
CubeaddonScreen::changeCap (bool top, int change)

I'd imagine that's because if this function happened on a timer and there was no other damage or motion, we'd want the cap change to reflected as an immediate repaint.

227 -
228 CubeaddonScreen::CubeaddonScreen (CompScreen *s) :
229 PluginClassHandler<CubeaddonScreen, CompScreen> (s),
230 CubeaddonOptions (),
231 @@ -1608,4 +1605,3 @@
232
233 return true;
234 }
235 -

This is just a change in whitespace. Its not really a big problem, see if you can avoid them though because too many can clutter up diffs.

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

Hi, and thanks for the review :)
A lot of surprising Compiz action happening...

> I'm a bit confused about this:
>
> 5 void
> 6 CubeaddonScreen::CubeCap::load (bool scale, bool aspect, bool clamp)
> 7 {
> 8 - if (mFiles.empty ())
> 9 - return;
> 10 -
>
> It seems like the point is to remove the early return if no images are
> available. However cubeaddon only loads images (to the best of my
> understanding). I'm pretty sure there's a risk of a segfault or
> std::out_of_range exeception just a few lines underneath it:
>
> mCurrent = mCurrent % mFiles.size ();
>
> CompString imgName = mFiles[mCurrent].s ();
> CompString pname = "cubeaddon";
> mTexture = GLTexture::readImageToTexture (imgName, pname, tSize);
>
> Was this change really needed?
>
Well, currently this cannot happen, because CubeaddonScreen::CubeCap::load
is just called by CubeaddonScreen::changeCap, where cap->mFiles.size ()
is already checked - no need to check it again, because this check already
happened a moment ago.

> 34 - cScreen->damageScreen ();
> 35 - }
>
> Was there a reason for this one? The function documentation says that we
> should be posting a full-screen damage at that point.
>
I was not sure about that one, but my logic tells me that we are already
rendering fullscreen (with fullscreen damage), when we show the cube -
but I can bring that back in.

> /*
> * Switch cap, load it and damage screen if possible
> */
> bool
> CubeaddonScreen::changeCap (bool top, int change)
>
> I'd imagine that's because if this function happened on a timer and there was
> no other damage or motion, we'd want the cap change to reflected as an
> immediate repaint.
>
Probably you are right, I'll bring it back in.
Unfortunately I could not test to see if any flickering occurs, because switching
top and bottom cap textures via keyboard shortcut is currently broken as well:
see bug #1162740

> 227 -
> 228 CubeaddonScreen::CubeaddonScreen (CompScreen *s) :
> 229 PluginClassHandler<CubeaddonScreen, CompScreen> (s),
> 230 CubeaddonOptions (),
> 231 @@ -1608,4 +1605,3 @@
> 232
> 233 return true;
> 234 }
> 235 -
>
> This is just a change in whitespace. Its not really a big problem, see if you
> can avoid them though because too many can clutter up diffs.

Unfortunately I found a lot of whitespaces, newlines and indentation problems
throughout the code...
IMHO we should fix those in the long run and beautify our code.
Existing code should also be an example how we want future code to be.
If indentation and style are a mess, code also is harder to read and bugs can
easier slip through undetected...

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal
Download full text (3.8 KiB)

On Tue, Apr 2, 2013 at 4:13 PM, MC Return <email address hidden> wrote:
> Hi, and thanks for the review :)
> A lot of surprising Compiz action happening...
>
>> I'm a bit confused about this:
>>
>> 5 void
>> 6 CubeaddonScreen::CubeCap::load (bool scale, bool aspect, bool clamp)
>> 7 {
>> 8 - if (mFiles.empty ())
>> 9 - return;
>> 10 -
>>
>> It seems like the point is to remove the early return if no images are
>> available. However cubeaddon only loads images (to the best of my
>> understanding). I'm pretty sure there's a risk of a segfault or
>> std::out_of_range exeception just a few lines underneath it:
>>
>> mCurrent = mCurrent % mFiles.size ();
>>
>> CompString imgName = mFiles[mCurrent].s ();
>> CompString pname = "cubeaddon";
>> mTexture = GLTexture::readImageToTexture (imgName, pname, tSize);
>>
>> Was this change really needed?
>>
> Well, currently this cannot happen, because CubeaddonScreen::CubeCap::load
> is just called by CubeaddonScreen::changeCap, where cap->mFiles.size ()
> is already checked - no need to check it again, because this check already
> happened a moment ago.

Okay. What I would suggest doing is dropping the former check instead
of the one inside CubeCap::load. That means that we don't need to have
one of CubeCap::load's preconditions be that cap->mFiles.size () is >
0. Instead, the check only happens once, and it happens inside of
CubeCap::load (which in fact, is a better design, because now the
caller doesn't need to care about how many files the cap has).

>
>> 34 - cScreen->damageScreen ();
>> 35 - }
>>
>> Was there a reason for this one? The function documentation says that we
>> should be posting a full-screen damage at that point.
>>
> I was not sure about that one, but my logic tells me that we are already
> rendering fullscreen (with fullscreen damage), when we show the cube -
> but I can bring that back in.
>
>> /*
>> * Switch cap, load it and damage screen if possible
>> */
>> bool
>> CubeaddonScreen::changeCap (bool top, int change)
>>
>> I'd imagine that's because if this function happened on a timer and there was
>> no other damage or motion, we'd want the cap change to reflected as an
>> immediate repaint.
>>
> Probably you are right, I'll bring it back in.
> Unfortunately I could not test to see if any flickering occurs, because switching
> top and bottom cap textures via keyboard shortcut is currently broken as well:
> see bug #1162740
>

Yes, we do render full-screen when the cube is active. However, we
don't post a fullscreen damage on every frame, we only post one if
something changes that requires us to update the scene. This would be
one of those things.

>> 227 -
>> 228 CubeaddonScreen::CubeaddonScreen (CompScreen *s) :
>> 229 PluginClassHandler<CubeaddonScreen, CompScreen> (s),
>> 230 CubeaddonOptions (),
>> 231 @@ -1608,4 +1605,3 @@
>> 232
>> 233 return true;
>> 234 }
>> 235 -
>>
>> This is just a change in whitespace. Its not really a big problem, see if you
>> can avoid them though because too many can clutter up diffs.
>
> Unfortunately I found a lot of whitespaces, newlines and indentation probl...

Read more...

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

> Okay. What I would suggest doing is dropping the former check instead
> of the one inside CubeCap::load. That means that we don't need to have
> one of CubeCap::load's preconditions be that cap->mFiles.size () is >
> 0. Instead, the check only happens once, and it happens inside of
> CubeCap::load (which in fact, is a better design, because now the
> caller doesn't need to care about how many files the cap has).
>
You're right. I'll look into that.

>
> Yes, we do render full-screen when the cube is active. However, we
> don't post a fullscreen damage on every frame, we only post one if
> something changes that requires us to update the scene. This would be
> one of those things.
>
I've corrected that now - sorry for the mistake.

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

>
> Okay. What I would suggest doing is dropping the former check instead
> of the one inside CubeCap::load. That means that we don't need to have
> one of CubeCap::load's preconditions be that cap->mFiles.size () is >
> 0. Instead, the check only happens once, and it happens inside of
> CubeCap::load (which in fact, is a better design, because now the
> caller doesn't need to care about how many files the cap has).
>
Done in r3647.

Also:
Removed redundant mCurrent = mCurrent % mFiles.size (); calculation,
this has already been done in CubeaddonScreen::changeCap.

cap->mCurrent = (cap->mCurrent + change + count) % count;
could imho also be reduced to:
cap->mCurrent = (cap->mCurrent + change) % count;
because modulo will never return negative values AFAIK, but I kept it
for now...
Also we just need to do this calculation if count and change both are != 0

Bug #1162740 is still open, I suspect the problem is hidden here:

#define BIND_ACTION(opt, t, d) \
    optionSet##opt##Initiate (boost::bind (&CubeaddonScreen::changeCap, this, t, d))

    BIND_ACTION (TopNextKey, true, 1);
    BIND_ACTION (TopPrevKey, true, -1);
    BIND_ACTION (BottomNextKey, false, 1);
    BIND_ACTION (BottomNextKey, false, -1);

    BIND_ACTION (TopNextButton, true, 1);
    BIND_ACTION (TopPrevButton, true, -1);
    BIND_ACTION (BottomNextButton, false, 1);
    BIND_ACTION (BottomNextButton, false, -1);

#undef BIND_ACTION

I could not get the plugin to send those values to changeCap :(
Do you have an idea what could be wrong with that, Sam ?

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

> >
> > Okay. What I would suggest doing is dropping the former check instead
> > of the one inside CubeCap::load. That means that we don't need to have
> > one of CubeCap::load's preconditions be that cap->mFiles.size () is >
> > 0. Instead, the check only happens once, and it happens inside of
> > CubeCap::load (which in fact, is a better design, because now the
> > caller doesn't need to care about how many files the cap has).
> >
> Done in r3647.
>

Thanks, +1
>
> Bug #1162740 is still open, I suspect the problem is hidden here:
>
> #define BIND_ACTION(opt, t, d) \
> optionSet##opt##Initiate (boost::bind (&CubeaddonScreen::changeCap, this,
> t, d))
>
> BIND_ACTION (TopNextKey, true, 1);
> BIND_ACTION (TopPrevKey, true, -1);
> BIND_ACTION (BottomNextKey, false, 1);
> BIND_ACTION (BottomNextKey, false, -1);
>
> BIND_ACTION (TopNextButton, true, 1);
> BIND_ACTION (TopPrevButton, true, -1);
> BIND_ACTION (BottomNextButton, false, 1);
> BIND_ACTION (BottomNextButton, false, -1);
>
> #undef BIND_ACTION
>
> I could not get the plugin to send those values to changeCap :(
> Do you have an idea what could be wrong with that, Sam ?

Is it that changeCap is never called or is it that the values for "top" and "change" in CubeaddonScreen::changeCap are never different for each keybinding.

If its the former, try binding the action to another keybinding, eg Control-Super-a. It might be that we don't allow actions to be bound on non-modified keybindings.

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

>
> Is it that changeCap is never called or is it that the values for "top" and
> "change" in CubeaddonScreen::changeCap are never different for each
> keybinding.
>
> If its the former, try binding the action to another keybinding, eg Control-
> Super-a. It might be that we don't allow actions to be bound on non-modified
> keybindings.

It is the former, but I tried all kinds of mouse and keyboard combos.
I can confirm that keys get recognized during the cube -> for example I can
start the rotating cube screensaver and then do all kinds of things like
moving windows from viewport to viewport, minimizing/maximizing windows,
revealing/hiding Guake or type into a console...

Just those cubeaddon ones are striking :(
I really suspect the code I posted above to be the culprit...

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

Unfortunately I found one other bug in cube-addon:
The deformation stops during the time windows are animated :(

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

On Tue, Apr 2, 2013 at 11:52 PM, MC Return <email address hidden> wrote:
>>
> It is the former, but I tried all kinds of mouse and keyboard combos.
> I can confirm that keys get recognized during the cube -> for example I can
> start the rotating cube screensaver and then do all kinds of things like
> moving windows from viewport to viewport, minimizing/maximizing windows,
> revealing/hiding Guake or type into a console...

Is it just during the screensaver where the keybindings don't work?

>
> Just those cubeaddon ones are striking :(
> I really suspect the code I posted above to be the culprit...
> --
> https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1162484-original-cube-top-and-bottom-caps-not-deformed/+merge/156469
> Your team Compiz Maintainers is subscribed to branch lp:compiz.

--
Sam Spilsbury

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

>
> Is it just during the screensaver where the keybindings don't work?
>
No. Do they work for you ?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

The Jenkins failures seem to be unrelated to this MP...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> >
> > Is it just during the screensaver where the keybindings don't work?
> >
> No. Do they work for you ?

I haven't tried. But I suspect that the screensaver plugin doesn't take a grab when it activates, which would mean that single-key-only bindings are unlikely to work the way you might expect them to.

I don't think there's a "bug" here if the keybindings work whilst manually rotating the cube

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

>
> I haven't tried. But I suspect that the screensaver plugin doesn't take a grab
> when it activates, which would mean that single-key-only bindings are unlikely
> to work the way you might expect them to.
>
> I don't think there's a "bug" here if the keybindings work whilst manually
> rotating the cube

Those keyboard/mouse shortcuts *never* work. I shouldn't have mentioned screensaver...

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

Ping ?

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

This is good as is. Try to avoid mixing whitespace change and variable initialization changes with substantive changes in future though, as it tends to confuse the diffs.

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/cubeaddon/src/cubeaddon.cpp'
2--- plugins/cubeaddon/src/cubeaddon.cpp 2013-02-25 19:34:51 +0000
3+++ plugins/cubeaddon/src/cubeaddon.cpp 2013-04-04 04:10:28 +0000
4@@ -44,8 +44,15 @@
5 void
6 CubeaddonScreen::CubeCap::load (bool scale, bool aspect, bool clamp)
7 {
8+ /* we need to clear the texture, if no texture files are specified */
9 if (mFiles.empty ())
10+ {
11+ mTexture.clear ();
12+ mLoaded = false;
13+ mCurrent = 0;
14+
15 return;
16+ }
17
18 CompSize tSize;
19 float xScale, yScale;
20@@ -56,9 +63,6 @@
21
22 mLoaded = false;
23
24- mCurrent = mCurrent % mFiles.size ();
25-
26-
27 CompString imgName = mFiles[mCurrent].s ();
28 CompString pname = "cubeaddon";
29 mTexture = GLTexture::readImageToTexture (imgName, pname, tSize);
30@@ -143,23 +147,25 @@
31 CubeaddonScreen::changeCap (bool top, int change)
32 {
33 CubeCap *cap = (top)? &mTopCap : &mBottomCap;
34- if (cap->mFiles.size ())
35- {
36- int count = cap->mFiles.size ();
37+
38+ int count = cap->mFiles.size ();
39+
40+ /* mCurrent just changes in this case */
41+ if (count && change)
42 cap->mCurrent = (cap->mCurrent + change + count) % count;
43- if (top)
44- {
45- cap->load (optionGetTopScale (), optionGetTopAspect (),
46- optionGetTopClamp ());
47- }
48- else
49- {
50- cap->load (optionGetBottomScale (), optionGetBottomAspect (),
51- optionGetBottomClamp ());
52- cap->mTexMat.scale (1.0, -1.0, 1.0);
53- }
54- cScreen->damageScreen ();
55- }
56+
57+ if (top)
58+ {
59+ cap->load (optionGetTopScale (), optionGetTopAspect (),
60+ optionGetTopClamp ());
61+ }
62+ else
63+ {
64+ cap->load (optionGetBottomScale (), optionGetBottomAspect (),
65+ optionGetBottomClamp ());
66+ cap->mTexMat.scale (1.0, -1.0, 1.0);
67+ }
68+ cScreen->damageScreen ();
69
70 return false;
71 }
72@@ -167,7 +173,6 @@
73 bool
74 CubeaddonScreen::setOption (const CompString &name, CompOption::Value &value)
75 {
76-
77 unsigned int index;
78
79 bool rv = CubeaddonOptions::setOption (name, value);
80@@ -206,11 +211,9 @@
81 void
82 CubeaddonScreen::drawBasicGround ()
83 {
84- float i;
85-
86 glEnable (GL_BLEND);
87 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
88- i = optionGetIntensity () * 2;
89+ float i = optionGetIntensity () * 2;
90
91 GLMatrix transform;
92 transform.translate (0.0f, 0.0f, -DEFAULT_Z_CAMERA);
93@@ -272,10 +275,8 @@
94 CompOutput *output,
95 std::vector<GLVector> &points)
96 {
97- bool status;
98-
99- status = cubeScreen->cubeCheckOrientation (sAttrib, transform,
100- output, points);
101+ bool status = cubeScreen->cubeCheckOrientation (sAttrib, transform,
102+ output, points);
103
104 if (mReflection)
105 return !status;
106@@ -311,14 +312,14 @@
107 glCullFace (GL_FRONT);
108 }
109
110-bool
111+bool
112 CubeaddonScreen::cubeShouldPaintViewport (const GLScreenPaintAttrib &sAttrib,
113 const GLMatrix &transform,
114 CompOutput *output,
115 PaintOrder order)
116 {
117 bool rv = cubeScreen->cubeShouldPaintViewport (sAttrib, transform,
118- output, order);
119+ output, order);
120
121 if (rv || cubeScreen->unfolded ())
122 return rv;
123@@ -326,15 +327,14 @@
124 if (mDeform > 0.0 && optionGetDeformation () == DeformationCylinder)
125 {
126 float z[3];
127- bool ftb1, ftb2, ftb3;
128
129 z[0] = cubeScreen->invert () * cubeScreen->distance ();
130 z[1] = z[0] + (0.25 / cubeScreen->distance ());
131- z[2] = cubeScreen->invert () *
132+ z[2] = cubeScreen->invert () *
133 sqrtf (0.25 + (cubeScreen->distance () * cubeScreen->distance ()));
134
135 std::vector<GLVector> vPoints[3];
136-
137+
138 vPoints[0].push_back (GLVector (-0.5, 0.0, z[0], 1.0));
139 vPoints[0].push_back (GLVector ( 0.0, 0.5, z[1], 1.0));
140 vPoints[0].push_back (GLVector ( 0.0, 0.0, z[1], 1.0));
141@@ -345,12 +345,12 @@
142 vPoints[2].push_back (GLVector ( 0.0, 0.5, z[2], 1.0));
143 vPoints[2].push_back (GLVector ( 0.0, 0.0, z[2], 1.0));
144
145- ftb1 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
146- output, vPoints[0]);
147- ftb2 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
148- output, vPoints[1]);
149- ftb3 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
150- output, vPoints[2]);
151+ bool ftb1 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
152+ output, vPoints[0]);
153+ bool ftb2 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
154+ output, vPoints[1]);
155+ bool ftb3 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
156+ output, vPoints[2]);
157
158 rv = (order == FTB && (ftb1 || ftb2 || ftb3)) ||
159 (order == BTF && (!ftb1 || !ftb2 || !ftb3));
160@@ -358,15 +358,14 @@
161 else if (mDeform > 0.0 && optionGetDeformation () == DeformationSphere)
162 {
163 float z[4];
164- bool ftb1, ftb2, ftb3, ftb4;
165
166 z[0] = sqrtf (0.5 + (cubeScreen->distance () * cubeScreen->distance ()));
167 z[1] = z[0] + (0.25 / cubeScreen->distance ());
168 z[2] = sqrtf (0.25 + (cubeScreen->distance () * cubeScreen->distance ()));
169 z[3] = z[2] + 0.5;
170-
171+
172 std::vector<GLVector> vPoints[4];
173-
174+
175 vPoints[0].push_back (GLVector ( 0.0, 0.0, z[3], 1.0));
176 vPoints[0].push_back (GLVector (-0.5, 0.5, z[2], 1.0));
177 vPoints[0].push_back (GLVector ( 0.0, 0.5, z[2], 1.0));
178@@ -380,14 +379,14 @@
179 vPoints[3].push_back (GLVector ( 0.5, 0.5, z[0], 1.0));
180 vPoints[3].push_back (GLVector ( 0.5, 0.0, z[0], 1.0));
181
182- ftb1 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
183- output, vPoints[0]);
184- ftb2 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
185- output, vPoints[1]);
186- ftb3 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
187- output, vPoints[2]);
188- ftb4 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
189- output, vPoints[3]);
190+ bool ftb1 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
191+ output, vPoints[0]);
192+ bool ftb2 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
193+ output, vPoints[1]);
194+ bool ftb3 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
195+ output, vPoints[2]);
196+ bool ftb4 = cubeScreen->cubeCheckOrientation (sAttrib, transform,
197+ output, vPoints[3]);
198
199 rv = (order == FTB && (ftb1 || ftb2 || ftb3 || ftb4)) ||
200 (order == BTF && (!ftb1 || !ftb2 || !ftb3 || !ftb4));
201@@ -406,7 +405,6 @@
202 {
203 GLScreenPaintAttrib sa;
204 GLMatrix sTransform;
205- int i, l, opacity;
206 int cullNorm, cullInv;
207 bool wasCulled = glIsEnabled (GL_CULL_FACE);
208 float cInv = (top) ? 1.0: -1.0;
209@@ -416,12 +414,13 @@
210
211 glGetIntegerv (GL_CULL_FACE_MODE, &cullNorm);
212 cullInv = (cullNorm == GL_BACK)? GL_FRONT : GL_BACK;
213+
214 if (top)
215 color = cubeScreen->topColor ();
216 else
217 color = cubeScreen->bottomColor ();
218
219- opacity = cubeScreen->desktopOpacity () * color[3] / 0xffff;
220+ int opacity = cubeScreen->desktopOpacity () * color[3] / 0xffff;
221
222 glEnable (GL_BLEND);
223
224@@ -438,11 +437,11 @@
225
226 glEnable(GL_CULL_FACE);
227
228- for (l = 0; l < ((cubeScreen->invert () == 1) ? 2 : 1); l++)
229+ for (int l = 0; l < ((cubeScreen->invert () == 1) ? 2 : 1); l++)
230 {
231 glCullFace(((l == 1) ^ top) ? cullInv : cullNorm);
232
233- for (i = 0; i < size; i++)
234+ for (int i = 0; i < size; i++)
235 {
236 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
237
238@@ -688,17 +687,18 @@
239 int size,
240 const GLVector &normal)
241 {
242- if ((!optionGetDrawBottom () && cubeScreen->invert () == -1) ||
243- (!optionGetDrawTop () && cubeScreen->invert () == 1))
244- {
245+ /* we do not want to draw anything if this option is disabled */
246+ if (!optionGetDrawTop ())
247+ return;
248+
249+ if (((!optionGetDrawBottom () && cubeScreen->invert () == -1) ||
250+ (!optionGetDrawTop () && cubeScreen->invert () == 1)) &&
251+ /* the original top cap will work for the non-deformed cube only */
252+ (optionGetDeformation () == DeformationNone))
253 cubeScreen->cubePaintTop (sAttrib, transform, output, size, normal);
254- }
255-
256- if (!optionGetDrawTop ())
257- return;
258-
259- paintCap (sAttrib, transform, output, size,
260- true, optionGetAdjustTop ());
261+ else
262+ paintCap (sAttrib, transform, output, size,
263+ true, optionGetAdjustTop ());
264 }
265
266 void
267@@ -708,16 +708,17 @@
268 int size,
269 const GLVector &normal)
270 {
271- if ((!optionGetDrawBottom () && cubeScreen->invert () == 1) ||
272- (!optionGetDrawTop () && cubeScreen->invert () == -1))
273- {
274+ /* we do not want to draw anything if this option is disabled */
275+ if (!optionGetDrawBottom ())
276+ return;
277+
278+ if (((!optionGetDrawBottom () && cubeScreen->invert () == 1) ||
279+ (!optionGetDrawTop () && cubeScreen->invert () == -1)) &&
280+ /* the original bottom cap will work for the non-deformed cube only */
281+ (optionGetDeformation () == DeformationNone))
282 cubeScreen->cubePaintBottom (sAttrib, transform, output, size, normal);
283- }
284-
285- if (!optionGetDrawBottom ())
286- return;
287-
288- paintCap (sAttrib, transform, output, size,
289+ else
290+ paintCap (sAttrib, transform, output, size,
291 false, optionGetAdjustBottom ());
292 }
293
294@@ -911,7 +912,6 @@
295 if (!(mask & PAINT_WINDOW_TRANSFORMED_MASK) && caScreen->mDeform)
296 {
297 CompPoint offset;
298- int x1, x2;
299
300 if (!window->onAllViewports ())
301 {
302@@ -919,8 +919,8 @@
303 offset = window->getMovementForOffset (offset);
304 }
305
306- x1 = window->x () - window->output ().left + offset.x ();
307- x2 = window->x () + window->width () + window->output ().right + offset.x ();
308+ int x1 = window->x () - window->output ().left + offset.x ();
309+ int x2 = window->x () + window->width () + window->output ().right + offset.x ();
310 if (x1 < 0 && x2 < 0)
311 return false;
312 if (x1 > screen->width () && x2 > screen->width ())
313@@ -941,16 +941,15 @@
314 int i;
315 int sx1, sx2, sw, sy1, sy2, sh;
316 int offX = 0, offY = 0;
317- float x, y, ym;
318+ float x, y;
319 GLfloat *v, *n;
320- float inv;
321
322 GLVertexBuffer *vb = gWindow->vertexBuffer ();
323 CubeScreen::MultioutputMode cMOM = cubeScreen->multioutputMode ();
324 float cDist = cubeScreen->distance ();
325
326- inv = (cubeScreen->invert () == 1) ? 1.0: -1.0;
327- ym = (caScreen->optionGetDeformation () == CubeaddonScreen::DeformationCylinder) ? 0.0 : 1.0;
328+ float inv = (cubeScreen->invert () == 1) ? 1.0: -1.0;
329+ float ym = (caScreen->optionGetDeformation () == CubeaddonScreen::DeformationCylinder) ? 0.0 : 1.0;
330
331 int vertexCount = vb->countVertices ();
332
333@@ -1159,7 +1158,6 @@
334 }
335 else
336 {
337- int i;
338 float w;
339 rS = cDist2 + 0.5;
340
341@@ -1170,7 +1168,7 @@
342 mCapFillNorm[1] = -1.0;
343 mCapFillNorm[2] = 0.0;
344
345- for (i = 0; i < CAP_ELEMENTS; i++)
346+ for (int i = 0; i < CAP_ELEMENTS; i++)
347 {
348 w = (float)(i + 1) / (float)CAP_ELEMENTS;
349
350@@ -1281,20 +1279,18 @@
351 mYTrans = 0.0;
352 if (optionGetDeformation () == DeformationSphere &&
353 optionGetDeformCaps () && optionGetDrawBottom ())
354- {
355 rYTrans = sqrt (0.5 + cDist2) * -2.0;
356- }
357 else
358- {
359 rYTrans = point[1] * 2.0;
360- }
361+
362 break;
363+
364 case ModeDistance:
365 mYTrans = 0.0;
366 rYTrans = sqrt (0.5 + cDist2) * -2.0;
367 break;
368+
369 default:
370-
371 if (optionGetDeformation () == DeformationSphere &&
372 optionGetDeformCaps () && optionGetDrawBottom ())
373 {
374@@ -1315,13 +1311,10 @@
375 break;
376 }
377
378-
379 if (!optionGetAutoZoom () ||
380 ((cubeScreen->rotationState () != CubeScreen::RotationManual) &&
381 optionGetZoomManualOnly ()))
382- {
383 mZTrans = 0.0;
384- }
385 else
386 mZTrans = -point2[2] + cDist;
387
388@@ -1377,8 +1370,6 @@
389
390 if (optionGetMode () == ModeAbove && mVRot > 0.0)
391 {
392- int j;
393- float i, c;
394 float v = MIN (1.0, mVRot / 30.0);
395 unsigned short col1[4], col2[4];
396
397@@ -1391,8 +1382,8 @@
398
399 gTransform.translate (0, 0, -DEFAULT_Z_CAMERA);
400
401- i = optionGetIntensity () * 2;
402- c = optionGetIntensity ();
403+ float i = optionGetIntensity () * 2;
404+ float c = optionGetIntensity ();
405
406 GLfloat vertices[] =
407 {
408@@ -1419,7 +1410,7 @@
409 if (streamingBuffer->end ())
410 streamingBuffer->render (gTransform);
411
412- for (j = 0; j < 4; j++)
413+ for (int j = 0; j < 4; j++)
414 {
415 col1[j] = (1.0 - v) * optionGetGroundColor1 () [j] +
416 (v * (optionGetGroundColor1 () [j] +
417@@ -1516,7 +1507,6 @@
418 cScreen->donePaint ();
419 }
420
421-
422 CubeaddonScreen::CubeaddonScreen (CompScreen *s) :
423 PluginClassHandler<CubeaddonScreen, CompScreen> (s),
424 CubeaddonOptions (),
425@@ -1538,7 +1528,6 @@
426
427 idx = mCapFillIdx;
428 for (int i = 0; i < CAP_ELEMENTS - 1; i++)
429- {
430 for (int j = 0; j < CAP_ELEMENTS; j++)
431 {
432 idx[0] = 1 + (i * (CAP_ELEMENTS + 1)) + j;
433@@ -1547,7 +1536,6 @@
434 idx[3] = 2 + (i * (CAP_ELEMENTS + 1)) + j;
435 idx += 4;
436 }
437- }
438
439 mTopCap.mFiles = optionGetTopImages ();
440 mBottomCap.mFiles = optionGetBottomImages ();
441@@ -1608,4 +1596,3 @@
442
443 return true;
444 }
445-

Subscribers

People subscribed via source and target branches

to all changes: