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

Generated by: LCOV version 1.10