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

Generated by: LCOV version 1.10