LCOV - code coverage report
Current view: top level - slideshow/source/engine/OGLTrans/generic - OGLTrans_TransitionImpl.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 41 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 34 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2008 by Sun Microsystems, Inc.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      12             :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13             :  * it under the terms of the GNU Lesser General Public License version 3
      14             :  * only, as published by the Free Software Foundation.
      15             :  *
      16             :  * OpenOffice.org is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU Lesser General Public License version 3 for more details
      20             :  * (a copy is included in the LICENSE file that accompanied this code).
      21             :  *
      22             :  * You should have received a copy of the GNU Lesser General Public License
      23             :  * version 3 along with OpenOffice.org.  If not, see
      24             :  * <http://www.openoffice.org/license.html>
      25             :  * for a copy of the LGPLv3 License.
      26             :  *
      27             :  ************************************************************************/
      28             : #ifndef INCLUDED_OGLTRANS_TRANSITIONIMPL_HXX_
      29             : #define INCLUDED_OGLTRANS_TRANSITIONIMPL_HXX_
      30             : 
      31             : #include <config_lgpl.h>
      32             : #include <glm/glm.hpp>
      33             : 
      34             : #include <boost/noncopyable.hpp>
      35             : #include <boost/shared_ptr.hpp>
      36             : 
      37             : #include <GL/glew.h>
      38             : 
      39             : #include <basegfx/vector/b2dvector.hxx>
      40             : #include <basegfx/vector/b3dvector.hxx>
      41             : 
      42             : #include <vector>
      43             : 
      44             : class Primitive;
      45             : class Operation;
      46             : class SceneObject;
      47             : class TransitionData;
      48             : 
      49             : struct TransitionSettings
      50             : {
      51           0 :     TransitionSettings() :
      52             :         mbUseMipMapLeaving( true ),
      53             :         mbUseMipMapEntering( true ),
      54             :         mnRequiredGLVersion( 1.0 ),
      55           0 :         mbReflectSlides( false )
      56             :     {
      57           0 :     }
      58             : 
      59             :     /** Whether to use mipmaping for slides textures
      60             :      */
      61             :     bool mbUseMipMapLeaving;
      62             :     bool mbUseMipMapEntering;
      63             : 
      64             :     /** which GL version does the transition require
      65             :      */
      66             :     float mnRequiredGLVersion;
      67             : 
      68             :     /** Whether to reflect slides, the reflection happens on flat surface beneath the slides.
      69             :      ** Now it only works with slides which keep their rectangular shape together.
      70             :      */
      71             :     bool mbReflectSlides;
      72             : };
      73             : 
      74             : typedef std::vector<Primitive> Primitives_t;
      75             : typedef std::vector<boost::shared_ptr<SceneObject> > SceneObjects_t;
      76             : typedef std::vector<boost::shared_ptr<Operation> > Operations_t;
      77             : 
      78           0 : class TransitionScene
      79             : {
      80             : public:
      81           0 :     TransitionScene()
      82           0 :     {
      83           0 :     }
      84             : 
      85           0 :     TransitionScene(
      86             :             const Primitives_t& rLeavingSlidePrimitives,
      87             :             const Primitives_t& rEnteringSlidePrimitives,
      88             :             const Operations_t& rOverallOperations = Operations_t(),
      89             :             const SceneObjects_t& rSceneObjects = SceneObjects_t()
      90             :     )
      91             :         : maLeavingSlidePrimitives(rLeavingSlidePrimitives)
      92             :         , maEnteringSlidePrimitives(rEnteringSlidePrimitives)
      93             :         , maOverallOperations(rOverallOperations)
      94           0 :         , maSceneObjects(rSceneObjects)
      95             :     {
      96           0 :     }
      97             : 
      98             :     TransitionScene(TransitionScene const& rOther);
      99             :     TransitionScene& operator=(const TransitionScene& rOther);
     100             : 
     101             :     void swap(TransitionScene& rOther);
     102             : 
     103           0 :     const Primitives_t& getLeavingSlide() const
     104             :     {
     105           0 :         return maLeavingSlidePrimitives;
     106             :     }
     107             : 
     108           0 :     const Primitives_t& getEnteringSlide() const
     109             :     {
     110           0 :         return maEnteringSlidePrimitives;
     111             :     }
     112             : 
     113           0 :     const Operations_t& getOperations() const
     114             :     {
     115           0 :         return maOverallOperations;
     116             :     }
     117             : 
     118           0 :     const SceneObjects_t& getSceneObjects() const
     119             :     {
     120           0 :         return maSceneObjects;
     121             :     }
     122             : 
     123             : private:
     124             :     /** All the primitives that use the leaving slide texture
     125             :     */
     126             :     Primitives_t maLeavingSlidePrimitives;
     127             : 
     128             :     /** All the primitives that use the leaving slide texture
     129             :     */
     130             :     Primitives_t maEnteringSlidePrimitives;
     131             : 
     132             :     /** All the operations that should be applied to both leaving and entering slide primitives. These operations will be called in the order they were pushed back in. In OpenGL this effectively uses the operations in the opposite order they were pushed back.
     133             :     */
     134             :     Operations_t maOverallOperations;
     135             : 
     136             :     /** All the surrounding scene objects
     137             :     */
     138             :     SceneObjects_t maSceneObjects;
     139             : };
     140             : 
     141             : /** OpenGL 3D Transition class. It implicitly is constructed from XOGLTransition
     142             : 
     143             :     It holds Primitives and Operations on those primitives.
     144             : */
     145             : class OGLTransitionImpl : private boost::noncopyable
     146             : {
     147             : public:
     148             :     virtual ~OGLTransitionImpl();
     149             : 
     150             :     /** Prepare transition.
     151             :       */
     152             :     void prepare( ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex );
     153             :     /** Display a step of the transition.
     154             :       */
     155             :     void display( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight );
     156             :     /** Clean up after transition.
     157             :       */
     158             :     void finish();
     159             : 
     160           0 :     TransitionSettings const& getSettings() const
     161             :     {
     162           0 :         return maSettings;
     163             :     }
     164             : 
     165             : protected:
     166           0 :     OGLTransitionImpl(const TransitionScene& rScene, const TransitionSettings& rSettings)
     167             :         : maScene(rScene)
     168           0 :         , maSettings(rSettings)
     169           0 :     {}
     170             : 
     171           0 :     OGLTransitionImpl() {}
     172             : 
     173           0 :     TransitionScene const& getScene() const
     174             :     {
     175           0 :         return maScene;
     176             :     }
     177             : 
     178             :     void setScene(TransitionScene const& rScene);
     179             :     // void setSettings(TransitionSettings const& rSettings);
     180             : 
     181             :     void displaySlide( double nTime, ::sal_Int32 glSlideTex, const Primitives_t& primitives, double SlideWidthScale, double SlideHeightScale );
     182             :     void displayScene( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight);
     183             :     void applyOverallOperations( double nTime, double SlideWidthScale, double SlideHeightScale );
     184             : 
     185             : private:
     186             :     /** This function is called in display method to prepare the slides, scene, etc.
     187             :       *
     188             :       * Default implementation does nothing.
     189             :       */
     190             :     virtual void prepare( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight );
     191             : 
     192             :     /** This function is called after glx context is ready to let the transition prepare GL related things, like GLSL program.
     193             :       *
     194             :       * Default implementation does nothing.
     195             :       */
     196             :     virtual void prepareTransition( ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex );
     197             : 
     198             :     /** This function is called when the transition needs to clear after itself, like delete own textures etc.
     199             :       *
     200             :       * Default implementation does nothing.
     201             :       */
     202             :     virtual void finishTransition();
     203             : 
     204             :     /** This function is called in display method to display the slides.
     205             :       *
     206             :       * Default implementation applies overall operations and then
     207             :       * displays both slides.
     208             :       */
     209             :     virtual void displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale );
     210             : 
     211             : private:
     212             :     TransitionScene maScene;
     213             :     const TransitionSettings maSettings;
     214             : };
     215             : 
     216             : 
     217             : // "Constructors" of available transitions
     218             : boost::shared_ptr<OGLTransitionImpl> makeOutsideCubeFaceToLeft();
     219             : boost::shared_ptr<OGLTransitionImpl> makeInsideCubeFaceToLeft();
     220             : boost::shared_ptr<OGLTransitionImpl> makeNByMTileFlip( ::sal_uInt16 n, ::sal_uInt16 m );
     221             : boost::shared_ptr<OGLTransitionImpl> makeRevolvingCircles( ::sal_uInt16 nCircles , ::sal_uInt16 nPointsOnCircles );
     222             : boost::shared_ptr<OGLTransitionImpl> makeHelix( ::sal_uInt16 nRows );
     223             : boost::shared_ptr<OGLTransitionImpl> makeFallLeaving();
     224             : boost::shared_ptr<OGLTransitionImpl> makeTurnAround();
     225             : boost::shared_ptr<OGLTransitionImpl> makeTurnDown();
     226             : boost::shared_ptr<OGLTransitionImpl> makeIris();
     227             : boost::shared_ptr<OGLTransitionImpl> makeRochade();
     228             : boost::shared_ptr<OGLTransitionImpl> makeVenetianBlinds( bool vertical, int parts );
     229             : boost::shared_ptr<OGLTransitionImpl> makeStatic();
     230             : boost::shared_ptr<OGLTransitionImpl> makeDissolve();
     231             : boost::shared_ptr<OGLTransitionImpl> makeNewsflash();
     232             : 
     233             : /** 2D replacements
     234             :     */
     235             : boost::shared_ptr<OGLTransitionImpl> makeDiamond();
     236             : boost::shared_ptr<OGLTransitionImpl> makeFadeSmoothly();
     237             : boost::shared_ptr<OGLTransitionImpl> makeFadeThroughBlack();
     238             : 
     239             : class SceneObject : private boost::noncopyable
     240             : {
     241             : public:
     242             :     SceneObject();
     243             :     virtual ~SceneObject();
     244             : 
     245           0 :     virtual void prepare() {}
     246             :     virtual void display(double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight) const;
     247           0 :     virtual void finish() {}
     248             : 
     249             :     void pushPrimitive (const Primitive &p);
     250             : 
     251             : protected:
     252             :     /** All the surrounding scene primitives
     253             :     */
     254             :     Primitives_t maPrimitives;
     255             : };
     256             : 
     257           0 : class Iris : public SceneObject
     258             : {
     259             : public:
     260             :     Iris ();
     261             : 
     262             :     virtual void prepare() SAL_OVERRIDE;
     263             :     virtual void display(double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight) const SAL_OVERRIDE;
     264             :     virtual void finish() SAL_OVERRIDE;
     265             : 
     266             : private:
     267             :     GLuint maTexture;
     268             : };
     269             : 
     270             : /** This class is a list of Triangles that will share Operations, and could possibly share
     271             : */
     272           0 : class Primitive
     273             : {
     274             : public:
     275           0 :     Primitive() {}
     276             :     // making copy constructor explicit makes the class un-suitable for use with stl containers
     277             :     Primitive(const Primitive& rvalue);
     278             :     Primitive& operator=(const Primitive& rvalue);
     279             : 
     280             :     void swap(Primitive& rOther);
     281             : 
     282             :     void applyOperations(double nTime, double SlideWidthScale, double SlideHeightScale) const;
     283             :     void display(double nTime, double SlideWidthScale, double SlideHeightScale) const;
     284             : 
     285             :     /** PushBack a vertex,normal, and tex coord. Each SlideLocation is where on the slide is mapped to this location ( from (0,0) to (1,1)  ). This will make sure the correct aspect ratio is used, and helps to make slides begin and end at the correct position. (0,0) is the top left of the slide, and (1,1) is the bottom right.
     286             : 
     287             :     @param SlideLocation0
     288             :     Location of first Vertex on slide
     289             : 
     290             :     @param SlideLocation1
     291             :     Location of second Vertex on slide
     292             : 
     293             :     @param SlideLocation2
     294             :     Location of third Vertex on slide
     295             : 
     296             :     */
     297             :     void pushTriangle(const glm::vec2& SlideLocation0,const glm::vec2& SlideLocation1,const glm::vec2& SlideLocation2);
     298             : 
     299             :     /** clear all the vertices, normals, tex coordinates, and normals
     300             :     */
     301             :     void clearTriangles();
     302             : 
     303             :     /** guards against directly changing the vertices
     304             : 
     305             :         @return
     306             :         the list of vertices
     307             :     */
     308           0 :     const std::vector<glm::vec3>& getVertices() const {return Vertices;}
     309             : 
     310             :     /** guards against directly changing the vertices
     311             :     */
     312             :     const std::vector<glm::vec3>& getNormals() const {return Normals;}
     313             : 
     314             :     /** guards against directly changing the vertices
     315             : 
     316             :         @return
     317             :         the list of Texture Coordinates
     318             : 
     319             :     */
     320             :     const std::vector<glm::vec2>& getTexCoords() const {return TexCoords;}
     321             : 
     322             :     /** list of Operations to be performed on this primitive.These operations will be called in the order they were pushed back in. In OpenGL this effectively uses the operations in the opposite order they were pushed back.
     323             : 
     324             :         @return
     325             :         the list of Operations
     326             : 
     327             :     */
     328             :     Operations_t Operations;
     329             : 
     330             : private:
     331             :     /** list of vertices
     332             :     */
     333             :     std::vector<glm::vec3> Vertices;
     334             : 
     335             :     /** list of Normals
     336             :     */
     337             :     std::vector<glm::vec3> Normals;
     338             : 
     339             :     /** list of Texture Coordinates
     340             :     */
     341             :     std::vector<glm::vec2> TexCoords;
     342             : };
     343             : 
     344             : /** This class is to be derived to make any operation (transform) you may need in order to construct your transitions
     345             : */
     346             : class Operation : private boost::noncopyable
     347             : {
     348             : public:
     349           0 :     virtual ~Operation(){}
     350             : 
     351             : protected:
     352             :     /** Should this operation be interpolated . If TRUE, the transform will smoothly move from making no difference from t = 0.0 to mnT0 to being completely transformed from t = mnT1 to 1. If FALSE, the transform will be inneffectual from t = 0 to mnT0, and completely transformed from t = mnT0 to 1.
     353             :     */
     354             :     bool mbInterpolate;
     355             : 
     356             :     /** time to begin the transformation
     357             :     */
     358             :     double mnT0;
     359             : 
     360             :     /** time to finish the transformation
     361             :     */
     362             :     double mnT1;
     363             : public:
     364             :     /** this is the function that is called to give the Operation to OpenGL.
     365             : 
     366             :         @param t
     367             :         time from t = 0 to t = 1
     368             : 
     369             :         @param SlideWidthScale
     370             :         width of slide divided by width of window
     371             : 
     372             :         @param SlideHeightScale
     373             :         height of slide divided by height of window
     374             : 
     375             :     */
     376             :     virtual void interpolate(double t,double SlideWidthScale,double SlideHeightScale) const = 0;
     377             : 
     378             : protected:
     379           0 :     Operation(bool bInterpolate, double nT0, double nT1):
     380           0 :         mbInterpolate(bInterpolate), mnT0(nT0), mnT1(nT1){}
     381             : };
     382             : 
     383             : /** this class is a generic CounterClockWise(CCW) rotation with an axis angle
     384             : */
     385             : class SRotate: public Operation
     386             : {
     387             : public:
     388             :     virtual void interpolate(double t,double SlideWidthScale,double SlideHeightScale) const SAL_OVERRIDE;
     389             : 
     390             :     /** Constructor
     391             : 
     392             :         @param Axis
     393             :         axis to rotate about
     394             : 
     395             :         @param Origin
     396             :         position that rotation axis runs through
     397             : 
     398             :         @param Angle
     399             :         angle in radians of CCW rotation
     400             : 
     401             :         @param bInter
     402             :         see Operation
     403             : 
     404             :         @param T0
     405             :         transformation starting time
     406             : 
     407             :         @param T1
     408             :         transformation ending time
     409             : 
     410             :     */
     411             :     SRotate(const glm::vec3& Axis, const glm::vec3& Origin, double Angle,
     412             :             bool bInter, double T0, double T1);
     413           0 :     virtual ~SRotate(){}
     414             : private:
     415             :     /** axis to rotate CCW about
     416             :     */
     417             :     glm::vec3 axis;
     418             : 
     419             :     /** position that rotation axis runs through
     420             :     */
     421             :     glm::vec3 origin;
     422             : 
     423             :     /** angle in radians of CCW rotation
     424             :     */
     425             :     double angle;
     426             : };
     427             : 
     428             : boost::shared_ptr<SRotate>
     429             : makeSRotate(const glm::vec3& Axis, const glm::vec3& Origin, double Angle,
     430             :         bool bInter, double T0, double T1);
     431             : 
     432             : /** scaling transformation
     433             : */
     434             : class SScale: public Operation
     435             : {
     436             : public:
     437             :     virtual void interpolate(double t,double SlideWidthScale,double SlideHeightScale) const SAL_OVERRIDE;
     438             : 
     439             :     /** Constructor
     440             : 
     441             :         @param Scale
     442             :         amount to scale by
     443             : 
     444             :         @param Origin
     445             :         position that rotation axis runs through
     446             : 
     447             :         @param bInter
     448             :         see Operation
     449             : 
     450             :         @param T0
     451             :         transformation starting time
     452             : 
     453             :         @param T1
     454             :         transformation ending time
     455             : 
     456             :     */
     457             :     SScale(const glm::vec3& Scale, const glm::vec3& Origin,bool bInter, double T0, double T1);
     458           0 :     virtual ~SScale(){}
     459             : private:
     460             :     glm::vec3 scale;
     461             :     glm::vec3 origin;
     462             : };
     463             : 
     464             : boost::shared_ptr<SScale>
     465             : makeSScale(const glm::vec3& Scale, const glm::vec3& Origin,bool bInter, double T0, double T1);
     466             : 
     467             : /** translation transformation
     468             : */
     469             : class STranslate: public Operation
     470             : {
     471             : public:
     472             :     virtual void interpolate(double t,double SlideWidthScale,double SlideHeightScale) const SAL_OVERRIDE;
     473             : 
     474             :     /** Constructor
     475             : 
     476             :         @param Vector
     477             :         vector to translate
     478             : 
     479             :         @param bInter
     480             :         see Operation
     481             : 
     482             :         @param T0
     483             :         transformation starting time
     484             : 
     485             :         @param T1
     486             :         transformation ending time
     487             : 
     488             :     */
     489             :     STranslate(const glm::vec3& Vector,bool bInter, double T0, double T1);
     490           0 :     virtual ~STranslate(){}
     491             : private:
     492             :     /** vector to translate by
     493             :     */
     494             :     glm::vec3 vector;
     495             : };
     496             : 
     497             : boost::shared_ptr<STranslate>
     498             : makeSTranslate(const glm::vec3& Vector,bool bInter, double T0, double T1);
     499             : 
     500             : /** translation transformation
     501             : */
     502             : class SEllipseTranslate: public Operation
     503             : {
     504             : public:
     505             :     virtual void interpolate(double t,double SlideWidthScale,double SlideHeightScale) const SAL_OVERRIDE;
     506             : 
     507             :     /** Constructor
     508             : 
     509             :         @param Vector
     510             :         vector to translate
     511             : 
     512             :         @param bInter
     513             :         see Operation
     514             : 
     515             :         @param T0
     516             :         transformation starting time
     517             : 
     518             :         @param T1
     519             :         transformation ending time
     520             : 
     521             :     */
     522             :     SEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1);
     523           0 :     virtual ~SEllipseTranslate(){}
     524             : private:
     525             :     /** width and length of the ellipse
     526             :      */
     527             :     double width, height;
     528             : 
     529             :     /** start and end position on the ellipse <0,1>
     530             :      */
     531             :     double startPosition;
     532             :     double endPosition;
     533             : };
     534             : 
     535             : boost::shared_ptr<SEllipseTranslate>
     536             : makeSEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1);
     537             : 
     538             : /** Same as SRotate, except the depth is scaled by the width of the slide divided by the width of the window.
     539             : */
     540             : class RotateAndScaleDepthByWidth: public Operation
     541             : {
     542             : public:
     543             :     virtual void interpolate(double t,double SlideWidthScale,double SlideHeightScale) const SAL_OVERRIDE;
     544             : 
     545             :     RotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1);
     546           0 :     virtual ~RotateAndScaleDepthByWidth(){}
     547             : private:
     548             :     glm::vec3 axis;
     549             :     glm::vec3 origin;
     550             :     double angle;
     551             : };
     552             : 
     553             : boost::shared_ptr<RotateAndScaleDepthByWidth>
     554             : makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1);
     555             : 
     556             : /** Same as SRotate, except the depth is scaled by the width of the slide divided by the height of the window.
     557             : */
     558             : class RotateAndScaleDepthByHeight: public Operation
     559             : {
     560             : public:
     561             :     virtual void interpolate(double t,double SlideWidthScale,double SlideHeightScale) const SAL_OVERRIDE;
     562             : 
     563             :     RotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1);
     564           0 :     virtual ~RotateAndScaleDepthByHeight(){}
     565             : private:
     566             :     glm::vec3 axis;
     567             :     glm::vec3 origin;
     568             :     double angle;
     569             : };
     570             : 
     571             : boost::shared_ptr<RotateAndScaleDepthByHeight>
     572             : makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle,bool bInter, double T0, double T1);
     573             : 
     574             : #endif // INCLUDED_SLIDESHOW_TRANSITION_HXX_
     575             : 
     576             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11