LCOV - code coverage report
Current view: top level - slideshow/source/engine/slide - layer.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 8 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #ifndef INCLUDED_SLIDESHOW_LAYER_HXX
      21                 :            : #define INCLUDED_SLIDESHOW_LAYER_HXX
      22                 :            : 
      23                 :            : #include <basegfx/range/b2dpolyrange.hxx>
      24                 :            : #include <cppcanvas/spritecanvas.hxx>
      25                 :            : 
      26                 :            : #include "view.hxx"
      27                 :            : #include "animatableshape.hxx"
      28                 :            : 
      29                 :            : #include <boost/shared_ptr.hpp>
      30                 :            : #include <boost/weak_ptr.hpp>
      31                 :            : #include <boost/noncopyable.hpp>
      32                 :            : #include <boost/enable_shared_from_this.hpp>
      33                 :            : 
      34                 :            : #include <vector>
      35                 :            : 
      36                 :            : 
      37                 :            : namespace slideshow
      38                 :            : {
      39                 :            :     namespace internal
      40                 :            :     {
      41                 :            :         class LayerEndUpdate;
      42                 :            : 
      43                 :            :         /* Definition of Layer class */
      44                 :            : 
      45                 :            :         /** This class represents one layer of output on a Slide.
      46                 :            : 
      47                 :            :             Layers group shapes for a certain depth region of a slide.
      48                 :            : 
      49                 :            :             Since slides have a notion of depth, i.e. shapes on it
      50                 :            :             have a certain order in which they lie upon each other,
      51                 :            :             this layering must be modeled. A prime example for this
      52                 :            :             necessity are animations of shapes lying behind other
      53                 :            :             shapes. Then, everything behind the animated shape will be
      54                 :            :             in a background layer, the shape itself will be in an
      55                 :            :             animation layer, and everything before it will be in a
      56                 :            :             foreground layer (these layers are most preferrably
      57                 :            :             modeled as XSprite objects internally).
      58                 :            : 
      59                 :            :             @attention All methods of this class are only supposed to
      60                 :            :             be called from the LayerManager. Normally, it shouldn't be
      61                 :            :             possible to get hold of an instance of this class at all.
      62                 :            :          */
      63                 :          0 :         class Layer : public boost::enable_shared_from_this<Layer>,
      64                 :            :                       private boost::noncopyable
      65                 :            :         {
      66                 :            :         public:
      67                 :            :             typedef boost::shared_ptr<LayerEndUpdate> EndUpdater;
      68                 :            : 
      69                 :            :             /** Create background layer
      70                 :            : 
      71                 :            :                 This method will create a layer without a ViewLayer,
      72                 :            :                 i.e. one that displays directly on the background.
      73                 :            : 
      74                 :            :                 @param rMaxLayerBounds
      75                 :            :                 Maximal bounds of this layer, in user
      76                 :            :                 coordinates. This layer will never be larger or extend
      77                 :            :                 outside these bounds.
      78                 :            :              */
      79                 :            :             static ::boost::shared_ptr< Layer > createBackgroundLayer( const basegfx::B2DRange& rMaxLayerBounds );
      80                 :            : 
      81                 :            :             /** Create non-background layer
      82                 :            : 
      83                 :            :                 This method will create a layer in front of the
      84                 :            :                 background, to contain shapes that should appear in
      85                 :            :                 front of animated objects.
      86                 :            : 
      87                 :            :                 @param rMaxLayerBounds
      88                 :            :                 Maximal bounds of this layer, in user
      89                 :            :                 coordinates. This layer will never be larger or extend
      90                 :            :                 outside these bounds.
      91                 :            :              */
      92                 :            :             static ::boost::shared_ptr< Layer > createLayer( const basegfx::B2DRange& rMaxLayerBounds );
      93                 :            : 
      94                 :            : 
      95                 :            :             /////////////////////////////////////////////////////////////////////
      96                 :            : 
      97                 :            : 
      98                 :            :             /** Predicate, whether this layer is the special
      99                 :            :                 background layer
     100                 :            : 
     101                 :            :                 This method is mostly useful for checking invariants.
     102                 :            :              */
     103                 :            :             bool isBackgroundLayer() const { return mbBackgroundLayer; }
     104                 :            : 
     105                 :            :             /** Add a view to this layer.
     106                 :            : 
     107                 :            :                 If the view is already added, this method does not add
     108                 :            :                 it a second time, just returning the existing ViewLayer.
     109                 :            : 
     110                 :            :                 @param rNewView
     111                 :            :                 New view to add to this layer.
     112                 :            : 
     113                 :            :                 @return the newly generated ViewLayer for this View
     114                 :            :              */
     115                 :            :             ViewLayerSharedPtr addView( const ViewSharedPtr& rNewView );
     116                 :            : 
     117                 :            :             /** Remove a view
     118                 :            : 
     119                 :            :                 This method removes the view from this Layer and all
     120                 :            :                 shapes included herein.
     121                 :            : 
     122                 :            :                 @return the ViewLayer of the removed Layer, if
     123                 :            :                 any. Otherwise, NULL is returned.
     124                 :            :              */
     125                 :            :             ViewLayerSharedPtr removeView( const ViewSharedPtr& rView );
     126                 :            : 
     127                 :            :             /** Init shape with this layer's views
     128                 :            : 
     129                 :            :                 @param rShape
     130                 :            :                 The shape, that will subsequently display on this
     131                 :            :                 layer's views
     132                 :            :              */
     133                 :            :             void setShapeViews( ShapeSharedPtr const& rShape ) const;
     134                 :            : 
     135                 :            : 
     136                 :            :             /////////////////////////////////////////////////////////////////////
     137                 :            : 
     138                 :            : 
     139                 :            :             /** Change layer priority range.
     140                 :            : 
     141                 :            :                 The layer priority affects the position of the layer
     142                 :            :                 in the z direction (i.e. before/behind which other
     143                 :            :                 layers this one appears). The higher the prio, the
     144                 :            :                 further on top of the layer stack this one appears.
     145                 :            : 
     146                 :            :                 @param rPrioRange
     147                 :            :                 The priority range of differing layers must not
     148                 :            :                 intersect
     149                 :            :              */
     150                 :            :             void setPriority( const ::basegfx::B1DRange& rPrioRange );
     151                 :            : 
     152                 :            :             /** Add an area that needs update
     153                 :            : 
     154                 :            :                 @param rUpdateRange
     155                 :            :                 Area on this layer that needs update
     156                 :            :              */
     157                 :            :             void addUpdateRange( ::basegfx::B2DRange const& rUpdateRange );
     158                 :            : 
     159                 :            :             /** Whether any update ranges have been added
     160                 :            : 
     161                 :            :                 @return true, if any non-empty addUpdateRange() calls
     162                 :            :                 have been made since the last render()/update() call.
     163                 :            :              */
     164                 :          0 :             bool isUpdatePending() const { return maUpdateAreas.count()!=0; }
     165                 :            : 
     166                 :            :             /** Update layer bound rect from shape bounds
     167                 :            :              */
     168                 :            :             void updateBounds( ShapeSharedPtr const& rShape );
     169                 :            : 
     170                 :            :             /** Commit collected layer bounds to ViewLayer
     171                 :            : 
     172                 :            :                 Call this method when you're done adding new shapes to
     173                 :            :                 the layer.
     174                 :            : 
     175                 :            :                 @return true, if layer needed a resize (which
     176                 :            :                 invalidates its content - you have to repaint all
     177                 :            :                 contained shapes!)
     178                 :            :              */
     179                 :            :             bool commitBounds();
     180                 :            : 
     181                 :            :             /** Clear all registered update ranges
     182                 :            : 
     183                 :            :                 This method clears all update ranges that are
     184                 :            :                 registered at this layer.
     185                 :            :              */
     186                 :            :             void clearUpdateRanges();
     187                 :            : 
     188                 :            :             /** Clear whole layer content
     189                 :            : 
     190                 :            :                 This method clears the whole layer content. As a
     191                 :            :                 byproduct, all update ranges are cleared as well. It
     192                 :            :                 makes no sense to maintain them any further, since
     193                 :            :                 they only serve for partial updates.
     194                 :            :              */
     195                 :            :             void clearContent();
     196                 :            : 
     197                 :            :             /** Init layer update.
     198                 :            : 
     199                 :            :                 This method initializes a full layer update of the
     200                 :            :                 update area. When the last copy of the returned
     201                 :            :                 EndUpdater is destroyed, the Layer leaves update mode
     202                 :            :                 again.
     203                 :            : 
     204                 :            :                 @return a update end RAII object.
     205                 :            :             */
     206                 :            :             EndUpdater beginUpdate();
     207                 :            : 
     208                 :            :             /** Finish layer update
     209                 :            : 
     210                 :            :                 Resets clipping and transformation to normal values
     211                 :            :              */
     212                 :            :             void endUpdate();
     213                 :            : 
     214                 :            :             /** Check whether given shape is inside current update area.
     215                 :            : 
     216                 :            :                 @return true, if the given shape is at least partially
     217                 :            :                 inside the current update area.
     218                 :            :             */
     219                 :            :             bool isInsideUpdateArea( ShapeSharedPtr const& rShape ) const;
     220                 :            : 
     221                 :            :         private:
     222                 :            :             enum Dummy{ BackgroundLayer };
     223                 :            : 
     224                 :            :             /** Create background layer
     225                 :            : 
     226                 :            :                 This constructor will create a layer without a
     227                 :            :                 ViewLayer, i.e. one that displays directly on the
     228                 :            :                 background.
     229                 :            : 
     230                 :            :                 @param rMaxLayerBounds
     231                 :            :                 Maximal bounds of this layer, in user
     232                 :            :                 coordinates. This layer will never be larger or extend
     233                 :            :                 outside these bounds.
     234                 :            : 
     235                 :            :                 @param eFlag
     236                 :            :                 Dummy parameter, to disambiguate from normal layer
     237                 :            :                 constructor
     238                 :            :              */
     239                 :            :             Layer( const basegfx::B2DRange& rMaxLayerBounds,
     240                 :            :                    Dummy                    eFlag );
     241                 :            : 
     242                 :            :             /** Create non-background layer
     243                 :            : 
     244                 :            :                 This constructor will create a layer in front of the
     245                 :            :                 background, to contain shapes that should appear in
     246                 :            :                 front of animated objects.
     247                 :            : 
     248                 :            :                 @param rMaxLayerBounds
     249                 :            :                 Maximal bounds of this layer, in user
     250                 :            :                 coordinates. This layer will never be larger or extend
     251                 :            :                 outside these bounds.
     252                 :            :              */
     253                 :            :             explicit Layer( const basegfx::B2DRange& rMaxLayerBounds );
     254                 :            : 
     255                 :          0 :             struct ViewEntry
     256                 :            :             {
     257                 :          0 :                 ViewEntry( const ViewSharedPtr&      rView,
     258                 :            :                            const ViewLayerSharedPtr& rViewLayer ) :
     259                 :            :                     mpView( rView ),
     260                 :          0 :                     mpViewLayer( rViewLayer )
     261                 :          0 :                 {}
     262                 :            : 
     263                 :            :                 ViewSharedPtr      mpView;
     264                 :            :                 ViewLayerSharedPtr mpViewLayer;
     265                 :            : 
     266                 :            :                 // for generic algo access (which needs actual functions)
     267                 :          0 :                 const ViewSharedPtr&      getView() const { return mpView; }
     268                 :          0 :                 const ViewLayerSharedPtr& getViewLayer() const { return mpViewLayer; }
     269                 :            :             };
     270                 :            : 
     271                 :            :             typedef ::std::vector< ViewEntry > ViewEntryVector;
     272                 :            : 
     273                 :            :             ViewEntryVector            maViewEntries;
     274                 :            :             basegfx::B2DPolyRange      maUpdateAreas;
     275                 :            :             basegfx::B2DRange          maBounds;
     276                 :            :             basegfx::B2DRange          maNewBounds;
     277                 :            :             const basegfx::B2DRange    maMaxBounds;       // maBounds is clipped against this
     278                 :            :             bool                       mbBoundsDirty;     // true, if view layers need resize
     279                 :            :             bool                       mbBackgroundLayer; // true, if this
     280                 :            :                                                           // layer is the
     281                 :            :                                                           // special
     282                 :            :                                                           // background layer
     283                 :            :             bool                       mbClipSet; // true, if beginUpdate set a clip
     284                 :            :         };
     285                 :            : 
     286                 :            :         typedef ::boost::shared_ptr< Layer >    LayerSharedPtr;
     287                 :            :         typedef ::boost::weak_ptr< Layer >      LayerWeakPtr;
     288                 :            :         typedef ::std::vector< LayerSharedPtr > LayerVector;
     289                 :            : 
     290                 :            :     }
     291                 :            : }
     292                 :            : 
     293                 :            : #endif /* INCLUDED_SLIDESHOW_LAYER_HXX */
     294                 :            : 
     295                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10