diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-11-13 10:10:17 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-11-13 10:15:08 +0100 |
commit | f6ef7e33b034d4ee5fb85ae4b72d8d255fbed2b6 (patch) | |
tree | 7b380ff59088c930d26432f015991975db1819b9 /slideshow/source | |
parent | 1c482cb54b4dab4c5b549ecd2395104f042e4101 (diff) |
slideshow: add "glitter" slide transition
Change-Id: Ie89b64c4399cd0092eee579660c9fe85f8ca8e73
Diffstat (limited to 'slideshow/source')
3 files changed, 67 insertions, 5 deletions
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx index cf79ead9ad27..3b3d581fb57f 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx @@ -836,6 +836,20 @@ std::shared_ptr<OGLTransitionImpl> makeHelix( sal_uInt16 nRows ) return makeSimpleTransition(aLeavingSlide, aEnteringSlide); } +float fdiv(int a, int b) +{ + return static_cast<float>(a)/b; +} + +glm::vec2 vec(float x, float y, float nx, float ny) +{ + x = x < 0.0 ? 0.0 : x; + x = x > nx ? nx : x; + y = y < 0.0 ? 0.0 : y; + y = y > ny ? ny : y; + return glm::vec2(fdiv(x, nx), fdiv(y, ny)); +} + std::shared_ptr<OGLTransitionImpl> makeNByMTileFlip( sal_uInt16 n, sal_uInt16 m ) { double invN(1.0/static_cast<double>(n)); @@ -1649,11 +1663,6 @@ std::shared_ptr<OGLTransitionImpl> makeDissolve() namespace { -float fdiv(int a, int b) -{ - return static_cast<float>(a)/b; -} - class VortexTransition : public ShaderTransition { public: @@ -1863,6 +1872,54 @@ std::shared_ptr<OGLTransitionImpl> makeRipple() return makeRippleTransition(aLeavingSlide, aEnteringSlide, aSettings); } +std::shared_ptr<OGLTransitionImpl> makeGlitter() +{ + const int NX = 30, NY = 30; + + Primitives_t aLeavingSlide; + Primitives_t aEnteringSlide; + + for (int y = 0; y < NY+2; y+=2) + { + for (int x = 0; x < NX+2; x+=2) + { + Primitive Slide; + + if (y % 4 == 0) + { + Slide.pushTriangle(vec(x-1, y-1, NX, NY), vec(x, y-2, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x, y-2, NX, NY), vec(x+1, y-1, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x+1, y-1, NX, NY), vec(x+1, y, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x+1, y, NX, NY), vec(x, y+1, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x, y+1, NX, NY), vec(x-1, y, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x-1, y, NX, NY), vec(x-1, y-1, NX, NY), vec(x, y+0.5, NX, NY)); + } + else + { + Slide.pushTriangle(vec(x-2, y-1, NX, NY), vec(x-1, y-2, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x-1, y-2, NX, NY), vec(x, y-1, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x, y-1, NX, NY), vec(x, y, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x, y, NX, NY), vec(x-1, y+1, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x-1, y+1, NX, NY), vec(x-2, y, NX, NY), vec(x, y+0.5, NX, NY)); + Slide.pushTriangle(vec(x-2, y, NX, NY), vec(x-2, y-1, NX, NY), vec(x, y+0.5, NX, NY)); + } + + glm::vec3 center = Slide.getVertices()[2]; + + float random = comphelper::rng::uniform_real_distribution(-0.2, std::nextafter(0.2, DBL_MAX)); + + Slide.Operations.push_back(makeSRotate(glm::vec3(0, 1, 0), center, 180 , true, fdiv(x, NX) + random , 1.0)); + + aLeavingSlide.push_back (Slide); + + Slide.Operations.push_back(makeSRotate(glm::vec3(0, 1, 0), center, 180 , false, fdiv(x, NX) + random, 1.0)); + aEnteringSlide.push_back (Slide); + } + } + + return makeSimpleTransition(aLeavingSlide, aEnteringSlide); +} + std::shared_ptr<OGLTransitionImpl> makeNewsflash() { Primitive Slide; diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx index 7193b6d98a93..f7e26651d517 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.hxx @@ -236,6 +236,7 @@ std::shared_ptr<OGLTransitionImpl> makeStatic(); std::shared_ptr<OGLTransitionImpl> makeDissolve(); std::shared_ptr<OGLTransitionImpl> makeVortex(); std::shared_ptr<OGLTransitionImpl> makeRipple(); +std::shared_ptr<OGLTransitionImpl> makeGlitter(); std::shared_ptr<OGLTransitionImpl> makeNewsflash(); /** 2D replacements diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx index be0686c82325..04c86b13260c 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx @@ -1432,6 +1432,7 @@ public: case animations::TransitionSubType::CORNERSOUT: // 12 case animations::TransitionSubType::VERTICAL: // 13 case animations::TransitionSubType::HORIZONTAL: // 14 + case animations::TransitionSubType::DIAMOND: // 26 case animations::TransitionSubType::CIRCLE: // 27 case animations::TransitionSubType::FANOUTHORIZONTAL: // 55 case animations::TransitionSubType::ACROSS: // 108 @@ -1520,6 +1521,9 @@ public: case animations::TransitionSubType::ACROSS: pTransition = makeNByMTileFlip(8,6); break; + case animations::TransitionSubType::DIAMOND: + pTransition = makeGlitter(); + break; } } else if( transitionType == animations::TransitionType::FADE && transitionSubType == animations::TransitionSubType::CROSSFADE ) { pTransition = makeFadeSmoothly(); |