Merge lp:~smspillaz/compiz/compiz.animationsjc-returns-v2 into lp:compiz/0.9.13

Proposed by Sam Spilsbury
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 4073
Merged at revision: 4072
Proposed branch: lp:~smspillaz/compiz/compiz.animationsjc-returns-v2
Merge into: lp:compiz/0.9.13
Diff against target: 1121 lines (+1019/-0)
15 files modified
debian/compiz-dev.install (+1/-0)
debian/compiz-plugins.install (+2/-0)
debian/compiz-plugins.install.armel (+2/-0)
debian/compiz-plugins.install.armhf (+2/-0)
plugins/animationjc/CMakeLists.txt (+4/-0)
plugins/animationjc/animationjc.xml.in (+154/-0)
plugins/animationjc/compiz-animationjc.pc.in (+12/-0)
plugins/animationjc/include/animationjc/animationjc.h (+42/-0)
plugins/animationjc/src/animationjc.cpp (+150/-0)
plugins/animationjc/src/blackhole.cpp (+79/-0)
plugins/animationjc/src/flicker.cpp (+96/-0)
plugins/animationjc/src/ghost.cpp (+98/-0)
plugins/animationjc/src/popcorn.cpp (+60/-0)
plugins/animationjc/src/private.h (+232/-0)
plugins/animationjc/src/raindrop.cpp (+85/-0)
To merge this branch: bzr merge lp:~smspillaz/compiz/compiz.animationsjc-returns-v2
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Pending
Marco Trevisan (Treviño) Pending
Review via email: mp+301092@code.launchpad.net

This proposal supersedes a proposal from 2016-07-09.

Commit message

Re-add the animationsjc plugin

Description of the change

Re-add the animationsjc plugin.

Removed dependency on libGLU.

(Thanks to MC Return for preserving this)

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal

Please add .pc file to -dev:

dh_install: usr/lib/x86_64-linux-gnu/pkgconfig/compiz-animationjc.pc exists in debian/tmp but is not installed to anywhere

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

Of course. I'm not sure why animationjc installs a pkgconfig file - I don't think it purports to actually export and extension plugin. Nevertheless, probably better to just install it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/compiz-dev.install'
2--- debian/compiz-dev.install 2016-06-28 14:57:19 +0000
3+++ debian/compiz-dev.install 2016-07-25 17:10:57 +0000
4@@ -2,6 +2,7 @@
5 debian/tmp/usr/lib/*/libcompiz_core.so
6 debian/tmp/usr/lib/*/pkgconfig/compiz-animation.pc
7 debian/tmp/usr/lib/*/pkgconfig/compiz-animationaddon.pc
8+debian/tmp/usr/lib/*/pkgconfig/compiz-animationjc.pc
9 debian/tmp/usr/lib/*/pkgconfig/compiz-compiztoolbox.pc
10 debian/tmp/usr/lib/*/pkgconfig/compiz-composite.pc
11 debian/tmp/usr/lib/*/pkgconfig/compiz-cube.pc
12
13=== modified file 'debian/compiz-plugins.install'
14--- debian/compiz-plugins.install 2016-06-28 14:57:19 +0000
15+++ debian/compiz-plugins.install 2016-07-25 17:10:57 +0000
16@@ -4,6 +4,8 @@
17 usr/share/compiz/*annotate.*
18 usr/lib/*/compiz/*animationaddon.*
19 usr/share/compiz/*animationaddon.*
20+usr/lib/*/compiz/*animationjc.*
21+usr/share/compiz/*animationjc.*
22 usr/lib/*/compiz/*bench.*
23 usr/share/compiz/*bench.*
24 usr/lib/*/compiz/*blur.*
25
26=== modified file 'debian/compiz-plugins.install.armel'
27--- debian/compiz-plugins.install.armel 2016-06-28 14:57:19 +0000
28+++ debian/compiz-plugins.install.armel 2016-07-25 17:10:57 +0000
29@@ -4,6 +4,8 @@
30 usr/share/compiz/*annotate.*
31 usr/lib/*/compiz/*animationaddon.*
32 usr/share/compiz/*animationaddon.*
33+usr/lib/*/compiz/*animationjc.*
34+usr/share/compiz/*animationjc.*
35 usr/lib/*/compiz/*clone.*
36 usr/share/compiz/*clone.*
37 usr/lib/*/compiz/*crashhandler.*
38
39=== modified file 'debian/compiz-plugins.install.armhf'
40--- debian/compiz-plugins.install.armhf 2016-06-28 14:57:19 +0000
41+++ debian/compiz-plugins.install.armhf 2016-07-25 17:10:57 +0000
42@@ -4,6 +4,8 @@
43 usr/share/compiz/*annotate.*
44 usr/lib/*/compiz/*animationaddon.*
45 usr/share/compiz/*animationaddon.*
46+usr/lib/*/compiz/*animationjc.*
47+usr/share/compiz/*animationjc.*
48 usr/lib/*/compiz/*clone.*
49 usr/share/compiz/*clone.*
50 usr/lib/*/compiz/*crashhandler.*
51
52=== added directory 'plugins/animationjc'
53=== added file 'plugins/animationjc/CMakeLists.txt'
54--- plugins/animationjc/CMakeLists.txt 1970-01-01 00:00:00 +0000
55+++ plugins/animationjc/CMakeLists.txt 2016-07-25 17:10:57 +0000
56@@ -0,0 +1,4 @@
57+find_package (Compiz REQUIRED)
58+include (CompizPlugin)
59+
60+compiz_plugin (animationjc PLUGINDEPS composite opengl animation)
61
62=== added file 'plugins/animationjc/animationjc.xml.in'
63--- plugins/animationjc/animationjc.xml.in 1970-01-01 00:00:00 +0000
64+++ plugins/animationjc/animationjc.xml.in 2016-07-25 17:10:57 +0000
65@@ -0,0 +1,154 @@
66+<compiz>
67+ <!-- animationaddon metadata -->
68+ <plugin name="animationjc" useBcop="true">
69+ <_short>Animations Experimental</_short>
70+ <_long>Extra window animations</_long>
71+ <category>Effects</category>
72+ <deps>
73+ <requirement>
74+ <plugin>opengl</plugin>
75+ <plugin>animation</plugin>
76+ </requirement>
77+ <relation type="after">
78+ <plugin>opengl</plugin>
79+ <plugin>composite</plugin>
80+ <plugin>animation</plugin>
81+ <plugin>decor</plugin>
82+ </relation>
83+ </deps>
84+
85+ <options>
86+ <group>
87+ <_short>Effect Settings</_short>
88+
89+ <subgroup>
90+ <_short>Black Hole</_short>
91+ <option name="blackhole_delay" type="float">
92+ <_short>Delay</_short>
93+ <default>0.75</default>
94+ <min>0.0</min>
95+ <max>0.99</max>
96+ <precision>0.01</precision>
97+ </option>
98+ </subgroup>
99+
100+ <subgroup>
101+ <_short>Flicker</_short>
102+ <option name="flicker_amplitude" type="int">
103+ <_short>Amplitude</_short>
104+ <default>3</default>
105+ <min>1</min>
106+ <max>10</max>
107+ </option>
108+ </subgroup>
109+
110+ <subgroup>
111+ <_short>Ghost</_short>
112+ <option name="ghost_grid" type="int">
113+ <_short>Grid</_short>
114+ <default>20</default>
115+ <min>2</min>
116+ <max>20</max>
117+ </option>
118+
119+ <option name="ghost_saturation" type="float">
120+ <_short>Saturation</_short>
121+ <default>0.0</default>
122+ <min>0.0</min>
123+ <max>1.0</max>
124+ <precision>0.1</precision>
125+ </option>
126+
127+ <option name="ghost_amplitude" type="float">
128+ <_short>Amplitude</_short>
129+ <default>1.0</default>
130+ <min>0.0</min>
131+ <max>5.0</max>
132+ </option>
133+
134+ <option name="ghost_wave_speed" type="float">
135+ <_short>Wave Speed</_short>
136+ <default>1.0</default>
137+ <min>0.0</min>
138+ <max>5.0</max>
139+ </option>
140+ </subgroup>
141+
142+ <subgroup>
143+ <_short>Popcorn</_short>
144+ <option name="popcorn_kernel_height" type="float">
145+ <_short>Kernel Height</_short>
146+ <default>1.0</default>
147+ <min>0.0</min>
148+ <max>5.0</max>
149+ <precision>0.1</precision>
150+ </option>
151+ </subgroup>
152+
153+ <subgroup>
154+ <_short>Raindrop</_short>
155+
156+ <option name="raindrop_amplitude" type="float">
157+ <_short>Amplitude</_short>
158+ <default>1.0</default>
159+ <min>-5.0</min>
160+ <max>5.0</max>
161+ <precision>0.1</precision>
162+ </option>
163+
164+ <option name="raindrop_wavelength" type="float">
165+ <_short>Wavelength</_short>
166+ <default>0.4</default>
167+ <min>0.0</min>
168+ <max>1.0</max>
169+ <precision>0.05</precision>
170+ </option>
171+
172+ <option name="raindrop_num_waves" type="int">
173+ <_short>Number of Waves</_short>
174+ <default>1</default>
175+ <min>1</min>
176+ <max>5</max>
177+ </option>
178+ </subgroup>
179+ </group>
180+ </options>
181+
182+ <extension base_plugin="animation">
183+ <base_option>open_effects</base_option>
184+ <base_option>open_random_effects</base_option>
185+ <base_option>close_effects</base_option>
186+ <base_option>close_random_effects</base_option>
187+ <base_option>minimize_effects</base_option>
188+ <base_option>minimize_random_effects</base_option>
189+ <restriction>
190+ <value>animationjc:Black Hole</value>
191+ <_name>Black Hole</_name>
192+ </restriction>
193+ <restriction>
194+ <value>animationjc:Ghost</value>
195+ <_name>Ghost</_name>
196+ </restriction>
197+ <restriction>
198+ <value>animationjc:Popcorn</value>
199+ <_name>Popcorn</_name>
200+ </restriction>
201+ </extension>
202+
203+ <extension base_plugin="animation">
204+ <base_option>open_effects</base_option>
205+ <base_option>open_random_effects</base_option>
206+ <base_option>close_effects</base_option>
207+ <base_option>close_random_effects</base_option>
208+ <base_option>focus_effects</base_option>
209+ <restriction>
210+ <value>animationjc:Flicker</value>
211+ <_name>Flicker</_name>
212+ </restriction>
213+ <restriction>
214+ <value>animationjc:Raindrop</value>
215+ <_name>Raindrop</_name>
216+ </restriction>
217+ </extension>
218+ </plugin>
219+</compiz>
220
221=== added file 'plugins/animationjc/compiz-animationjc.pc.in'
222--- plugins/animationjc/compiz-animationjc.pc.in 1970-01-01 00:00:00 +0000
223+++ plugins/animationjc/compiz-animationjc.pc.in 2016-07-25 17:10:57 +0000
224@@ -0,0 +1,12 @@
225+prefix=@prefix@
226+exec_prefix=@prefix@
227+libdir=@libdir@
228+includedir=@includedir@
229+
230+Name: compiz-animationjc
231+Description: Animation JC plugin for compiz
232+Version: @VERSION@
233+
234+Requires: compiz compiz-composite compiz-opengl compiz-animation
235+Libs: -L${libdir} -lanimationjc
236+Cflags: @COMPIZ_CFLAGS@
237
238=== added directory 'plugins/animationjc/include'
239=== added directory 'plugins/animationjc/include/animationjc'
240=== added file 'plugins/animationjc/include/animationjc/animationjc.h'
241--- plugins/animationjc/include/animationjc/animationjc.h 1970-01-01 00:00:00 +0000
242+++ plugins/animationjc/include/animationjc/animationjc.h 2016-07-25 17:10:57 +0000
243@@ -0,0 +1,42 @@
244+#ifndef _COMPIZ_ANIMATIONJC_H
245+#define _COMPIZ_ANIMATIONJC_H
246+
247+#define ANIMATIONADDON_ABI 20091206
248+
249+#include <core/pluginclasshandler.h>
250+
251+#include <vector>
252+#include <boost/ptr_container/ptr_vector.hpp>
253+
254+#include <opengl/opengl.h>
255+
256+using namespace::std;
257+
258+class PrivateAnimJCScreen;
259+
260+
261+/// Base class for all polygon- and particle-based animations
262+class BaseAddonAnim :
263+ virtual public Animation
264+{
265+public:
266+ BaseAddonAnim (CompWindow *w,
267+ WindowEvent curWindowEvent,
268+ float duration,
269+ const AnimEffect info,
270+ const CompRect &icon);
271+ ~BaseAddonAnim () {}
272+
273+ bool needsDepthTest () { return mDoDepthTest; }
274+
275+protected:
276+ /// Gets info about the extension plugin that implements this animation.
277+ ExtensionPluginInfo *getExtensionPluginInfo ();
278+
279+ CompositeScreen *mCScreen;
280+ GLScreen *mGScreen;
281+
282+ bool mDoDepthTest; ///< Whether depth testing should be used in the effect
283+};
284+
285+#endif
286
287=== added directory 'plugins/animationjc/src'
288=== added file 'plugins/animationjc/src/animationjc.cpp'
289--- plugins/animationjc/src/animationjc.cpp 1970-01-01 00:00:00 +0000
290+++ plugins/animationjc/src/animationjc.cpp 2016-07-25 17:10:57 +0000
291@@ -0,0 +1,150 @@
292+#include "private.h"
293+
294+class AnimJCPluginVTable :
295+ public CompPlugin::VTableForScreenAndWindow<AnimJCScreen, AnimJCWindow>
296+{
297+public:
298+ bool init ();
299+};
300+
301+COMPIZ_PLUGIN_20090315 (animationjc, AnimJCPluginVTable);
302+
303+AnimEffect animEffects[NUM_EFFECTS];
304+
305+ExtensionPluginAnimJC animJCExtPluginInfo (CompString ("animationjc"),
306+ NUM_EFFECTS, animEffects, NULL,
307+ NUM_NONEFFECT_OPTIONS);
308+
309+AnimEffect AnimEffectBlackHole;
310+AnimEffect AnimEffectFlicker;
311+AnimEffect AnimEffectGhost;
312+AnimEffect AnimEffectPopcorn;
313+AnimEffect AnimEffectRaindrop;
314+
315+ExtensionPluginInfo *
316+BaseAddonAnim::getExtensionPluginInfo ()
317+{
318+ return &animJCExtPluginInfo;
319+}
320+
321+BaseAddonAnim::BaseAddonAnim (CompWindow *w,
322+ WindowEvent curWindowEvent,
323+ float duration,
324+ const AnimEffect info,
325+ const CompRect &icon) :
326+ Animation::Animation (w, curWindowEvent, duration, info, icon),
327+ mCScreen (CompositeScreen::get (::screen)),
328+ mGScreen (GLScreen::get (::screen)),
329+ mDoDepthTest (false)
330+{
331+}
332+
333+void
334+AnimJCScreen::initAnimationList ()
335+{
336+ int i = 0;
337+
338+ AnimEffectUsedFor focusableUsedFor = AnimEffectUsedFor::all ()
339+ .exclude (AnimEventShade);
340+ AnimEffectUsedFor openUsedFor = AnimEffectUsedFor::all ()
341+ .exclude (AnimEventShade)
342+ .exclude (AnimEventFocus);
343+
344+ animEffects[i++] = AnimEffectBlackHole =
345+ new AnimEffectInfo ("animationjc:Black Hole",
346+ openUsedFor,
347+ &createAnimation<BlackHoleAnim>);
348+
349+ animEffects[i++] = AnimEffectFlicker =
350+ new AnimEffectInfo ("animationjc:Flicker",
351+ focusableUsedFor,
352+ &createAnimation<FlickerAnim>);
353+
354+ animEffects[i++] = AnimEffectGhost =
355+ new AnimEffectInfo ("animationjc:Ghost",
356+ openUsedFor,
357+ &createAnimation<GhostAnim>);
358+
359+ animEffects[i++] = AnimEffectPopcorn =
360+ new AnimEffectInfo ("animationjc:Popcorn",
361+ openUsedFor,
362+ &createAnimation<PopcornAnim>);
363+
364+ animEffects[i++] = AnimEffectRaindrop =
365+ new AnimEffectInfo ("animationjc:Raindrop",
366+ focusableUsedFor,
367+ &createAnimation<RaindropAnim>);
368+
369+ animJCExtPluginInfo.effectOptions = &getOptions ();
370+
371+ AnimScreen *as = AnimScreen::get (::screen);
372+
373+ // Extends animation plugin with this set of animation effects.
374+ as->addExtension (&animJCExtPluginInfo);
375+}
376+
377+PrivateAnimJCScreen::PrivateAnimJCScreen (CompScreen *s) :
378+ mOutput (s->fullscreenOutput ())
379+{
380+}
381+
382+PrivateAnimJCScreen::~PrivateAnimJCScreen ()
383+{
384+ AnimScreen *as = AnimScreen::get (::screen);
385+
386+ as->removeExtension (&animJCExtPluginInfo);
387+
388+ for (int i = 0; i < NUM_EFFECTS; i++)
389+ {
390+ delete animEffects[i];
391+ animEffects[i] = NULL;
392+ }
393+}
394+
395+AnimJCScreen::AnimJCScreen (CompScreen *s) :
396+ PluginClassHandler<AnimJCScreen, CompScreen> (s),
397+ priv (new PrivateAnimJCScreen (s))
398+{
399+ initAnimationList ();
400+}
401+
402+AnimJCScreen::~AnimJCScreen ()
403+{
404+ delete priv;
405+}
406+
407+AnimJCWindow::AnimJCWindow (CompWindow *w) :
408+ PluginClassHandler<AnimJCWindow, CompWindow> (w),
409+ mWindow (w),
410+ aWindow (AnimWindow::get (w))
411+{
412+}
413+
414+AnimJCWindow::~AnimJCWindow ()
415+{
416+ Animation *curAnim = aWindow->curAnimation ();
417+
418+ if (!curAnim)
419+ return;
420+
421+ // We need to interrupt and clean up the animation currently being played
422+ // by animationaddon for this window (if any)
423+ if (curAnim->remainingTime () > 0 &&
424+ curAnim->getExtensionPluginInfo ()->name ==
425+ CompString ("animationjc"))
426+ {
427+ aWindow->postAnimationCleanUp ();
428+ }
429+}
430+
431+bool
432+AnimJCPluginVTable::init ()
433+{
434+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) |
435+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) |
436+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) |
437+ !CompPlugin::checkPluginABI ("animation", ANIMATION_ABI))
438+ return false;
439+
440+ return true;
441+}
442
443=== added file 'plugins/animationjc/src/blackhole.cpp'
444--- plugins/animationjc/src/blackhole.cpp 1970-01-01 00:00:00 +0000
445+++ plugins/animationjc/src/blackhole.cpp 2016-07-25 17:10:57 +0000
446@@ -0,0 +1,79 @@
447+#include "private.h"
448+
449+#include <algorithm>
450+
451+BlackHoleAnim::BlackHoleAnim (CompWindow *w,
452+ WindowEvent curWindowEvent,
453+ float duration,
454+ const AnimEffect info,
455+ const CompRect &icon) :
456+ Animation::Animation (w, curWindowEvent, duration, info, icon),
457+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
458+ GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info,
459+ icon)
460+{
461+}
462+
463+void
464+BlackHoleAnim::initGrid ()
465+{
466+ mGridWidth = 20;
467+ mGridHeight = 20;
468+}
469+
470+void
471+BlackHoleAnim::step ()
472+{
473+ CompRect winRect (mAWindow->savedRectsValid () ?
474+ mAWindow->saveWinRect () :
475+ mWindow->geometry ());
476+ CompRect outRect (mAWindow->savedRectsValid () ?
477+ mAWindow->savedOutRect () :
478+ mWindow->outputRect ());
479+ CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
480+ mAWindow->savedOutExtents () :
481+ mWindow->output ());
482+
483+ int wx = winRect.x ();
484+ int wy = winRect.y ();
485+
486+ int owidth = outRect.width ();
487+ int oheight = outRect.height ();
488+
489+ float centerx = wx + mModel->scale ().x () *
490+ (owidth * 0.5 - outExtents.left);
491+ float centery = wy + mModel->scale ().y () *
492+ (oheight * 0.5 - outExtents.top);
493+
494+ float delay = AnimJCScreen::get (screen)->optionGetBlackholeDelay ();
495+ float tau = (1. - delay) / 8.;
496+
497+ GridModel::GridObject *object = mModel->objects ();
498+ unsigned int n = mModel->numObjects ();
499+ for (unsigned int i = 0; i < n; i++, object++)
500+ {
501+ // find distance to center in grid terms, 0..1
502+ float gridDistance = 2 * max (fabs (object->gridPosition ().x ()-0.5),
503+ fabs (object->gridPosition ().y ()-0.5));
504+
505+ // use that and tau to find r
506+ float cutoff = gridDistance * delay;
507+ float r = 1;
508+ if (getBlackHoleProgress () > cutoff)
509+ r = exp (-(getBlackHoleProgress () - cutoff) / tau);
510+
511+ // find real original coordinates
512+ float origx = wx + mModel->scale ().x () *
513+ (owidth * object->gridPosition ().x () -
514+ outExtents.left);
515+ float origy = wy + mModel->scale ().y () *
516+ (oheight * object->gridPosition ().y () -
517+ outExtents.top);
518+
519+ // shrink toward center by r
520+ Point3d &objPos = object->position ();
521+ objPos.setX ((origx-centerx) * r + centerx);
522+ objPos.setY ((origy-centery) * r + centery);
523+ objPos.setZ (0);
524+ }
525+}
526
527=== added file 'plugins/animationjc/src/flicker.cpp'
528--- plugins/animationjc/src/flicker.cpp 1970-01-01 00:00:00 +0000
529+++ plugins/animationjc/src/flicker.cpp 2016-07-25 17:10:57 +0000
530@@ -0,0 +1,96 @@
531+#include <private.h>
532+
533+void
534+FlickerSingleAnim::updateAttrib (GLWindowPaintAttrib &attrib)
535+{
536+ int layer = MultiAnim <FlickerSingleAnim,5>::getCurrAnimNumber (mAWindow);
537+ float o = 0.2;
538+ attrib.opacity *= o / (1. - (4-layer)*o);
539+}
540+
541+void
542+FlickerSingleAnim::initGrid ()
543+{
544+ mGridWidth = 2;
545+ mGridHeight = 20;
546+}
547+
548+void
549+FlickerSingleAnim::step ()
550+{
551+ int layer = MultiAnim <FlickerSingleAnim,5>::getCurrAnimNumber (mAWindow);
552+
553+ CompRect winRect (mAWindow->savedRectsValid () ?
554+ mAWindow->saveWinRect () :
555+ mWindow->geometry ());
556+ CompRect outRect (mAWindow->savedRectsValid () ?
557+ mAWindow->savedOutRect () :
558+ mWindow->outputRect ());
559+ CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
560+ mAWindow->savedOutExtents () :
561+ mWindow->output ());
562+
563+ int wx = winRect.x ();
564+ int wy = winRect.y ();
565+ int owidth = outRect.width ();
566+ int oheight = outRect.height ();
567+
568+ float t = 1 - progressLinear ();
569+ if (mCurWindowEvent == WindowEventClose)
570+ t = 1 - t;
571+
572+ float amplitude = AnimJCScreen::get (screen)->optionGetFlickerAmplitude ();
573+ float waveLength = 0.4;
574+ float wavePosition = -waveLength + (1. + waveLength) * t;
575+
576+ float displacement = 0;
577+
578+ GridModel::GridObject *object = mModel->objects ();
579+ unsigned int n = mModel->numObjects ();
580+ for (unsigned int i = 0; i < n; i++, object++)
581+ {
582+ Point3d &objPos = object->position ();
583+
584+ if (i % 2 == 0) // left side; reuse old displacement on right side
585+ {
586+ float distFromWave = object->gridPosition ().y () - wavePosition;
587+
588+ if (distFromWave > 0 && distFromWave <= waveLength)
589+ {
590+ displacement = amplitude * sin (distFromWave/waveLength * M_PI);
591+ }
592+ else
593+ {
594+ displacement = 0;
595+ }
596+ }
597+
598+ float x = wx + mModel->scale ().x () *
599+ (owidth * object->gridPosition ().x () - outExtents.left);
600+
601+ float y = wy + mModel->scale ().y () *
602+ (oheight * object->gridPosition ().y () - outExtents.top);
603+
604+ switch (layer)
605+ {
606+ case 1:
607+ x -= displacement;
608+ break;
609+ case 2:
610+ x += displacement;
611+ break;
612+ case 3:
613+ y -= displacement;
614+ break;
615+ case 4:
616+ y += displacement;
617+ break;
618+ default:
619+ break;
620+ }
621+
622+ objPos.setX (x);
623+ objPos.setY (y);
624+ objPos.setZ (0);
625+ }
626+}
627
628=== added file 'plugins/animationjc/src/ghost.cpp'
629--- plugins/animationjc/src/ghost.cpp 1970-01-01 00:00:00 +0000
630+++ plugins/animationjc/src/ghost.cpp 2016-07-25 17:10:57 +0000
631@@ -0,0 +1,98 @@
632+#include "private.h"
633+
634+GhostAnim::GhostAnim (CompWindow *w,
635+ WindowEvent curWindowEvent,
636+ float duration,
637+ const AnimEffect info,
638+ const CompRect &icon) :
639+ Animation::Animation (w, curWindowEvent, duration, info, icon),
640+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
641+ GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info,
642+ icon)
643+{
644+}
645+
646+void
647+GhostAnim::updateAttrib (GLWindowPaintAttrib &attrib)
648+{
649+ AnimJCScreen *ajs = AnimJCScreen::get (screen);
650+ attrib.opacity *= 1. - progressLinear ();
651+ attrib.saturation *= ajs->optionGetGhostSaturation ();
652+}
653+
654+void
655+GhostAnim::initGrid ()
656+{
657+ AnimJCScreen *ajs = AnimJCScreen::get (screen);
658+ mGridWidth = ajs->optionGetGhostGrid ();
659+ mGridHeight = ajs->optionGetGhostGrid ();
660+}
661+
662+void
663+GhostAnim::step ()
664+{
665+ float t = 1. - progressLinear ();
666+ if (mCurWindowEvent == WindowEventClose)
667+ t = 1. - t;
668+
669+ CompRect winRect (mAWindow->savedRectsValid () ?
670+ mAWindow->saveWinRect () :
671+ mWindow->geometry ());
672+ CompRect outRect (mAWindow->savedRectsValid () ?
673+ mAWindow->savedOutRect () :
674+ mWindow->outputRect ());
675+ CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
676+ mAWindow->savedOutExtents () :
677+ mWindow->output ());
678+
679+ int wx = winRect.x ();
680+ int wy = winRect.y ();
681+
682+ int owidth = outRect.width ();
683+ int oheight = outRect.height ();
684+
685+ AnimJCScreen *ajs = AnimJCScreen::get (screen);
686+
687+ float waveAmp = 3 * ajs->optionGetGhostAmplitude ();
688+ float waveLengthX1 = 0.4;
689+ float waveLengthX2 = 0.3;
690+ float waveLengthY1 = 0.45;
691+ float waveLengthY2 = 0.35;
692+ float wavePositionX1 = 0.25 * t * ajs->optionGetGhostWaveSpeed ();
693+ float wavePositionX2 = -0.25 * t * ajs->optionGetGhostWaveSpeed ();
694+ float wavePositionY1 = 0.25 * t * ajs->optionGetGhostWaveSpeed ();
695+ float wavePositionY2 = -0.25 * t * ajs->optionGetGhostWaveSpeed ();
696+
697+ GridModel::GridObject *object = mModel->objects ();
698+ unsigned int n = mModel->numObjects ();
699+ for (unsigned int i = 0; i < n; i++, object++)
700+ {
701+ Point3d &objPos = object->position ();
702+
703+ float origx = wx + mModel->scale ().x () *
704+ (owidth * object->gridPosition ().x () -
705+ outExtents.left);
706+
707+ float origy = wy + mModel->scale ().y () *
708+ (oheight * object->gridPosition ().y () -
709+ outExtents.top);
710+
711+ float x = object->gridPosition ().x ();
712+ float y = object->gridPosition ().y ();
713+
714+ float distFromWaveX1 = x - wavePositionX1;
715+ float distFromWaveX2 = x - wavePositionX2;
716+ float distFromWaveY1 = y - wavePositionY1;
717+ float distFromWaveY2 = y - wavePositionY2;
718+
719+ objPos.setX (origx +
720+ waveAmp * sin (distFromWaveX1 / waveLengthX1 * 2 * M_PI) +
721+ waveAmp * sin (distFromWaveX2 / waveLengthX2 * 2 * M_PI));
722+
723+ objPos.setY (origy +
724+ waveAmp * sin (distFromWaveY1 / waveLengthY1 * 2 * M_PI) +
725+ waveAmp * sin (distFromWaveY2 / waveLengthY2 * 2 * M_PI));
726+
727+ objPos.setZ (0);
728+ }
729+}
730
731=== added file 'plugins/animationjc/src/popcorn.cpp'
732--- plugins/animationjc/src/popcorn.cpp 1970-01-01 00:00:00 +0000
733+++ plugins/animationjc/src/popcorn.cpp 2016-07-25 17:10:57 +0000
734@@ -0,0 +1,60 @@
735+#include <private.h>
736+
737+#define WIN_X(w) ((w)->x () - (w)->input ().left)
738+#define WIN_Y(w) ((w)->y () - (w)->input ().top)
739+#define WIN_W(w) ((w)->width () + (w)->input ().left + (w)->input ().right)
740+#define WIN_H(w) ((w)->height () + (w)->input ().top + (w)->input ().bottom)
741+
742+float
743+PopcornSingleAnim::layerProgress (int layer)
744+{
745+ if (layer == 0)
746+ return 0;
747+
748+ float tStart = (5. - layer) / 6.;
749+ float tEnd = tStart + 1./3.;
750+
751+ float t = progressLinear ();
752+
753+ if (t < tStart)
754+ return 0;
755+
756+ if (t > tEnd)
757+ return 1;
758+
759+ return (t - tStart) / (tEnd - tStart);
760+}
761+
762+void
763+PopcornSingleAnim::updateAttrib (GLWindowPaintAttrib &attrib)
764+{
765+ int layer = MultiAnim <PopcornSingleAnim, 6>::getCurrAnimNumber (mAWindow);
766+
767+ attrib.opacity *= 1. - progressLinear ();
768+
769+ attrib.opacity *= 1. - layerProgress (layer);
770+}
771+
772+void
773+PopcornSingleAnim::applyTransform ()
774+{
775+ int layer = MultiAnim <PopcornSingleAnim, 6>::getCurrAnimNumber (mAWindow);
776+
777+ if (layer == 0) return;
778+
779+ float p = layerProgress (layer);
780+
781+ float v = 40.;
782+ float theta = (54. + 144.*(layer-1)) / 180. * 3.14159265;
783+ float dx = v * cos (theta) * p;
784+ float dy = -v * sin (theta) * p;
785+
786+ mTransform.translate (dx, dy,
787+ 0.16*p*AnimJCScreen::get (screen)->optionGetPopcornKernelHeight ());
788+}
789+
790+void
791+PopcornSingleAnim::updateBB (CompOutput &output)
792+{
793+ TransformAnim::updateBB (output);
794+}
795
796=== added file 'plugins/animationjc/src/private.h'
797--- plugins/animationjc/src/private.h 1970-01-01 00:00:00 +0000
798+++ plugins/animationjc/src/private.h 2016-07-25 17:10:57 +0000
799@@ -0,0 +1,232 @@
800+#include <string.h>
801+#include <stdlib.h>
802+#include <math.h>
803+
804+#include <core/core.h>
805+#include <composite/composite.h>
806+#include <opengl/opengl.h>
807+
808+#include <boost/foreach.hpp>
809+#define foreach BOOST_FOREACH
810+
811+#include <animation/animation.h>
812+#include <animationjc/animationjc.h>
813+
814+#include "animationjc_options.h"
815+
816+extern AnimEffect AnimEffectBlackHole;
817+extern AnimEffect AnimEffectFlicker;
818+extern AnimEffect AnimEffectGhost;
819+extern AnimEffect AnimEffectPopcorn;
820+extern AnimEffect AnimEffectRaindrop;
821+
822+#define NUM_EFFECTS 5
823+
824+// This must have the value of the first "effect setting" above
825+// in AnimJCScreenOptions
826+#define NUM_NONEFFECT_OPTIONS 0
827+
828+class ExtensionPluginAnimJC : public ExtensionPluginInfo
829+{
830+public:
831+ ExtensionPluginAnimJC (const CompString &name,
832+ unsigned int nEffects,
833+ AnimEffect *effects,
834+ CompOption::Vector *effectOptions,
835+ unsigned int firstEffectOptionIndex) :
836+ ExtensionPluginInfo (name, nEffects, effects, effectOptions,
837+ firstEffectOptionIndex) {}
838+ ~ExtensionPluginAnimJC () {}
839+
840+ const CompOutput *output () { return mOutput; }
841+
842+private:
843+ const CompOutput *mOutput;
844+};
845+
846+class AnimJCScreen :
847+ public PluginClassHandler<AnimJCScreen, CompScreen>,
848+ public AnimationjcOptions
849+{
850+public:
851+ AnimJCScreen (CompScreen *);
852+ ~AnimJCScreen ();
853+
854+ int getIntenseTimeStep ();
855+
856+ void initAnimationList ();
857+
858+private:
859+ PrivateAnimJCScreen *priv;
860+};
861+
862+class PrivateAnimJCScreen
863+{
864+ friend class AnimJCScreen;
865+
866+public:
867+ PrivateAnimJCScreen (CompScreen *);
868+ ~PrivateAnimJCScreen ();
869+
870+protected:
871+ CompOutput &mOutput;
872+};
873+
874+class AnimJCWindow :
875+ public PluginClassHandler<AnimJCWindow, CompWindow>
876+{
877+public:
878+ AnimJCWindow (CompWindow *);
879+ ~AnimJCWindow ();
880+
881+protected:
882+ CompWindow *mWindow; ///< Window being animated.
883+ AnimWindow *aWindow;
884+};
885+
886+/*** BLACK HOLE **************************************************************/
887+
888+class BlackHoleAnim :
889+ public GridTransformAnim
890+{
891+public:
892+ BlackHoleAnim (CompWindow *w,
893+ WindowEvent curWindowEvent,
894+ float duration,
895+ const AnimEffect info,
896+ const CompRect &icon);
897+
898+ float getBlackHoleProgress () { return progressLinear (); }
899+
900+ void initGrid ();
901+ inline bool using3D () { return false; }
902+ void step ();
903+};
904+
905+/*** RAINDROP ****************************************************************/
906+
907+class RaindropAnim :
908+ public GridTransformAnim
909+{
910+public:
911+ RaindropAnim (CompWindow *w,
912+ WindowEvent curWindowEvent,
913+ float duration,
914+ const AnimEffect info,
915+ const CompRect &icon);
916+
917+ void initGrid ();
918+
919+ inline bool using3D () { return true; }
920+
921+ void step ();
922+};
923+
924+/*** POPCORN *****************************************************************/
925+
926+class PopcornSingleAnim :
927+ public TransformAnim
928+{
929+public:
930+ PopcornSingleAnim (CompWindow *w,
931+ WindowEvent curWindowEvent,
932+ float duration,
933+ const AnimEffect info,
934+ const CompRect &icon) :
935+ Animation::Animation
936+ (w, curWindowEvent, duration, info, icon),
937+ TransformAnim::TransformAnim
938+ (w, curWindowEvent, duration, info, icon)
939+ {
940+ }
941+
942+ float layerProgress (int);
943+
944+ void applyTransform ();
945+
946+ void updateAttrib (GLWindowPaintAttrib &);
947+
948+ void updateBB (CompOutput &output);
949+ bool updateBBUsed () { return true; }
950+};
951+
952+class PopcornAnim :
953+ public MultiAnim <PopcornSingleAnim, 6>
954+{
955+public:
956+ PopcornAnim (CompWindow *w,
957+ WindowEvent curWindowEvent,
958+ float duration,
959+ const AnimEffect info,
960+ const CompRect &icon) :
961+ MultiAnim <PopcornSingleAnim, 6>::MultiAnim
962+ (w, curWindowEvent, duration, info, icon)
963+ {
964+ }
965+};
966+
967+/*** GHOST *******************************************************************/
968+
969+class GhostAnim :
970+ public GridTransformAnim
971+{
972+public:
973+ GhostAnim (CompWindow *w,
974+ WindowEvent curWindowEvent,
975+ float duration,
976+ const AnimEffect info,
977+ const CompRect &icon);
978+
979+ void initGrid ();
980+
981+ inline bool using3D () { return true; }
982+
983+ void step ();
984+
985+ void updateAttrib (GLWindowPaintAttrib &);
986+};
987+
988+/*** FLICKER *****************************************************************/
989+
990+class FlickerSingleAnim :
991+ public GridTransformAnim
992+{
993+public:
994+ FlickerSingleAnim (CompWindow *w,
995+ WindowEvent curWindowEvent,
996+ float duration,
997+ const AnimEffect info,
998+ const CompRect &icon) :
999+ Animation::Animation
1000+ (w, curWindowEvent, duration, info, icon),
1001+ TransformAnim::TransformAnim
1002+ (w, curWindowEvent, duration, info, icon),
1003+ GridTransformAnim::GridTransformAnim
1004+ (w, curWindowEvent, duration, info, icon)
1005+ {
1006+ }
1007+
1008+ void updateAttrib (GLWindowPaintAttrib &);
1009+
1010+ void initGrid ();
1011+
1012+ void step ();
1013+
1014+ bool updateBBUsed () { return true; }
1015+ void updateBB (CompOutput &output) { TransformAnim::updateBB (output); }
1016+};
1017+
1018+class FlickerAnim :
1019+ public MultiAnim <FlickerSingleAnim, 5>
1020+{
1021+public:
1022+ FlickerAnim (CompWindow *w,
1023+ WindowEvent curWindowEvent,
1024+ float duration,
1025+ const AnimEffect info,
1026+ const CompRect &icon) :
1027+ MultiAnim <FlickerSingleAnim, 5>::MultiAnim
1028+ (w, curWindowEvent, duration, info, icon)
1029+ {
1030+ }
1031+};
1032
1033=== added file 'plugins/animationjc/src/raindrop.cpp'
1034--- plugins/animationjc/src/raindrop.cpp 1970-01-01 00:00:00 +0000
1035+++ plugins/animationjc/src/raindrop.cpp 2016-07-25 17:10:57 +0000
1036@@ -0,0 +1,85 @@
1037+#include "private.h"
1038+
1039+#include <algorithm>
1040+
1041+RaindropAnim::RaindropAnim (CompWindow *w,
1042+ WindowEvent curWindowEvent,
1043+ float duration,
1044+ const AnimEffect info,
1045+ const CompRect &icon) :
1046+ Animation::Animation (w, curWindowEvent, duration, info, icon),
1047+ TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
1048+ GridTransformAnim::GridTransformAnim (w, curWindowEvent, duration, info,
1049+ icon)
1050+{
1051+}
1052+
1053+void
1054+RaindropAnim::initGrid ()
1055+{
1056+ mGridWidth = 20;
1057+ mGridHeight = 20;
1058+}
1059+
1060+void
1061+RaindropAnim::step ()
1062+{
1063+ float t = 1. - progressLinear ();
1064+ if (mCurWindowEvent == WindowEventClose)
1065+ t = 1. - t;
1066+
1067+ CompRect winRect (mAWindow->savedRectsValid () ?
1068+ mAWindow->saveWinRect () :
1069+ mWindow->geometry ());
1070+ CompRect outRect (mAWindow->savedRectsValid () ?
1071+ mAWindow->savedOutRect () :
1072+ mWindow->outputRect ());
1073+ CompWindowExtents outExtents (mAWindow->savedRectsValid () ?
1074+ mAWindow->savedOutExtents () :
1075+ mWindow->output ());
1076+
1077+ int wx = winRect.x ();
1078+ int wy = winRect.y ();
1079+
1080+ int owidth = outRect.width ();
1081+ int oheight = outRect.height ();
1082+
1083+ AnimJCScreen *ajs = AnimJCScreen::get (screen);
1084+
1085+ float waveLength = ajs->optionGetRaindropWavelength ();
1086+ int numWaves = ajs->optionGetRaindropNumWaves ();
1087+ float waveAmp = (pow ((float)oheight / ::screen->height (), 0.4) * 0.08) *
1088+ ajs->optionGetRaindropAmplitude ();
1089+ float wavePosition = -waveLength * numWaves +
1090+ (1. + waveLength * numWaves) * t;
1091+
1092+ GridModel::GridObject *object = mModel->objects ();
1093+ unsigned int n = mModel->numObjects ();
1094+ for (unsigned int i = 0; i < n; i++, object++)
1095+ {
1096+ Point3d &objPos = object->position ();
1097+
1098+ float origx = wx + mModel->scale ().x () *
1099+ (owidth * object->gridPosition ().x () -
1100+ outExtents.left);
1101+ objPos.setX (origx);
1102+
1103+ float origy = wy + mModel->scale ().y () *
1104+ (oheight * object->gridPosition ().y () -
1105+ outExtents.top);
1106+ objPos.setY (origy);
1107+
1108+ // find distance to center in grid terms
1109+ float gridDistance = sqrt (pow (object->gridPosition ().x ()-0.5, 2) +
1110+ pow (object->gridPosition ().y ()-0.5, 2)) *
1111+ sqrt (2);
1112+
1113+ float distFromWave = gridDistance - wavePosition;
1114+ if (distFromWave < waveLength*numWaves && distFromWave > 0)
1115+ objPos.setZ (waveAmp *
1116+ sin (3.14159265 * distFromWave / waveLength / numWaves) *
1117+ pow (sin (3.14159265 * distFromWave / waveLength), 2));
1118+ else
1119+ objPos.setZ (0);
1120+ }
1121+}

Subscribers

People subscribed via source and target branches