LCOV - code coverage report
Current view: top level - cppcanvas/source/mtfrenderer - bitmapaction.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 47 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 98 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                 :            : 
      30                 :            : #include <rtl/logfile.hxx>
      31                 :            : #include <com/sun/star/rendering/XBitmap.hpp>
      32                 :            : #include <com/sun/star/rendering/RepaintResult.hpp>
      33                 :            : #include <com/sun/star/rendering/XCachedPrimitive.hpp>
      34                 :            : #include <vcl/bitmapex.hxx>
      35                 :            : #include <tools/gen.hxx>
      36                 :            : #include <vcl/canvastools.hxx>
      37                 :            : #include <canvas/canvastools.hxx>
      38                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      39                 :            : #include <basegfx/vector/b2dsize.hxx>
      40                 :            : #include <basegfx/point/b2dpoint.hxx>
      41                 :            : #include <basegfx/range/b2drange.hxx>
      42                 :            : #include <basegfx/tools/canvastools.hxx>
      43                 :            : #include <boost/utility.hpp>
      44                 :            : #include "cachedprimitivebase.hxx"
      45                 :            : #include "bitmapaction.hxx"
      46                 :            : #include "outdevstate.hxx"
      47                 :            : #include "mtftools.hxx"
      48                 :            : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      49                 :            : 
      50                 :            : 
      51                 :            : using namespace ::com::sun::star;
      52                 :            : 
      53                 :            : namespace cppcanvas
      54                 :            : {
      55                 :            :     namespace internal
      56                 :            :     {
      57                 :            :         namespace
      58                 :            :         {
      59                 :            : 
      60 [ #  # ][ #  # ]:          0 :             class BitmapAction : public CachedPrimitiveBase
                 [ #  # ]
      61                 :            :             {
      62                 :            :             public:
      63                 :            :                 BitmapAction( const ::BitmapEx&,
      64                 :            :                               const ::basegfx::B2DPoint& rDstPoint,
      65                 :            :                               const CanvasSharedPtr&,
      66                 :            :                               const OutDevState& );
      67                 :            :                 BitmapAction( const ::BitmapEx&,
      68                 :            :                               const ::basegfx::B2DPoint&  rDstPoint,
      69                 :            :                               const ::basegfx::B2DVector& rDstSize,
      70                 :            :                               const CanvasSharedPtr&,
      71                 :            :                               const OutDevState& );
      72                 :            : 
      73                 :            :                 virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
      74                 :            :                                            const Subset&                  rSubset ) const;
      75                 :            : 
      76                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
      77                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix&   rTransformation,
      78                 :            :                                                        const Subset&                    rSubset ) const;
      79                 :            : 
      80                 :            :                 virtual sal_Int32 getActionCount() const;
      81                 :            : 
      82                 :            :             private:
      83                 :            :                 using Action::render;
      84                 :            :                 virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
      85                 :            :                                               const ::basegfx::B2DHomMatrix&                 rTransformation ) const;
      86                 :            : 
      87                 :            :                 uno::Reference< rendering::XBitmap >                    mxBitmap;
      88                 :            :                 CanvasSharedPtr                                         mpCanvas;
      89                 :            :                 rendering::RenderState                                  maState;
      90                 :            :             };
      91                 :            : 
      92                 :            : 
      93                 :          0 :             BitmapAction::BitmapAction( const ::BitmapEx&          rBmpEx,
      94                 :            :                                         const ::basegfx::B2DPoint& rDstPoint,
      95                 :            :                                         const CanvasSharedPtr&     rCanvas,
      96                 :            :                                         const OutDevState&         rState ) :
      97                 :            :                 CachedPrimitiveBase( rCanvas, true ),
      98 [ #  # ][ #  # ]:          0 :                 mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
      99                 :            :                                                                 rBmpEx ) ),
     100                 :            :                 mpCanvas( rCanvas ),
     101 [ #  # ][ #  # ]:          0 :                 maState()
         [ #  # ][ #  # ]
     102                 :            :             {
     103         [ #  # ]:          0 :                 tools::initRenderState(maState,rState);
     104                 :            : 
     105                 :            :                 // Setup transformation such that the next render call is
     106                 :            :                 // moved rPoint away.
     107         [ #  # ]:          0 :                 const basegfx::B2DHomMatrix aLocalTransformation(basegfx::tools::createTranslateB2DHomMatrix(rDstPoint));
     108                 :            :                 ::canvas::tools::appendToRenderState( maState,
     109         [ #  # ]:          0 :                                                       aLocalTransformation );
     110                 :            : 
     111                 :            :                 // correct clip (which is relative to original transform)
     112                 :            :                 tools::modifyClip( maState,
     113                 :            :                                    rState,
     114                 :            :                                    rCanvas,
     115                 :            :                                    rDstPoint,
     116                 :            :                                    NULL,
     117 [ #  # ][ #  # ]:          0 :                                    NULL );
     118                 :          0 :             }
     119                 :            : 
     120                 :          0 :             BitmapAction::BitmapAction( const ::BitmapEx&           rBmpEx,
     121                 :            :                                         const ::basegfx::B2DPoint&  rDstPoint,
     122                 :            :                                         const ::basegfx::B2DVector& rDstSize,
     123                 :            :                                         const CanvasSharedPtr&      rCanvas,
     124                 :            :                                         const OutDevState&          rState      ) :
     125                 :            :                 CachedPrimitiveBase( rCanvas, true ),
     126 [ #  # ][ #  # ]:          0 :                 mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
     127                 :            :                                                                 rBmpEx ) ),
     128                 :            :                 mpCanvas( rCanvas ),
     129 [ #  # ][ #  # ]:          0 :                 maState()
         [ #  # ][ #  # ]
     130                 :            :             {
     131         [ #  # ]:          0 :                 tools::initRenderState(maState,rState);
     132                 :            : 
     133                 :            :                 // Setup transformation such that the next render call is
     134                 :            :                 // moved rPoint away, and scaled according to the ratio
     135                 :            :                 // given by src and dst size.
     136                 :          0 :                 const ::Size aBmpSize( rBmpEx.GetSizePixel() );
     137                 :            : 
     138                 :          0 :                 const ::basegfx::B2DVector aScale( rDstSize.getX() / aBmpSize.Width(),
     139                 :          0 :                                                    rDstSize.getY() / aBmpSize.Height() );
     140                 :            :                 const basegfx::B2DHomMatrix aLocalTransformation(basegfx::tools::createScaleTranslateB2DHomMatrix(
     141         [ #  # ]:          0 :                     aScale, rDstPoint));
     142         [ #  # ]:          0 :                 ::canvas::tools::appendToRenderState( maState, aLocalTransformation );
     143                 :            : 
     144                 :            :                 // correct clip (which is relative to original transform)
     145                 :            :                 tools::modifyClip( maState,
     146                 :            :                                    rState,
     147                 :            :                                    rCanvas,
     148                 :            :                                    rDstPoint,
     149                 :            :                                    &aScale,
     150 [ #  # ][ #  # ]:          0 :                                    NULL );
     151                 :          0 :             }
     152                 :            : 
     153                 :          0 :             bool BitmapAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
     154                 :            :                                                 const ::basegfx::B2DHomMatrix&                 rTransformation ) const
     155                 :            :             {
     156                 :            :                 RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::BitmapAction::renderPrimitive()" );
     157                 :            :                 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::BitmapAction: 0x%X", this );
     158                 :            : 
     159         [ #  # ]:          0 :                 rendering::RenderState aLocalState( maState );
     160         [ #  # ]:          0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     161                 :            : 
     162 [ #  # ][ #  # ]:          0 :                 rCachedPrimitive = mpCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
     163                 :          0 :                                                                          mpCanvas->getViewState(),
     164 [ #  # ][ #  # ]:          0 :                                                                          aLocalState );
         [ #  # ][ #  # ]
     165                 :            : 
     166         [ #  # ]:          0 :                 return true;
     167                 :            :             }
     168                 :            : 
     169                 :          0 :             bool BitmapAction::renderSubset( const ::basegfx::B2DHomMatrix&   rTransformation,
     170                 :            :                                              const Subset&                    rSubset ) const
     171                 :            :             {
     172                 :            :                 // bitmap only contains a single action, fail if subset
     173                 :            :                 // requests different range
     174 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     175                 :            :                     rSubset.mnSubsetEnd != 1 )
     176                 :          0 :                     return false;
     177                 :            : 
     178                 :          0 :                 return CachedPrimitiveBase::render( rTransformation );
     179                 :            :             }
     180                 :            : 
     181                 :          0 :             ::basegfx::B2DRange BitmapAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
     182                 :            :             {
     183         [ #  # ]:          0 :                 rendering::RenderState aLocalState( maState );
     184         [ #  # ]:          0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     185                 :            : 
     186 [ #  # ][ #  # ]:          0 :                 const geometry::IntegerSize2D aSize( mxBitmap->getSize() );
     187                 :            : 
     188                 :            :                 return tools::calcDevicePixelBounds( ::basegfx::B2DRange( 0,0,
     189                 :            :                                                                           aSize.Width,
     190                 :            :                                                                           aSize.Height ),
     191                 :          0 :                                                      mpCanvas->getViewState(),
     192 [ #  # ][ #  # ]:          0 :                                                      aLocalState );
         [ #  # ][ #  # ]
                 [ #  # ]
     193                 :            :             }
     194                 :            : 
     195                 :          0 :             ::basegfx::B2DRange BitmapAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
     196                 :            :                                                          const Subset&                  rSubset ) const
     197                 :            :             {
     198                 :            :                 // bitmap only contains a single action, empty bounds
     199                 :            :                 // if subset requests different range
     200 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     201                 :            :                     rSubset.mnSubsetEnd != 1 )
     202                 :          0 :                     return ::basegfx::B2DRange();
     203                 :            : 
     204                 :          0 :                 return getBounds( rTransformation );
     205                 :            :             }
     206                 :            : 
     207                 :          0 :             sal_Int32 BitmapAction::getActionCount() const
     208                 :            :             {
     209                 :          0 :                 return 1;
     210                 :            :             }
     211                 :            :         }
     212                 :            : 
     213                 :          0 :         ActionSharedPtr BitmapActionFactory::createBitmapAction( const ::BitmapEx&          rBmpEx,
     214                 :            :                                                                  const ::basegfx::B2DPoint& rDstPoint,
     215                 :            :                                                                  const CanvasSharedPtr&     rCanvas,
     216                 :            :                                                                  const OutDevState&         rState )
     217                 :            :         {
     218                 :            :             return ActionSharedPtr( new BitmapAction(rBmpEx,
     219                 :            :                                                      rDstPoint,
     220                 :            :                                                      rCanvas,
     221         [ #  # ]:          0 :                                                      rState ) );
     222                 :            :         }
     223                 :            : 
     224                 :          0 :         ActionSharedPtr BitmapActionFactory::createBitmapAction( const ::BitmapEx&           rBmpEx,
     225                 :            :                                                                  const ::basegfx::B2DPoint&  rDstPoint,
     226                 :            :                                                                  const ::basegfx::B2DVector& rDstSize,
     227                 :            :                                                                  const CanvasSharedPtr&      rCanvas,
     228                 :            :                                                                  const OutDevState&          rState )
     229                 :            :         {
     230                 :            :             return ActionSharedPtr( new BitmapAction(rBmpEx,
     231                 :            :                                                      rDstPoint,
     232                 :            :                                                      rDstSize,
     233                 :            :                                                      rCanvas,
     234         [ #  # ]:          0 :                                                      rState ) );
     235                 :            :         }
     236                 :            :     }
     237                 :            : }
     238                 :            : 
     239                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10