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

Proposed by MC Return
Status: Superseded
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1162484-original-cube-top-and-bottom-caps-not-deformed
Merge into: lp:compiz/0.9.9
Diff against target: 235 lines (+44/-48)
1 file modified
plugins/cubeaddon/src/cubeaddon.cpp (+44/-48)
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
Daniel van Vugt Needs Resubmitting
Review via email: mp+156306@code.launchpad.net

This proposal has been superseded by 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.

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".
In this case 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).

void CubeaddonScreen::CubeCap::load is just called by
CubeaddonScreen::changeCap, where cap->mFiles.size ()
is already checked, no need to check it again.

Removed redundant call to cScreen->damageScreen ().
If we draw the cube we are already damaging the screen, no
need to damage it again if we change the cap.

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 (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).

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

Please re-target this for lp:compiz/0.9.10

review: Needs Resubmitting
3646. By MC Return

cScreen->damageScreen (); once the cap has been changed
(reverted removal)

3647. By MC Return

Moved the mFiles.size () check to CubeaddonScreen::CubeCap::load (...)

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

3648. By MC Return

Additional cleanup

Unmerged revisions

3648. By MC Return

Additional cleanup

3647. By MC Return

Moved the mFiles.size () check to CubeaddonScreen::CubeCap::load (...)

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

3646. By MC Return

cScreen->damageScreen (); once the cap has been changed
(reverted removal)

3645. By MC Return

If the user disables "Draw top face"/"Draw bottom face"
we do not want to draw anything

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

We need to clear the texture if no texture files are
specified

void CubeaddonScreen::CubeCap::load is just called by
CubeaddonScreen::changeCap, where cap->mFiles.size ()
is already checked, no need to check it again

Fixed indentation

Removed redundant brackets and newlines

3644. By MC Return

Cube-addon:
Only call cubeScreen->cubePaintBottom if there is no deformation
Declare and assign variables in one line, if possible
Minor cleanup

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-01 11:03:21 +0000
4@@ -44,9 +44,6 @@
5 void
6 CubeaddonScreen::CubeCap::load (bool scale, bool aspect, bool clamp)
7 {
8- if (mFiles.empty ())
9- return;
10-
11 CompSize tSize;
12 float xScale, yScale;
13
14@@ -58,7 +55,6 @@
15
16 mCurrent = mCurrent % mFiles.size ();
17
18-
19 CompString imgName = mFiles[mCurrent].s ();
20 CompString pname = "cubeaddon";
21 mTexture = GLTexture::readImageToTexture (imgName, pname, tSize);
22@@ -147,6 +143,7 @@
23 {
24 int count = cap->mFiles.size ();
25 cap->mCurrent = (cap->mCurrent + change + count) % count;
26+
27 if (top)
28 {
29 cap->load (optionGetTopScale (), optionGetTopAspect (),
30@@ -158,16 +155,21 @@
31 optionGetBottomClamp ());
32 cap->mTexMat.scale (1.0, -1.0, 1.0);
33 }
34- cScreen->damageScreen ();
35- }
36-
37+ }
38+ /* we need to clear the texture if no texture files are specified */
39+ else if (cap->mFiles.empty ())
40+ {
41+ cap->mTexture.clear ();
42+ cap->mLoaded = false;
43+ cap->mCurrent = 0;
44+ cap->mTexMat.reset ();
45+ }
46 return false;
47 }
48
49 bool
50 CubeaddonScreen::setOption (const CompString &name, CompOption::Value &value)
51 {
52-
53 unsigned int index;
54
55 bool rv = CubeaddonOptions::setOption (name, value);
56@@ -206,11 +208,9 @@
57 void
58 CubeaddonScreen::drawBasicGround ()
59 {
60- float i;
61-
62 glEnable (GL_BLEND);
63 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
64- i = optionGetIntensity () * 2;
65+ float i = optionGetIntensity () * 2;
66
67 GLMatrix transform;
68 transform.translate (0.0f, 0.0f, -DEFAULT_Z_CAMERA);
69@@ -272,10 +272,8 @@
70 CompOutput *output,
71 std::vector<GLVector> &points)
72 {
73- bool status;
74-
75- status = cubeScreen->cubeCheckOrientation (sAttrib, transform,
76- output, points);
77+ bool status = cubeScreen->cubeCheckOrientation (sAttrib, transform,
78+ output, points);
79
80 if (mReflection)
81 return !status;
82@@ -318,7 +316,7 @@
83 PaintOrder order)
84 {
85 bool rv = cubeScreen->cubeShouldPaintViewport (sAttrib, transform,
86- output, order);
87+ output, order);
88
89 if (rv || cubeScreen->unfolded ())
90 return rv;
91@@ -406,7 +404,6 @@
92 {
93 GLScreenPaintAttrib sa;
94 GLMatrix sTransform;
95- int i, l, opacity;
96 int cullNorm, cullInv;
97 bool wasCulled = glIsEnabled (GL_CULL_FACE);
98 float cInv = (top) ? 1.0: -1.0;
99@@ -416,12 +413,13 @@
100
101 glGetIntegerv (GL_CULL_FACE_MODE, &cullNorm);
102 cullInv = (cullNorm == GL_BACK)? GL_FRONT : GL_BACK;
103+
104 if (top)
105 color = cubeScreen->topColor ();
106 else
107 color = cubeScreen->bottomColor ();
108
109- opacity = cubeScreen->desktopOpacity () * color[3] / 0xffff;
110+ int opacity = cubeScreen->desktopOpacity () * color[3] / 0xffff;
111
112 glEnable (GL_BLEND);
113
114@@ -438,11 +436,11 @@
115
116 glEnable(GL_CULL_FACE);
117
118- for (l = 0; l < ((cubeScreen->invert () == 1) ? 2 : 1); l++)
119+ for (int l = 0; l < ((cubeScreen->invert () == 1) ? 2 : 1); l++)
120 {
121 glCullFace(((l == 1) ^ top) ? cullInv : cullNorm);
122
123- for (i = 0; i < size; i++)
124+ for (int i = 0; i < size; i++)
125 {
126 GLVertexBuffer *streamingBuffer = GLVertexBuffer::streamingBuffer ();
127
128@@ -688,17 +686,18 @@
129 int size,
130 const GLVector &normal)
131 {
132- if ((!optionGetDrawBottom () && cubeScreen->invert () == -1) ||
133- (!optionGetDrawTop () && cubeScreen->invert () == 1))
134- {
135+ /* we do not want to draw anything if this option is disabled */
136+ if (!optionGetDrawTop ())
137+ return;
138+
139+ if (((!optionGetDrawBottom () && cubeScreen->invert () == -1) ||
140+ (!optionGetDrawTop () && cubeScreen->invert () == 1)) &&
141+ /* the original top cap will work for the non-deformed cube only */
142+ (optionGetDeformation () == DeformationNone))
143 cubeScreen->cubePaintTop (sAttrib, transform, output, size, normal);
144- }
145-
146- if (!optionGetDrawTop ())
147- return;
148-
149- paintCap (sAttrib, transform, output, size,
150- true, optionGetAdjustTop ());
151+ else
152+ paintCap (sAttrib, transform, output, size,
153+ true, optionGetAdjustTop ());
154 }
155
156 void
157@@ -708,16 +707,17 @@
158 int size,
159 const GLVector &normal)
160 {
161- if ((!optionGetDrawBottom () && cubeScreen->invert () == 1) ||
162- (!optionGetDrawTop () && cubeScreen->invert () == -1))
163- {
164+ /* we do not want to draw anything if this option is disabled */
165+ if (!optionGetDrawBottom ())
166+ return;
167+
168+ if (((!optionGetDrawBottom () && cubeScreen->invert () == 1) ||
169+ (!optionGetDrawTop () && cubeScreen->invert () == -1)) &&
170+ /* the original bottom cap will work for the non-deformed cube only */
171+ (optionGetDeformation () == DeformationNone))
172 cubeScreen->cubePaintBottom (sAttrib, transform, output, size, normal);
173- }
174-
175- if (!optionGetDrawBottom ())
176- return;
177-
178- paintCap (sAttrib, transform, output, size,
179+ else
180+ paintCap (sAttrib, transform, output, size,
181 false, optionGetAdjustBottom ());
182 }
183
184@@ -911,7 +911,6 @@
185 if (!(mask & PAINT_WINDOW_TRANSFORMED_MASK) && caScreen->mDeform)
186 {
187 CompPoint offset;
188- int x1, x2;
189
190 if (!window->onAllViewports ())
191 {
192@@ -919,8 +918,8 @@
193 offset = window->getMovementForOffset (offset);
194 }
195
196- x1 = window->x () - window->output ().left + offset.x ();
197- x2 = window->x () + window->width () + window->output ().right + offset.x ();
198+ int x1 = window->x () - window->output ().left + offset.x ();
199+ int x2 = window->x () + window->width () + window->output ().right + offset.x ();
200 if (x1 < 0 && x2 < 0)
201 return false;
202 if (x1 > screen->width () && x2 > screen->width ())
203@@ -941,16 +940,15 @@
204 int i;
205 int sx1, sx2, sw, sy1, sy2, sh;
206 int offX = 0, offY = 0;
207- float x, y, ym;
208+ float x, y;
209 GLfloat *v, *n;
210- float inv;
211
212 GLVertexBuffer *vb = gWindow->vertexBuffer ();
213 CubeScreen::MultioutputMode cMOM = cubeScreen->multioutputMode ();
214 float cDist = cubeScreen->distance ();
215
216- inv = (cubeScreen->invert () == 1) ? 1.0: -1.0;
217- ym = (caScreen->optionGetDeformation () == CubeaddonScreen::DeformationCylinder) ? 0.0 : 1.0;
218+ float inv = (cubeScreen->invert () == 1) ? 1.0: -1.0;
219+ float ym = (caScreen->optionGetDeformation () == CubeaddonScreen::DeformationCylinder) ? 0.0 : 1.0;
220
221 int vertexCount = vb->countVertices ();
222
223@@ -1516,7 +1514,6 @@
224 cScreen->donePaint ();
225 }
226
227-
228 CubeaddonScreen::CubeaddonScreen (CompScreen *s) :
229 PluginClassHandler<CubeaddonScreen, CompScreen> (s),
230 CubeaddonOptions (),
231@@ -1608,4 +1605,3 @@
232
233 return true;
234 }
235-

Subscribers

People subscribed via source and target branches