LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/canvas/base - canvascustomspritehelper.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 4 0.0 %

           Branch data     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 2000, 2010 Oracle and/or its affiliates.
       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                 :            : 
      29                 :            : #ifndef INCLUDED_CANVAS_CANVASCUSTOMSPRITEHELPER_HXX
      30                 :            : #define INCLUDED_CANVAS_CANVASCUSTOMSPRITEHELPER_HXX
      31                 :            : 
      32                 :            : #include <com/sun/star/rendering/XCustomSprite.hpp>
      33                 :            : #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
      34                 :            : #include <basegfx/point/b2dpoint.hxx>
      35                 :            : #include <basegfx/vector/b2dvector.hxx>
      36                 :            : #include <basegfx/range/b2drange.hxx>
      37                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      38                 :            : #include <canvas/base/spritesurface.hxx>
      39                 :            : #include <canvas/canvastoolsdllapi.h>
      40                 :            : 
      41                 :            : namespace canvas
      42                 :            : {
      43                 :            :     /* Definition of CanvasCustomSpriteHelper class */
      44                 :            : 
      45                 :            :     /** Base class for an XSprite helper implementation - to be used
      46                 :            :         in concert with CanvasCustomSpriteBase
      47                 :            :      */
      48                 :            :     class CANVASTOOLS_DLLPUBLIC CanvasCustomSpriteHelper
      49                 :            :     {
      50                 :            :     public:
      51                 :            :         CanvasCustomSpriteHelper();
      52 [ #  # ][ #  # ]:          0 :         virtual ~CanvasCustomSpriteHelper() {}
      53                 :            : 
      54                 :            :         /** Init helper
      55                 :            : 
      56                 :            :             @param rSpriteSize
      57                 :            :             Requested size of the sprite, as passed to the
      58                 :            :             XSpriteCanvas::createCustomSprite() method
      59                 :            : 
      60                 :            :             @param rOwningSpriteCanvas
      61                 :            :             The XSpriteCanvas this sprite is displayed on
      62                 :            :          */
      63                 :            :         void init( const ::com::sun::star::geometry::RealSize2D&    rSpriteSize,
      64                 :            :                    const SpriteSurface::Reference&                  rOwningSpriteCanvas );
      65                 :            : 
      66                 :            :         /** Object is being disposed, release all internal references
      67                 :            : 
      68                 :            :             @derive when overriding this method in derived classes,
      69                 :            :             <em>always</em> call the base class' method!
      70                 :            :          */
      71                 :            :         void disposing();
      72                 :            : 
      73                 :            :         // XCanvas
      74                 :            :         /// need  to call this method for XCanvas::clear(), for opacity tracking
      75                 :            :         void clearingContent( const Sprite::Reference& rSprite );
      76                 :            : 
      77                 :            :         /// need to call this method for XCanvas::drawBitmap(), for opacity tracking
      78                 :            :         void checkDrawBitmap( const Sprite::Reference&                                                          rSprite,
      79                 :            :                               const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >&   xBitmap,
      80                 :            :                               const ::com::sun::star::rendering::ViewState&                                     viewState,
      81                 :            :                               const ::com::sun::star::rendering::RenderState&                                   renderState );
      82                 :            : 
      83                 :            :         // XSprite
      84                 :            :         void setAlpha( const Sprite::Reference& rSprite,
      85                 :            :                        double                   alpha );
      86                 :            :         void move( const Sprite::Reference&                         rSprite,
      87                 :            :                    const ::com::sun::star::geometry::RealPoint2D&   aNewPos,
      88                 :            :                    const ::com::sun::star::rendering::ViewState&    viewState,
      89                 :            :                    const ::com::sun::star::rendering::RenderState&  renderState );
      90                 :            :         void transform( const Sprite::Reference&                            rSprite,
      91                 :            :                        const ::com::sun::star::geometry::AffineMatrix2D&    aTransformation );
      92                 :            :         void clip( const Sprite::Reference&                                                                 rSprite,
      93                 :            :                    const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >&   aClip );
      94                 :            :         void setPriority( const Sprite::Reference&  rSprite,
      95                 :            :                           double                    nPriority );
      96                 :            :         void show( const Sprite::Reference& rSprite );
      97                 :            :         void hide( const Sprite::Reference& rSprite );
      98                 :            : 
      99                 :            :         // Sprite
     100                 :            :         bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const;
     101                 :            :         ::basegfx::B2DPoint  getPosPixel() const;
     102                 :            :         ::basegfx::B2DVector getSizePixel() const;
     103                 :            :         ::basegfx::B2DRange  getUpdateArea() const;
     104                 :            :         double               getPriority() const;
     105                 :            : 
     106                 :            :         // redraw must be implemented by derived - non sensible default implementation
     107                 :            :         // void redraw( const Sprite::Reference& rSprite,
     108                 :            :         //              const ::basegfx::B2DPoint& rPos ) const;
     109                 :            : 
     110                 :            : 
     111                 :            :         // Helper methods for derived classes
     112                 :            :         // ----------------------------------
     113                 :            : 
     114                 :            :         /// Calc sprite update area from given raw sprite bounds
     115                 :            :         ::basegfx::B2DRange getUpdateArea( const ::basegfx::B2DRange& rUntransformedSpriteBounds ) const;
     116                 :            : 
     117                 :            :         /// Calc update area for unclipped sprite content
     118                 :            :         ::basegfx::B2DRange getFullSpriteRect() const;
     119                 :            : 
     120                 :            :         /** Returns true, if sprite content bitmap is fully opaque.
     121                 :            : 
     122                 :            :             This does not take clipping or transformation into
     123                 :            :             account, but only denotes that the sprite bitmap's alpha
     124                 :            :             channel is all 1.0
     125                 :            :          */
     126                 :          0 :         bool isContentFullyOpaque() const { return mbIsContentFullyOpaque; }
     127                 :            : 
     128                 :            :         /// Returns true, if transformation has changed since last transformUpdated() call
     129                 :            :         bool hasAlphaChanged() const { return mbAlphaDirty; }
     130                 :            : 
     131                 :            :         /// Returns true, if transformation has changed since last transformUpdated() call
     132                 :            :         bool hasPositionChanged() const { return mbPositionDirty; }
     133                 :            : 
     134                 :            :         /// Returns true, if transformation has changed since last transformUpdated() call
     135                 :          0 :         bool hasTransformChanged() const { return mbTransformDirty; }
     136                 :            : 
     137                 :            :         /// Returns true, if transformation has changed since last transformUpdated() call
     138                 :            :         bool hasClipChanged() const { return mbClipDirty; }
     139                 :            : 
     140                 :            :         /// Returns true, if transformation has changed since last transformUpdated() call
     141                 :            :         bool hasPrioChanged() const { return mbPrioDirty; }
     142                 :            : 
     143                 :            :         /// Returns true, if transformation has changed since last transformUpdated() call
     144                 :            :         bool hasVisibilityChanged() const { return mbVisibilityDirty; }
     145                 :            : 
     146                 :            :         /// Retrieve current alpha value
     147                 :          0 :         double getAlpha() const { return mfAlpha; }
     148                 :            : 
     149                 :            :         /// Retrieve current clip
     150                 :            :         const ::com::sun::star::uno::Reference<
     151                 :          0 :             ::com::sun::star::rendering::XPolyPolygon2D >& getClip() const { return mxClipPoly; }
     152                 :            : 
     153                 :          0 :         const ::basegfx::B2DHomMatrix& getTransformation() const { return maTransform; }
     154                 :            : 
     155                 :            :         /// Retrieve current activation state
     156                 :          0 :         bool isActive() const { return mbActive; }
     157                 :            : 
     158                 :            :     protected:
     159                 :            :         /** Notifies that caller is again in sync with current alph
     160                 :            : 
     161                 :            :             const, but modifies state visible to derived
     162                 :            :             classes. beware of passing this information to the
     163                 :            :             outside!
     164                 :            :          */
     165                 :            :         void alphaUpdated() const { mbAlphaDirty=false; }
     166                 :            : 
     167                 :            :         /** Notifies that caller is again in sync with current position
     168                 :            : 
     169                 :            :             const, but modifies state visible to derived
     170                 :            :             classes. beware of passing this information to the
     171                 :            :             outside!
     172                 :            :          */
     173                 :            :         void positionUpdated() const { mbPositionDirty=false; }
     174                 :            : 
     175                 :            :         /** Notifies that caller is again in sync with current transformation
     176                 :            : 
     177                 :            :             const, but modifies state visible to derived
     178                 :            :             classes. beware of passing this information to the
     179                 :            :             outside!
     180                 :            :          */
     181                 :          0 :         void transformUpdated() const { mbTransformDirty=false; }
     182                 :            : 
     183                 :            :         /** Notifies that caller is again in sync with current clip
     184                 :            : 
     185                 :            :             const, but modifies state visible to derived
     186                 :            :             classes. beware of passing this information to the
     187                 :            :             outside!
     188                 :            :          */
     189                 :            :         void clipUpdated() const { mbClipDirty=false; }
     190                 :            : 
     191                 :            :         /** Notifies that caller is again in sync with current priority
     192                 :            : 
     193                 :            :             const, but modifies state visible to derived
     194                 :            :             classes. beware of passing this information to the
     195                 :            :             outside!
     196                 :            :          */
     197                 :            :         void prioUpdated() const { mbPrioDirty=false; }
     198                 :            : 
     199                 :            :         /** Notifies that caller is again in sync with current visibility
     200                 :            : 
     201                 :            :             const, but modifies state visible to derived
     202                 :            :             classes. beware of passing this information to the
     203                 :            :             outside!
     204                 :            :          */
     205                 :            :         void visibilityUpdated() const { mbVisibilityDirty=false; }
     206                 :            : 
     207                 :            :     private:
     208                 :            :         CanvasCustomSpriteHelper( const CanvasCustomSpriteHelper& );
     209                 :            :         CanvasCustomSpriteHelper& operator=( const CanvasCustomSpriteHelper& );
     210                 :            : 
     211                 :            :         /** Called to convert an API polygon to a basegfx polygon
     212                 :            : 
     213                 :            :             @derive Needs to be provided by backend-specific code
     214                 :            :          */
     215                 :            :         virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D(
     216                 :            :             ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPoly ) const = 0;
     217                 :            : 
     218                 :            :         /** Update clip information from current state
     219                 :            : 
     220                 :            :             This method recomputes the maCurrClipBounds and
     221                 :            :             mbIsCurrClipRectangle members from the current clip and
     222                 :            :             transformation. IFF the clip changed from rectangular to
     223                 :            :             rectangular again, this method issues a sequence of
     224                 :            :             optimized SpriteSurface::updateSprite() calls.
     225                 :            : 
     226                 :            :             @return true, if SpriteSurface::updateSprite() was already
     227                 :            :             called within this method.
     228                 :            :          */
     229                 :            :         bool updateClipState( const Sprite::Reference& rSprite );
     230                 :            : 
     231                 :            :         // --------------------------------------------------------------------
     232                 :            : 
     233                 :            :         /// Owning sprite canvas
     234                 :            :         SpriteSurface::Reference                            mpSpriteCanvas;
     235                 :            : 
     236                 :            :         /** Currently active clip area.
     237                 :            : 
     238                 :            :             This member is either empty, denoting that the current
     239                 :            :             clip shows the full sprite content, or contains a
     240                 :            :             rectangular subarea of the sprite, outside of which
     241                 :            :             the sprite content is fully clipped.
     242                 :            : 
     243                 :            :             @see mbIsCurrClipRectangle
     244                 :            :          */
     245                 :            :         ::basegfx::B2DRange                                 maCurrClipBounds;
     246                 :            : 
     247                 :            :         // sprite state
     248                 :            :         ::basegfx::B2DPoint                                 maPosition;
     249                 :            :         ::basegfx::B2DVector                                maSize;
     250                 :            :         ::basegfx::B2DHomMatrix                             maTransform;
     251                 :            :         ::com::sun::star::uno::Reference<
     252                 :            :               ::com::sun::star::rendering::XPolyPolygon2D > mxClipPoly;
     253                 :            :         double                                              mfPriority;
     254                 :            :         double                                              mfAlpha;
     255                 :            :         bool                                                mbActive; // true, if not hidden
     256                 :            : 
     257                 :            :         /** If true, denotes that the current sprite clip is a true
     258                 :            :             rectangle, i.e. maCurrClipBounds <em>exactly</em>
     259                 :            :             describes the visible area of the sprite.
     260                 :            : 
     261                 :            :             @see maCurrClipBounds
     262                 :            :          */
     263                 :            :         bool                                                mbIsCurrClipRectangle;
     264                 :            : 
     265                 :            :         /** Redraw speedup.
     266                 :            : 
     267                 :            :             When true, this flag denotes that the current sprite
     268                 :            :             content is fully opaque, thus, that blits to the screen do
     269                 :            :             neither have to take alpha into account, nor prepare any
     270                 :            :             background for the sprite area.
     271                 :            :          */
     272                 :            :         mutable bool                                        mbIsContentFullyOpaque;
     273                 :            : 
     274                 :            :         /// True, iff mfAlpha has changed
     275                 :            :         mutable bool                                        mbAlphaDirty;
     276                 :            : 
     277                 :            :         /// True, iff maPosition has changed
     278                 :            :         mutable bool                                        mbPositionDirty;
     279                 :            : 
     280                 :            :         /// True, iff maTransform has changed
     281                 :            :         mutable bool                                        mbTransformDirty;
     282                 :            : 
     283                 :            :         /// True, iff mxClipPoly has changed
     284                 :            :         mutable bool                                        mbClipDirty;
     285                 :            : 
     286                 :            :         /// True, iff mnPriority has changed
     287                 :            :         mutable bool                                        mbPrioDirty;
     288                 :            : 
     289                 :            :         /// True, iff mbActive has changed
     290                 :            :         mutable bool                                        mbVisibilityDirty;
     291                 :            :     };
     292                 :            : }
     293                 :            : 
     294                 :            : #endif /* INCLUDED_CANVAS_CANVASCUSTOMSPRITEHELPER_HXX */
     295                 :            : 
     296                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10