Merge lp:~mc-return/compiz/compiz.merge-plugin-trip into lp:compiz/0.9.8

Proposed by MC Return
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
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

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

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.

Revision history for this message
Daniel van Vugt (vanvugt) :
review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-compiz-core/17/console reported an error when processing this lp:~mc-return/compiz/compiz.merge-plugin-trip branch.
Not merging it.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Needs downstream packaging to get Jenkins approval...

dh_install: usr/share/compiz/trip.xml exists in debian/tmp but is not installed to anywhere
dh_install: usr/lib/compiz/libtrip.so exists in debian/tmp but is not installed to anywhere
dh_install: missing files, aborting

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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

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

Subscribers

People subscribed via source and target branches