Merge lp:~mc-return/compiz/compiz.merge-plugin-trip into lp:compiz/0.9.8
- compiz.merge-plugin-trip
- Merge into 0.9.8
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Daniel van Vugt | ||||
Approved revision: | 3279 | ||||
Merged at revision: | 3281 | ||||
Proposed branch: | lp:~mc-return/compiz/compiz.merge-plugin-trip | ||||
Merge into: | lp:compiz/0.9.8 | ||||
Diff against target: |
905 lines (+879/-0) 5 files modified
plugins/trip/CMakeLists.txt (+5/-0) plugins/trip/VERSION (+1/-0) plugins/trip/src/trip.cpp (+578/-0) plugins/trip/src/trip.h (+192/-0) plugins/trip/trip.xml.in (+103/-0) |
||||
To merge this branch: | bzr merge lp:~mc-return/compiz/compiz.merge-plugin-trip | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Approve | ||
Didier Roche-Tolomelli | Pending | ||
Review via email: mp+113449@code.launchpad.net |
Commit message
Added the plug-in "Trip" converted from git to bzr (including full history) to Compiz.
Description of the change
Adds the plug-in "Trip" converted from git to bzr (including full history) to Compiz.
UNBLOCK
MC Return (mc-return) wrote : | # |
Daniel van Vugt (vanvugt) : | # |
Unity Merger (unity-merger) wrote : | # |
The Jenkins job https:/
Not merging it.
Daniel van Vugt (vanvugt) wrote : | # |
Needs downstream packaging to get Jenkins approval...
dh_install: usr/share/
dh_install: usr/lib/
dh_install: missing files, aborting
Didier Roche-Tolomelli (didrocks) wrote : | # |
@Daniel: package change done, BUT:
not sure why this has an unblock as gsettings/tests was supposively the only code entering to trunk before next snapshot.
Btw, I think now all plugins/new code entering the code will need tests. I won't accept anymore code without test to enter ubuntu.
Daniel van Vugt (vanvugt) wrote : | # |
Sorry; I had no idea if or why lp:compiz was frozen. So tried UNBLOCK on everything.
Yes, tests are important. But not for "unsupported" plugins like this one.
Didier Roche-Tolomelli (didrocks) wrote : | # |
@Daniel: it is important, it's in ubuntu, can be installed by people and affect the overall experience
Preview Diff
1 | === added directory 'plugins/trip' | |||
2 | === added file 'plugins/trip/CMakeLists.txt' | |||
3 | --- plugins/trip/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
4 | +++ plugins/trip/CMakeLists.txt 2012-07-04 19:03:18 +0000 | |||
5 | @@ -0,0 +1,5 @@ | |||
6 | 1 | find_package (Compiz REQUIRED) | ||
7 | 2 | |||
8 | 3 | include (CompizPlugin) | ||
9 | 4 | |||
10 | 5 | compiz_plugin (trip PLUGINDEPS composite opengl) | ||
11 | 0 | 6 | ||
12 | === added file 'plugins/trip/VERSION' | |||
13 | --- plugins/trip/VERSION 1970-01-01 00:00:00 +0000 | |||
14 | +++ plugins/trip/VERSION 2012-07-04 19:03:18 +0000 | |||
15 | @@ -0,0 +1,1 @@ | |||
16 | 1 | 0.9.5.0 | ||
17 | 0 | 2 | ||
18 | === added directory 'plugins/trip/src' | |||
19 | === added file 'plugins/trip/src/trip.cpp' | |||
20 | --- plugins/trip/src/trip.cpp 1970-01-01 00:00:00 +0000 | |||
21 | +++ plugins/trip/src/trip.cpp 2012-07-04 19:03:18 +0000 | |||
22 | @@ -0,0 +1,578 @@ | |||
23 | 1 | /* | ||
24 | 2 | * | ||
25 | 3 | * Compiz trip plugin | ||
26 | 4 | * | ||
27 | 5 | * trip.c | ||
28 | 6 | * | ||
29 | 7 | * Copyright : (C) 2010 by Scott Moreau | ||
30 | 8 | * E-mail : oreaus@gmail.com | ||
31 | 9 | * | ||
32 | 10 | * Based off the mag plugin by : | ||
33 | 11 | * Copyright : (C) 2008 by Dennis Kasprzyk | ||
34 | 12 | * E-mail : onestone@opencompositing.org | ||
35 | 13 | * | ||
36 | 14 | * | ||
37 | 15 | * This program is free software; you can redistribute it and/or | ||
38 | 16 | * modify it under the terms of the GNU General Public License | ||
39 | 17 | * as published by the Free Software Foundation; either version 2 | ||
40 | 18 | * of the License, or (at your option) any later version. | ||
41 | 19 | * | ||
42 | 20 | * This program is distributed in the hope that it will be useful, | ||
43 | 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
44 | 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
45 | 23 | * GNU General Public License for more details. | ||
46 | 24 | * | ||
47 | 25 | */ | ||
48 | 26 | |||
49 | 27 | #include "trip.h" | ||
50 | 28 | |||
51 | 29 | COMPIZ_PLUGIN_20090315 (trip, TripPluginVTable); | ||
52 | 30 | |||
53 | 31 | void | ||
54 | 32 | TripScreen::cleanup () | ||
55 | 33 | { | ||
56 | 34 | if (program) | ||
57 | 35 | { | ||
58 | 36 | GL::deletePrograms (1, &program); | ||
59 | 37 | program = 0; | ||
60 | 38 | } | ||
61 | 39 | } | ||
62 | 40 | |||
63 | 41 | bool | ||
64 | 42 | TripScreen::loadFragmentProgram () | ||
65 | 43 | { | ||
66 | 44 | char buffer[1024]; | ||
67 | 45 | GLsizei bufSize; | ||
68 | 46 | GLint errorPos; | ||
69 | 47 | |||
70 | 48 | if (!GL::fragmentProgram) | ||
71 | 49 | return false; | ||
72 | 50 | |||
73 | 51 | if (target == GL_TEXTURE_2D) | ||
74 | 52 | sprintf (buffer, rippleFpString, "2D"); | ||
75 | 53 | else | ||
76 | 54 | sprintf (buffer, rippleFpString, "RECT"); | ||
77 | 55 | |||
78 | 56 | /* clear errors */ | ||
79 | 57 | glGetError (); | ||
80 | 58 | |||
81 | 59 | if (!program) | ||
82 | 60 | GL::genPrograms (1, &program); | ||
83 | 61 | |||
84 | 62 | bufSize = (GLsizei) strlen (buffer); | ||
85 | 63 | |||
86 | 64 | GL::bindProgram (GL_FRAGMENT_PROGRAM_ARB, program); | ||
87 | 65 | GL::programString (GL_FRAGMENT_PROGRAM_ARB, | ||
88 | 66 | GL_PROGRAM_FORMAT_ASCII_ARB, | ||
89 | 67 | bufSize, buffer); | ||
90 | 68 | |||
91 | 69 | glGetIntegerv (GL_PROGRAM_ERROR_POSITION_ARB, &errorPos); | ||
92 | 70 | if (glGetError () != GL_NO_ERROR || errorPos != -1) | ||
93 | 71 | { | ||
94 | 72 | compLogMessage ("trip", CompLogLevelError, | ||
95 | 73 | "failed to load fragment program"); | ||
96 | 74 | |||
97 | 75 | GL::deletePrograms (1, &program); | ||
98 | 76 | program = 0; | ||
99 | 77 | |||
100 | 78 | return false; | ||
101 | 79 | } | ||
102 | 80 | GL::bindProgram (GL_FRAGMENT_PROGRAM_ARB, 0); | ||
103 | 81 | |||
104 | 82 | return true; | ||
105 | 83 | } | ||
106 | 84 | |||
107 | 85 | void | ||
108 | 86 | TripScreen::optionChanged (CompOption *opt, | ||
109 | 87 | Options num) | ||
110 | 88 | { | ||
111 | 89 | cleanup (); | ||
112 | 90 | loadFragmentProgram (); | ||
113 | 91 | |||
114 | 92 | quiet = true; | ||
115 | 93 | |||
116 | 94 | cScreen->damageScreen (); | ||
117 | 95 | } | ||
118 | 96 | |||
119 | 97 | int | ||
120 | 98 | TripScreen::adjustZoom (float chunk, Ripple &r) | ||
121 | 99 | { | ||
122 | 100 | float dx, adjust, amount; | ||
123 | 101 | float change; | ||
124 | 102 | |||
125 | 103 | dx = r.zTarget - r.zoom; | ||
126 | 104 | |||
127 | 105 | adjust = dx * 0.15f; | ||
128 | 106 | amount = fabs(dx) * 1.5f; | ||
129 | 107 | if (amount < 0.2f) | ||
130 | 108 | amount = 0.2f; | ||
131 | 109 | else if (amount > 2.0f) | ||
132 | 110 | amount = 2.0f; | ||
133 | 111 | |||
134 | 112 | r.zVelocity = (amount * r.zVelocity + adjust) / (amount + 1.0f); | ||
135 | 113 | |||
136 | 114 | if (fabs (dx) < 0.002f && fabs (r.zVelocity) < 0.004f) | ||
137 | 115 | { | ||
138 | 116 | r.zVelocity = 0.0f; | ||
139 | 117 | r.zoom = r.zTarget; | ||
140 | 118 | return false; | ||
141 | 119 | } | ||
142 | 120 | |||
143 | 121 | change = r.zVelocity * chunk; | ||
144 | 122 | if (!change) | ||
145 | 123 | { | ||
146 | 124 | if (r.zVelocity) | ||
147 | 125 | change = (dx > 0) ? 0.01 : -0.01; | ||
148 | 126 | } | ||
149 | 127 | |||
150 | 128 | r.zoom += change; | ||
151 | 129 | |||
152 | 130 | return true; | ||
153 | 131 | } | ||
154 | 132 | |||
155 | 133 | void | ||
156 | 134 | TripScreen::preparePaint (int time) | ||
157 | 135 | { | ||
158 | 136 | /* Be careful not to allow too much intensity. | ||
159 | 137 | * Otherwise, we might have a bad trip ;-) */ | ||
160 | 138 | if (intensity > 70) | ||
161 | 139 | intensity = 70; | ||
162 | 140 | |||
163 | 141 | for (unsigned int i = 0; i < ripples.size (); i++) | ||
164 | 142 | { | ||
165 | 143 | int steps; | ||
166 | 144 | float amount, chunk; | ||
167 | 145 | |||
168 | 146 | amount = time * 0.35f * optionGetSpeed (); | ||
169 | 147 | steps = amount / (0.5f * optionGetTimestep ()); | ||
170 | 148 | |||
171 | 149 | if (!steps) | ||
172 | 150 | steps = 1; | ||
173 | 151 | |||
174 | 152 | chunk = amount / (float) steps; | ||
175 | 153 | |||
176 | 154 | while (steps--) | ||
177 | 155 | { | ||
178 | 156 | ripples.at (i).adjust = adjustZoom (chunk, ripples.at (i)); | ||
179 | 157 | if (ripples.at (i).adjust) | ||
180 | 158 | break; | ||
181 | 159 | } | ||
182 | 160 | |||
183 | 161 | TRIP_SCREEN (screen); | ||
184 | 162 | |||
185 | 163 | /* Compute a 0.0 - 1.0 representation of the animation timeline */ | ||
186 | 164 | float progress = (float) (ripples.at (i).duration - | ||
187 | 165 | ripples.at (i).timer) / | ||
188 | 166 | (float) ripples.at (i).duration; | ||
189 | 167 | if (progress <= 0.5f) | ||
190 | 168 | { | ||
191 | 169 | ripples.at (i).timer -= (ts->quiet ? (time * 2) : (time / 4)); | ||
192 | 170 | ripples.at (i).zTarget = (MIN (10.0, (progress * 2) * 10.0)) + 1.0; | ||
193 | 171 | } | ||
194 | 172 | else | ||
195 | 173 | { ripples.at (i).timer -= (ts->quiet ? (time * 3) : (time / 5)); | ||
196 | 174 | ripples.at (i).zTarget = (MIN (10.0, (2.0 - (progress * 2)) * 10.0)) + 1.0; | ||
197 | 175 | } | ||
198 | 176 | |||
199 | 177 | if (ts->quiet) | ||
200 | 178 | { | ||
201 | 179 | intensity *= 0.8; | ||
202 | 180 | |||
203 | 181 | if (ripples.at (i).timer > 8000) | ||
204 | 182 | ripples.at (i).timer *= 0.8; | ||
205 | 183 | } | ||
206 | 184 | |||
207 | 185 | ripples.at (i).zTarget *= (intensity * 0.01); | ||
208 | 186 | ripples.at (i).radius += ripples.at (i).rMod; | ||
209 | 187 | } | ||
210 | 188 | cScreen->preparePaint (time); | ||
211 | 189 | cScreen->damageScreen (); | ||
212 | 190 | } | ||
213 | 191 | |||
214 | 192 | void | ||
215 | 193 | TripScreen::donePaint () | ||
216 | 194 | { | ||
217 | 195 | glEnable (target); | ||
218 | 196 | |||
219 | 197 | glBindTexture (target, texture); | ||
220 | 198 | |||
221 | 199 | glTexImage2D (target, 0, GL_RGB, 0, 0, 0, | ||
222 | 200 | GL_RGB, GL_UNSIGNED_BYTE, NULL); | ||
223 | 201 | |||
224 | 202 | glBindTexture (target, 0); | ||
225 | 203 | |||
226 | 204 | glDisable (target); | ||
227 | 205 | |||
228 | 206 | for (unsigned int i = 0; i < ripples.size (); i++) | ||
229 | 207 | { | ||
230 | 208 | ripples.at (i).width = 0; | ||
231 | 209 | ripples.at (i).height = 0; | ||
232 | 210 | |||
233 | 211 | if (ripples.at (i).zoom <= 1.0) | ||
234 | 212 | { | ||
235 | 213 | if (!quiet) | ||
236 | 214 | ripples.at (i). spawnRandom (); | ||
237 | 215 | else | ||
238 | 216 | ripples.erase (ripples.begin () + i); | ||
239 | 217 | } | ||
240 | 218 | } | ||
241 | 219 | |||
242 | 220 | if (ripples.empty ()) | ||
243 | 221 | { | ||
244 | 222 | ripples.clear (); | ||
245 | 223 | cScreen->preparePaintSetEnabled (this, false); | ||
246 | 224 | cScreen->donePaintSetEnabled (this, false); | ||
247 | 225 | gScreen->glPaintOutputSetEnabled (this, false); | ||
248 | 226 | } | ||
249 | 227 | |||
250 | 228 | cScreen->damageScreen (); | ||
251 | 229 | |||
252 | 230 | cScreen->donePaint (); | ||
253 | 231 | } | ||
254 | 232 | |||
255 | 233 | void | ||
256 | 234 | Ripple::paint () | ||
257 | 235 | { | ||
258 | 236 | |||
259 | 237 | TRIP_SCREEN (screen); | ||
260 | 238 | |||
261 | 239 | float pw, ph; | ||
262 | 240 | float fZoom, base; | ||
263 | 241 | int x1, x2, y1, y2; | ||
264 | 242 | float vc[4]; | ||
265 | 243 | int size; | ||
266 | 244 | |||
267 | 245 | width = height = 0; | ||
268 | 246 | |||
269 | 247 | base = 0.5 + (0.0015 * radius); | ||
270 | 248 | fZoom = (zoom * base) + 1.0 - base; | ||
271 | 249 | |||
272 | 250 | size = radius + 1; | ||
273 | 251 | |||
274 | 252 | x1 = MAX (0.0, coord.x () - size); | ||
275 | 253 | x2 = MIN (screen->width (), coord.x () + size); | ||
276 | 254 | y1 = MAX (0.0, coord.y () - size); | ||
277 | 255 | y2 = MIN (screen->height (), coord.y () + size); | ||
278 | 256 | |||
279 | 257 | glEnable (ts->target); | ||
280 | 258 | |||
281 | 259 | glBindTexture (ts->target, ts->texture); | ||
282 | 260 | |||
283 | 261 | if (width != 2 * size || height != 2 * size) | ||
284 | 262 | { | ||
285 | 263 | glCopyTexImage2D(ts->target, 0, GL_RGB, x1, screen->height () - y2, | ||
286 | 264 | size * 2, size * 2, 0); | ||
287 | 265 | width = height = 2 * size; | ||
288 | 266 | } | ||
289 | 267 | else | ||
290 | 268 | glCopyTexSubImage2D (ts->target, 0, 0, 0, | ||
291 | 269 | x1, screen->height () - y2, x2 - x1, y2 - y1); | ||
292 | 270 | |||
293 | 271 | if (ts->target == GL_TEXTURE_2D) | ||
294 | 272 | { | ||
295 | 273 | pw = 1.0 / width; | ||
296 | 274 | ph = 1.0 / height; | ||
297 | 275 | } | ||
298 | 276 | else | ||
299 | 277 | { | ||
300 | 278 | pw = 1.0; | ||
301 | 279 | ph = 1.0; | ||
302 | 280 | } | ||
303 | 281 | |||
304 | 282 | glMatrixMode (GL_PROJECTION); | ||
305 | 283 | glPushMatrix (); | ||
306 | 284 | glLoadIdentity (); | ||
307 | 285 | glMatrixMode (GL_MODELVIEW); | ||
308 | 286 | glPushMatrix (); | ||
309 | 287 | glLoadIdentity (); | ||
310 | 288 | |||
311 | 289 | glColor4usv (defaultColor); | ||
312 | 290 | |||
313 | 291 | glEnable (GL_FRAGMENT_PROGRAM_ARB); | ||
314 | 292 | GL::bindProgram (GL_FRAGMENT_PROGRAM_ARB, ts->program); | ||
315 | 293 | |||
316 | 294 | GL::programEnvParameter4f (GL_FRAGMENT_PROGRAM_ARB, 0, | ||
317 | 295 | coord.x (), screen->height () - coord.y (), | ||
318 | 296 | 1.0 / radius, 0.0f); | ||
319 | 297 | GL::programEnvParameter4f (GL_FRAGMENT_PROGRAM_ARB, 1, | ||
320 | 298 | pw, ph, M_PI / radius, | ||
321 | 299 | (fZoom - 1.0) * fZoom); | ||
322 | 300 | GL::programEnvParameter4f (GL_FRAGMENT_PROGRAM_ARB, 2, | ||
323 | 301 | -x1 * pw, -(screen->height () - y2) * ph, | ||
324 | 302 | -M_PI / 2.0, 0.0); | ||
325 | 303 | |||
326 | 304 | x1 = MAX (0.0, coord.x () - radius); | ||
327 | 305 | x2 = MIN (screen->width (), coord.x () + radius); | ||
328 | 306 | y1 = MAX (0.0, coord.y () - radius); | ||
329 | 307 | y2 = MIN (screen->height (), coord.y () + radius); | ||
330 | 308 | |||
331 | 309 | vc[0] = ((x1 * 2.0) / screen->width ()) - 1.0; | ||
332 | 310 | vc[1] = ((x2 * 2.0) / screen->width ()) - 1.0; | ||
333 | 311 | vc[2] = ((y1 * -2.0) / screen->height ()) + 1.0; | ||
334 | 312 | vc[3] = ((y2 * -2.0) / screen->height ()) + 1.0; | ||
335 | 313 | |||
336 | 314 | y1 = screen->height () - y1; | ||
337 | 315 | y2 = screen->height () - y2; | ||
338 | 316 | |||
339 | 317 | glBegin (GL_QUADS); | ||
340 | 318 | glTexCoord2f (x1, y1); | ||
341 | 319 | glVertex2f (vc[0], vc[2]); | ||
342 | 320 | glTexCoord2f (x1, y2); | ||
343 | 321 | glVertex2f (vc[0], vc[3]); | ||
344 | 322 | glTexCoord2f (x2, y2); | ||
345 | 323 | glVertex2f (vc[1], vc[3]); | ||
346 | 324 | glTexCoord2f (x2, y1); | ||
347 | 325 | glVertex2f (vc[1], vc[2]); | ||
348 | 326 | glEnd (); | ||
349 | 327 | |||
350 | 328 | glDisable (GL_FRAGMENT_PROGRAM_ARB); | ||
351 | 329 | |||
352 | 330 | glColor4usv (defaultColor); | ||
353 | 331 | |||
354 | 332 | glPopMatrix(); | ||
355 | 333 | glMatrixMode (GL_PROJECTION); | ||
356 | 334 | glPopMatrix (); | ||
357 | 335 | glMatrixMode (GL_MODELVIEW); | ||
358 | 336 | |||
359 | 337 | glBindTexture (ts->target, 0); | ||
360 | 338 | |||
361 | 339 | glDisable (ts->target); | ||
362 | 340 | } | ||
363 | 341 | |||
364 | 342 | |||
365 | 343 | bool | ||
366 | 344 | TripScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, | ||
367 | 345 | const GLMatrix &transform, | ||
368 | 346 | const CompRegion ®ion, | ||
369 | 347 | CompOutput *output, | ||
370 | 348 | unsigned int mask) | ||
371 | 349 | { | ||
372 | 350 | bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask); | ||
373 | 351 | |||
374 | 352 | if (ripples.empty ()) | ||
375 | 353 | return status; | ||
376 | 354 | |||
377 | 355 | /* Temporarily set the viewport to fullscreen */ | ||
378 | 356 | glViewport (0, 0, screen->width (), screen->height ()); | ||
379 | 357 | |||
380 | 358 | for (unsigned int i = 0; i < ripples.size (); i++) | ||
381 | 359 | ripples.at (i).paint (); | ||
382 | 360 | |||
383 | 361 | gScreen->setDefaultViewport (); | ||
384 | 362 | |||
385 | 363 | return status; | ||
386 | 364 | } | ||
387 | 365 | |||
388 | 366 | void | ||
389 | 367 | Ripple::spawnRandom () | ||
390 | 368 | { | ||
391 | 369 | TRIP_SCREEN (screen); | ||
392 | 370 | |||
393 | 371 | ts->cleanup (); | ||
394 | 372 | ts->loadFragmentProgram (); | ||
395 | 373 | |||
396 | 374 | radius = MAX (100, (rand () % ts->optionGetMaxRadius ())); | ||
397 | 375 | zoom = 1.0f; | ||
398 | 376 | |||
399 | 377 | rMod = (rand () % 3); | ||
400 | 378 | |||
401 | 379 | coord.setX (rand () % screen->width ()); | ||
402 | 380 | coord.setY (rand () % screen->height ()); | ||
403 | 381 | |||
404 | 382 | |||
405 | 383 | width = 0; | ||
406 | 384 | height = 0; | ||
407 | 385 | |||
408 | 386 | int x, y, w, h; | ||
409 | 387 | |||
410 | 388 | x = MAX (0.0, coord.x () - radius); | ||
411 | 389 | y = MAX (0.0, coord.y () - radius); | ||
412 | 390 | w = MIN (screen->width (), coord.x () + radius) - x; | ||
413 | 391 | h = MIN (screen->height (), coord.y () + radius) - y; | ||
414 | 392 | |||
415 | 393 | damageRect.setGeometry (x, y, w, h); | ||
416 | 394 | |||
417 | 395 | zTarget = MAX (1.0, MIN (10.0, (rand () % 10))); | ||
418 | 396 | |||
419 | 397 | duration = MAX(3000, (rand () % (ts->optionGetMaxDuration () * 1000))); | ||
420 | 398 | timer = duration; | ||
421 | 399 | adjust = true; | ||
422 | 400 | |||
423 | 401 | } | ||
424 | 402 | |||
425 | 403 | void | ||
426 | 404 | TripScreen::populateRippleSet () | ||
427 | 405 | { | ||
428 | 406 | |||
429 | 407 | ripples.clear (); | ||
430 | 408 | intensity = 30; | ||
431 | 409 | for (int i = 0; i < optionGetMaxRipples (); i++) | ||
432 | 410 | { | ||
433 | 411 | ripples.push_back (Ripple ()); | ||
434 | 412 | ripples.at (i). spawnRandom (); | ||
435 | 413 | } | ||
436 | 414 | } | ||
437 | 415 | |||
438 | 416 | bool | ||
439 | 417 | TripScreen::takeHit (CompAction *action, | ||
440 | 418 | CompAction::State state, | ||
441 | 419 | CompOption::Vector options) | ||
442 | 420 | { | ||
443 | 421 | intensity += 5; | ||
444 | 422 | |||
445 | 423 | if (quiet) | ||
446 | 424 | populateRippleSet (); | ||
447 | 425 | |||
448 | 426 | quiet = false; | ||
449 | 427 | |||
450 | 428 | /* Trip mode starting */ | ||
451 | 429 | cScreen->preparePaintSetEnabled (this, true); | ||
452 | 430 | cScreen->donePaintSetEnabled (this, true); | ||
453 | 431 | gScreen->glPaintOutputSetEnabled (this, true); | ||
454 | 432 | return true; | ||
455 | 433 | } | ||
456 | 434 | |||
457 | 435 | bool | ||
458 | 436 | TripScreen::untensify (CompAction *action, | ||
459 | 437 | CompAction::State state, | ||
460 | 438 | CompOption::Vector options) | ||
461 | 439 | { | ||
462 | 440 | intensity -= 5; | ||
463 | 441 | |||
464 | 442 | if (intensity < 15) | ||
465 | 443 | quiet = true; | ||
466 | 444 | |||
467 | 445 | return true; | ||
468 | 446 | } | ||
469 | 447 | |||
470 | 448 | bool | ||
471 | 449 | TripScreen::intensify (CompAction *action, | ||
472 | 450 | CompAction::State state, | ||
473 | 451 | CompOption::Vector options) | ||
474 | 452 | { | ||
475 | 453 | intensity += 2; | ||
476 | 454 | cScreen->damageScreen (); | ||
477 | 455 | |||
478 | 456 | if (quiet) | ||
479 | 457 | populateRippleSet (); | ||
480 | 458 | |||
481 | 459 | quiet = false; | ||
482 | 460 | |||
483 | 461 | /* Trip mode starting */ | ||
484 | 462 | cScreen->preparePaintSetEnabled (this, true); | ||
485 | 463 | cScreen->donePaintSetEnabled (this, true); | ||
486 | 464 | gScreen->glPaintOutputSetEnabled (this, true); | ||
487 | 465 | return true; | ||
488 | 466 | } | ||
489 | 467 | |||
490 | 468 | bool | ||
491 | 469 | TripScreen::soberUp (CompAction *action, | ||
492 | 470 | CompAction::State state, | ||
493 | 471 | CompOption::Vector options) | ||
494 | 472 | { | ||
495 | 473 | /* Time to end ripples quickly */ | ||
496 | 474 | quiet = true; | ||
497 | 475 | |||
498 | 476 | intensity -= 5; | ||
499 | 477 | |||
500 | 478 | cScreen->damageScreen (); | ||
501 | 479 | |||
502 | 480 | return true; | ||
503 | 481 | } | ||
504 | 482 | |||
505 | 483 | TripScreen::TripScreen (CompScreen *screen) : | ||
506 | 484 | PluginClassHandler <TripScreen, CompScreen> (screen), | ||
507 | 485 | cScreen (CompositeScreen::get (screen)), | ||
508 | 486 | gScreen (GLScreen::get (screen)), | ||
509 | 487 | program (0), | ||
510 | 488 | quiet (false), | ||
511 | 489 | intensity (25) | ||
512 | 490 | { | ||
513 | 491 | ScreenInterface::setHandler (screen, false); | ||
514 | 492 | CompositeScreenInterface::setHandler (cScreen, false); | ||
515 | 493 | GLScreenInterface::setHandler (gScreen, false); | ||
516 | 494 | |||
517 | 495 | |||
518 | 496 | glGenTextures (1, &texture); | ||
519 | 497 | |||
520 | 498 | if (GL::textureNonPowerOfTwo) | ||
521 | 499 | target = GL_TEXTURE_2D; | ||
522 | 500 | else | ||
523 | 501 | target = GL_TEXTURE_RECTANGLE_ARB; | ||
524 | 502 | |||
525 | 503 | glEnable (target); | ||
526 | 504 | |||
527 | 505 | /* Bind the texture */ | ||
528 | 506 | glBindTexture (target, texture); | ||
529 | 507 | |||
530 | 508 | /* Load the parameters */ | ||
531 | 509 | glTexParameteri (target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | ||
532 | 510 | glTexParameteri (target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | ||
533 | 511 | glTexParameteri (target, GL_TEXTURE_WRAP_S, GL_CLAMP); | ||
534 | 512 | glTexParameteri (target, GL_TEXTURE_WRAP_T, GL_CLAMP); | ||
535 | 513 | |||
536 | 514 | glTexImage2D (target, 0, GL_RGB, 0, 0, 0, | ||
537 | 515 | GL_RGB, GL_UNSIGNED_BYTE, NULL); | ||
538 | 516 | |||
539 | 517 | glBindTexture (target, 0); | ||
540 | 518 | |||
541 | 519 | glDisable (target); | ||
542 | 520 | |||
543 | 521 | optionSetMaxRadiusNotify (boost::bind (&TripScreen::optionChanged, this, _1, _2)); | ||
544 | 522 | optionSetMaxRipplesNotify (boost::bind (&TripScreen::optionChanged, this, _1, _2)); | ||
545 | 523 | optionSetMaxDurationNotify (boost::bind (&TripScreen::optionChanged, this, _1, _2)); | ||
546 | 524 | optionSetZoomFactorNotify (boost::bind (&TripScreen::optionChanged, this, _1, _2)); | ||
547 | 525 | optionSetSpeedNotify (boost::bind (&TripScreen::optionChanged, this, _1, _2)); | ||
548 | 526 | optionSetTimestepNotify (boost::bind (&TripScreen::optionChanged, this, _1, _2)); | ||
549 | 527 | |||
550 | 528 | optionSetTakeHitInitiate (boost::bind (&TripScreen::takeHit, this, _1, _2, | ||
551 | 529 | _3)); | ||
552 | 530 | |||
553 | 531 | optionSetDecreaseIntensityInitiate (boost::bind (&TripScreen::untensify, this, _1, _2, | ||
554 | 532 | _3)); | ||
555 | 533 | |||
556 | 534 | optionSetIncreaseIntensityInitiate (boost::bind (&TripScreen::intensify, this, _1, _2, | ||
557 | 535 | _3)); | ||
558 | 536 | |||
559 | 537 | optionSetSoberKeyInitiate (boost::bind (&TripScreen::soberUp, this, _1, _2, | ||
560 | 538 | _3)); | ||
561 | 539 | |||
562 | 540 | optionSetSoberButtonInitiate (boost::bind (&TripScreen::soberUp, this, _1, _2, | ||
563 | 541 | _3)); | ||
564 | 542 | |||
565 | 543 | populateRippleSet (); | ||
566 | 544 | |||
567 | 545 | if (!GL::fragmentProgram || !loadFragmentProgram ()) | ||
568 | 546 | compLogMessage ("trip", CompLogLevelWarn, | ||
569 | 547 | "GL_ARB_fragment_program not supported. " | ||
570 | 548 | "This plugin will not work."); | ||
571 | 549 | } | ||
572 | 550 | |||
573 | 551 | TripScreen::~TripScreen () | ||
574 | 552 | { | ||
575 | 553 | cScreen->damageScreen (); | ||
576 | 554 | |||
577 | 555 | glDeleteTextures (1, &target); | ||
578 | 556 | |||
579 | 557 | ripples.clear (); | ||
580 | 558 | } | ||
581 | 559 | |||
582 | 560 | Ripple::Ripple () : | ||
583 | 561 | dScreen (TripScreen::get (screen)) | ||
584 | 562 | { | ||
585 | 563 | } | ||
586 | 564 | |||
587 | 565 | Ripple::~Ripple () | ||
588 | 566 | { | ||
589 | 567 | } | ||
590 | 568 | |||
591 | 569 | bool | ||
592 | 570 | TripPluginVTable::init () | ||
593 | 571 | { | ||
594 | 572 | if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) || | ||
595 | 573 | !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) || | ||
596 | 574 | !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI)) | ||
597 | 575 | return false; | ||
598 | 576 | |||
599 | 577 | return true; | ||
600 | 578 | } | ||
601 | 0 | 579 | ||
602 | === added file 'plugins/trip/src/trip.h' | |||
603 | --- plugins/trip/src/trip.h 1970-01-01 00:00:00 +0000 | |||
604 | +++ plugins/trip/src/trip.h 2012-07-04 19:03:18 +0000 | |||
605 | @@ -0,0 +1,192 @@ | |||
606 | 1 | /* | ||
607 | 2 | * | ||
608 | 3 | * Compiz trip plugin | ||
609 | 4 | * | ||
610 | 5 | * trip.h | ||
611 | 6 | * | ||
612 | 7 | * Copyright : (C) 2010 by Scott Moreau | ||
613 | 8 | * E-mail : oreaus@gmail.com | ||
614 | 9 | * | ||
615 | 10 | * Based off the mag plugin by : | ||
616 | 11 | * Copyright : (C) 2008 by Dennis Kasprzyk | ||
617 | 12 | * E-mail : onestone@opencompositing.org | ||
618 | 13 | * | ||
619 | 14 | * | ||
620 | 15 | * This program is free software; you can redistribute it and/or | ||
621 | 16 | * modify it under the terms of the GNU General Public License | ||
622 | 17 | * as published by the Free Software Foundation; either version 2 | ||
623 | 18 | * of the License, or (at your option) any later version. | ||
624 | 19 | * | ||
625 | 20 | * This program is distributed in the hope that it will be useful, | ||
626 | 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
627 | 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
628 | 23 | * GNU General Public License for more details. | ||
629 | 24 | * | ||
630 | 25 | */ | ||
631 | 26 | |||
632 | 27 | #include <cmath> | ||
633 | 28 | |||
634 | 29 | #include <core/core.h> | ||
635 | 30 | #include <composite/composite.h> | ||
636 | 31 | #include <opengl/opengl.h> | ||
637 | 32 | |||
638 | 33 | #include "trip_options.h" | ||
639 | 34 | |||
640 | 35 | #define TRIP_SCREEN(s) \ | ||
641 | 36 | TripScreen *ts = TripScreen::get (s) | ||
642 | 37 | |||
643 | 38 | class Ripple; | ||
644 | 39 | |||
645 | 40 | class TripScreen : | ||
646 | 41 | public PluginClassHandler <TripScreen, CompScreen>, | ||
647 | 42 | public TripOptions, | ||
648 | 43 | public ScreenInterface, | ||
649 | 44 | public CompositeScreenInterface, | ||
650 | 45 | public GLScreenInterface | ||
651 | 46 | { | ||
652 | 47 | public: | ||
653 | 48 | TripScreen (CompScreen *screen); | ||
654 | 49 | ~TripScreen (); | ||
655 | 50 | |||
656 | 51 | CompositeScreen *cScreen; | ||
657 | 52 | GLScreen *gScreen; | ||
658 | 53 | |||
659 | 54 | std::vector <Ripple> ripples; | ||
660 | 55 | |||
661 | 56 | GLuint texture; | ||
662 | 57 | GLenum target; | ||
663 | 58 | |||
664 | 59 | GLuint program; | ||
665 | 60 | |||
666 | 61 | bool quiet; | ||
667 | 62 | |||
668 | 63 | unsigned int intensity; | ||
669 | 64 | |||
670 | 65 | bool | ||
671 | 66 | checkStateTimeout (); | ||
672 | 67 | |||
673 | 68 | void | ||
674 | 69 | preparePaint (int ms); | ||
675 | 70 | |||
676 | 71 | bool | ||
677 | 72 | glPaintOutput (const GLScreenPaintAttrib &attrib, | ||
678 | 73 | const GLMatrix &transform, | ||
679 | 74 | const CompRegion ®ion, | ||
680 | 75 | CompOutput *output, | ||
681 | 76 | unsigned int mask); | ||
682 | 77 | |||
683 | 78 | void | ||
684 | 79 | donePaint (); | ||
685 | 80 | |||
686 | 81 | void | ||
687 | 82 | cleanup (); | ||
688 | 83 | |||
689 | 84 | bool | ||
690 | 85 | loadFragmentProgram (); | ||
691 | 86 | |||
692 | 87 | void | ||
693 | 88 | optionChanged (CompOption *opt, | ||
694 | 89 | Options num); | ||
695 | 90 | |||
696 | 91 | void | ||
697 | 92 | positionUpdate (const CompPoint &pos); | ||
698 | 93 | |||
699 | 94 | int | ||
700 | 95 | adjustZoom (float chunk, Ripple &r); | ||
701 | 96 | |||
702 | 97 | bool | ||
703 | 98 | terminate (CompAction *action, | ||
704 | 99 | CompAction::State state, | ||
705 | 100 | CompOption::Vector options); | ||
706 | 101 | |||
707 | 102 | bool | ||
708 | 103 | takeHit (CompAction *action, | ||
709 | 104 | CompAction::State state, | ||
710 | 105 | CompOption::Vector options); | ||
711 | 106 | |||
712 | 107 | bool | ||
713 | 108 | untensify (CompAction *action, | ||
714 | 109 | CompAction::State state, | ||
715 | 110 | CompOption::Vector options); | ||
716 | 111 | |||
717 | 112 | bool | ||
718 | 113 | intensify (CompAction *action, | ||
719 | 114 | CompAction::State state, | ||
720 | 115 | CompOption::Vector options); | ||
721 | 116 | |||
722 | 117 | bool | ||
723 | 118 | soberUp (CompAction *action, | ||
724 | 119 | CompAction::State state, | ||
725 | 120 | CompOption::Vector options); | ||
726 | 121 | |||
727 | 122 | void populateRippleSet (); | ||
728 | 123 | |||
729 | 124 | }; | ||
730 | 125 | |||
731 | 126 | class Ripple | ||
732 | 127 | { | ||
733 | 128 | public: | ||
734 | 129 | Ripple (); | ||
735 | 130 | ~Ripple (); | ||
736 | 131 | |||
737 | 132 | TripScreen *dScreen; | ||
738 | 133 | |||
739 | 134 | int radius; | ||
740 | 135 | int rMod; | ||
741 | 136 | |||
742 | 137 | CompPoint coord; | ||
743 | 138 | |||
744 | 139 | int duration; | ||
745 | 140 | int timer; | ||
746 | 141 | |||
747 | 142 | int width; | ||
748 | 143 | int height; | ||
749 | 144 | |||
750 | 145 | GLfloat zVelocity; | ||
751 | 146 | GLfloat zTarget; | ||
752 | 147 | GLfloat zoom; | ||
753 | 148 | |||
754 | 149 | bool adjust; | ||
755 | 150 | |||
756 | 151 | CompRect damageRect; | ||
757 | 152 | |||
758 | 153 | void paint (); | ||
759 | 154 | void spawnRandom (); | ||
760 | 155 | }; | ||
761 | 156 | |||
762 | 157 | class TripPluginVTable : | ||
763 | 158 | public CompPlugin::VTableForScreen <TripScreen> | ||
764 | 159 | { | ||
765 | 160 | public: | ||
766 | 161 | bool init (); | ||
767 | 162 | }; | ||
768 | 163 | |||
769 | 164 | static const char *rippleFpString = | ||
770 | 165 | "!!ARBfp1.0" | ||
771 | 166 | |||
772 | 167 | "PARAM p0 = program.env[0];" | ||
773 | 168 | "PARAM p1 = program.env[1];" | ||
774 | 169 | "PARAM p2 = program.env[2];" | ||
775 | 170 | |||
776 | 171 | "TEMP t0, t1, t2, t3;" | ||
777 | 172 | |||
778 | 173 | "SUB t1, p0.xyww, fragment.texcoord[0];" | ||
779 | 174 | "DP3 t2, t1, t1;" | ||
780 | 175 | "RSQ t2, t2.x;" | ||
781 | 176 | "SUB t0, t2, p0;" | ||
782 | 177 | |||
783 | 178 | "RCP t3, t2.x;" | ||
784 | 179 | "MAD t3, t3, p1.z, p2.z;" | ||
785 | 180 | "COS t3, t3.x;" | ||
786 | 181 | |||
787 | 182 | "MUL t3, t3, p1.w;" | ||
788 | 183 | |||
789 | 184 | "MUL t1, t2, t1;" | ||
790 | 185 | "MAD t1, t1, t3, fragment.texcoord[0];" | ||
791 | 186 | |||
792 | 187 | "CMP t1, t0.z, fragment.texcoord[0], t1;" | ||
793 | 188 | |||
794 | 189 | "MAD t1, t1, p1, p2;" | ||
795 | 190 | "TEX result.color, t1, texture[0], %s;" | ||
796 | 191 | |||
797 | 192 | "END"; | ||
798 | 0 | 193 | ||
799 | === added file 'plugins/trip/trip.xml.in' | |||
800 | --- plugins/trip/trip.xml.in 1970-01-01 00:00:00 +0000 | |||
801 | +++ plugins/trip/trip.xml.in 2012-07-04 19:03:18 +0000 | |||
802 | @@ -0,0 +1,103 @@ | |||
803 | 1 | <?xml version="1.0"?> | ||
804 | 2 | <compiz> | ||
805 | 3 | <plugin name="trip" useBcop="true"> | ||
806 | 4 | <_short>Trip</_short> | ||
807 | 5 | <_long>Trips out desktops</_long> | ||
808 | 6 | <category>Effects</category> | ||
809 | 7 | <deps> | ||
810 | 8 | <relation type="after"> | ||
811 | 9 | <plugin>composite</plugin> | ||
812 | 10 | <plugin>opengl</plugin> | ||
813 | 11 | <plugin>cube</plugin> | ||
814 | 12 | <plugin>decor</plugin> | ||
815 | 13 | </relation> | ||
816 | 14 | <requirement> | ||
817 | 15 | <plugin>opengl</plugin> | ||
818 | 16 | </requirement> | ||
819 | 17 | </deps> | ||
820 | 18 | <options> | ||
821 | 19 | <group> | ||
822 | 20 | <_short>Bindings</_short> | ||
823 | 21 | <option name="take_hit" type="key"> | ||
824 | 22 | <_short>Take Hit</_short> | ||
825 | 23 | <_long>Take another hit</_long> | ||
826 | 24 | <default><Super><Alt>h</default> | ||
827 | 25 | </option> | ||
828 | 26 | <option name="decrease_intensity" type="key"> | ||
829 | 27 | <_short>Decrease intensity</_short> | ||
830 | 28 | <_long>Come down some</_long> | ||
831 | 29 | <default><Super><Alt>d</default> | ||
832 | 30 | </option> | ||
833 | 31 | <option name="increase_intensity" type="button"> | ||
834 | 32 | <_short>Increase effect</_short> | ||
835 | 33 | <_long>Increase intensity of effect</_long> | ||
836 | 34 | <default><Super><Alt>Button4</default> | ||
837 | 35 | </option> | ||
838 | 36 | <option name="sober_key" type="key"> | ||
839 | 37 | <_short>Stop effect</_short> | ||
840 | 38 | <_long>Stops tripping</_long> | ||
841 | 39 | <default><Super><Alt>s</default> | ||
842 | 40 | </option> | ||
843 | 41 | <option name="sober_button" type="button"> | ||
844 | 42 | <_short>Stop effect</_short> | ||
845 | 43 | <_long>Stops tripping</_long> | ||
846 | 44 | <default><Super><Alt>Button5</default> | ||
847 | 45 | </option> | ||
848 | 46 | </group> | ||
849 | 47 | <group> | ||
850 | 48 | <_short>General</_short> | ||
851 | 49 | <subgroup> | ||
852 | 50 | <_short>Effect Settings</_short> | ||
853 | 51 | <option name="max_radius" type="int"> | ||
854 | 52 | <_short>Radius</_short> | ||
855 | 53 | <_long>Radius of the magnification area.</_long> | ||
856 | 54 | <default>225</default> | ||
857 | 55 | <min>100</min> | ||
858 | 56 | <max>1000</max> | ||
859 | 57 | </option> | ||
860 | 58 | <option name="max_ripples" type="int"> | ||
861 | 59 | <_short>Ripples</_short> | ||
862 | 60 | <_long>Maximum number of ripples on screen at any given time.</_long> | ||
863 | 61 | <default>40</default> | ||
864 | 62 | <min>1</min> | ||
865 | 63 | <max>100</max> | ||
866 | 64 | </option> | ||
867 | 65 | <option name="max_duration" type="int"> | ||
868 | 66 | <_short>Duration</_short> | ||
869 | 67 | <_long>Maximum length of time in seconds for a given ripple.</_long> | ||
870 | 68 | <default>8</default> | ||
871 | 69 | <min>3</min> | ||
872 | 70 | <max>30</max> | ||
873 | 71 | </option> | ||
874 | 72 | </subgroup> | ||
875 | 73 | <subgroup> | ||
876 | 74 | <_short>Internal Settings</_short> | ||
877 | 75 | <option name="zoom_factor" type="float"> | ||
878 | 76 | <_short>Zoom</_short> | ||
879 | 77 | <_long>Zoom factor for keyboard initiated magnifier.</_long> | ||
880 | 78 | <default>2.0</default> | ||
881 | 79 | <min>1.1</min> | ||
882 | 80 | <max>32.0</max> | ||
883 | 81 | <precision>0.1</precision> | ||
884 | 82 | </option> | ||
885 | 83 | <option name="speed" type="float"> | ||
886 | 84 | <_short>Speed</_short> | ||
887 | 85 | <_long>Zoom Speed</_long> | ||
888 | 86 | <default>1.5</default> | ||
889 | 87 | <min>0.1</min> | ||
890 | 88 | <max>50</max> | ||
891 | 89 | <precision>0.1</precision> | ||
892 | 90 | </option> | ||
893 | 91 | <option name="timestep" type="float"> | ||
894 | 92 | <_short>Timestep</_short> | ||
895 | 93 | <_long>Zoom Timestep</_long> | ||
896 | 94 | <default>1.2</default> | ||
897 | 95 | <min>0.1</min> | ||
898 | 96 | <max>50</max> | ||
899 | 97 | <precision>0.1</precision> | ||
900 | 98 | </option> | ||
901 | 99 | </subgroup> | ||
902 | 100 | </group> | ||
903 | 101 | </options> | ||
904 | 102 | </plugin> | ||
905 | 103 | </compiz> |
This one *should* work, at least it does here (Ubuntu 12.10, latest Compiz 0.9.8).
It is quite useless, just like the water plug-in, but still is very nice to show off Compiz, just like the water plug-in :)
Seems something went wrong with my commit message (r3279), sorry about that.