LCOV - code coverage report
Current view: top level - cppcanvas/source/mtfrenderer - rendergraphicaction.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 44 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 102 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/rendergraphicrasterizer.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 "rendergraphicaction.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 RenderGraphicAction : public CachedPrimitiveBase
         [ #  # ][ #  # ]
      61                 :            :             {
      62                 :            :             public:
      63                 :            :                 RenderGraphicAction( const ::vcl::RenderGraphic& rRenderGraphic,
      64                 :            :                               const ::basegfx::B2DPoint& rDstPoint,
      65                 :            :                               const ::basegfx::B2DVector& rDstSize,
      66                 :            :                               const CanvasSharedPtr&,
      67                 :            :                               const OutDevState& );
      68                 :            : 
      69                 :            :                 virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
      70                 :            :                                            const Subset& rSubset ) const;
      71                 :            : 
      72                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
      73                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
      74                 :            :                                                        const Subset& rSubset ) const;
      75                 :            : 
      76                 :            :                 virtual sal_Int32 getActionCount() const;
      77                 :            : 
      78                 :            :             private:
      79                 :            :                 using Action::render;
      80                 :            :                 virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
      81                 :            :                                               const ::basegfx::B2DHomMatrix& rTransformation ) const;
      82                 :            : 
      83                 :            :                 ::vcl::RenderGraphic                    maRenderGraphic;
      84                 :            :                 uno::Reference< rendering::XBitmap >    mxBitmap;
      85                 :            :                 CanvasSharedPtr                         mpCanvas;
      86                 :            :                 rendering::RenderState                  maState;
      87                 :            :             };
      88                 :            : 
      89                 :          0 :             RenderGraphicAction::RenderGraphicAction( const ::vcl::RenderGraphic& rRenderGraphic,
      90                 :            :                                                       const ::basegfx::B2DPoint& rDstPoint,
      91                 :            :                                                       const ::basegfx::B2DVector& rDstSize,
      92                 :            :                                                       const CanvasSharedPtr& rCanvas,
      93                 :            :                                                       const OutDevState& rState ) :
      94                 :            :                 CachedPrimitiveBase( rCanvas, true ),
      95                 :            :                 maRenderGraphic( rRenderGraphic ),
      96 [ #  # ][ #  # ]:          0 :                 mpCanvas( rCanvas )
                 [ #  # ]
      97                 :            :             {
      98         [ #  # ]:          0 :                 tools::initRenderState( maState,rState );
      99                 :            : 
     100         [ #  # ]:          0 :                 const ::vcl::RenderGraphicRasterizer aRasterizer( rRenderGraphic );
     101 [ #  # ][ #  # ]:          0 :                 const BitmapEx aBmpEx( aRasterizer.Rasterize( ::vcl::unotools::sizeFromB2DSize( rDstSize ) ) );
                 [ #  # ]
     102                 :          0 :                 const Size aRasteredSizePixel( aBmpEx.GetSizePixel() );
     103                 :            : 
     104 [ #  # ][ #  # ]:          0 :                 if( aRasteredSizePixel.Width() && aRasteredSizePixel.Height() )
                 [ #  # ]
     105                 :            :                 {
     106                 :          0 :                     const ::basegfx::B2DVector aScale( rDstSize.getX() / aRasteredSizePixel.Width(),
     107                 :          0 :                                                        rDstSize.getY() / aRasteredSizePixel.Height() );
     108                 :            :                     const basegfx::B2DHomMatrix aLocalTransformation(
     109         [ #  # ]:          0 :                         basegfx::tools::createScaleTranslateB2DHomMatrix( aScale, rDstPoint)) ;
     110                 :            : 
     111         [ #  # ]:          0 :                     ::canvas::tools::appendToRenderState( maState, aLocalTransformation );
     112                 :            : 
     113                 :            :                     // correct clip (which is relative to original transform)
     114         [ #  # ]:          0 :                     tools::modifyClip( maState, rState, rCanvas, rDstPoint, &aScale, NULL );
     115                 :            : 
     116 [ #  # ][ #  # ]:          0 :                     mxBitmap = ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(), aBmpEx );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     117 [ #  # ][ #  # ]:          0 :                 }
     118                 :          0 :             }
     119                 :            : 
     120                 :          0 :             bool RenderGraphicAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
     121                 :            :                                                        const ::basegfx::B2DHomMatrix&                 rTransformation ) const
     122                 :            :             {
     123                 :            :                 RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::RenderGraphicAction::renderPrimitive()" );
     124                 :            :                 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::RenderGraphicAction: 0x%X", this );
     125                 :            : 
     126         [ #  # ]:          0 :                 if( mxBitmap.is() )
     127                 :            :                 {
     128         [ #  # ]:          0 :                     rendering::RenderState aLocalState( maState );
     129         [ #  # ]:          0 :                     ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     130                 :            : 
     131 [ #  # ][ #  # ]:          0 :                     rCachedPrimitive = mpCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
     132                 :          0 :                                                                              mpCanvas->getViewState(),
     133 [ #  # ][ #  # ]:          0 :                                                                              aLocalState );
           [ #  #  #  # ]
                 [ #  # ]
     134                 :            :                 }
     135                 :            : 
     136                 :          0 :                 return true;
     137                 :            :             }
     138                 :            : 
     139                 :          0 :             bool RenderGraphicAction::renderSubset( const ::basegfx::B2DHomMatrix&    rTransformation,
     140                 :            :                                                     const Subset&                    rSubset ) const
     141                 :            :             {
     142                 :            :                 // rendergraphic only contains a single action, fail if subset
     143                 :            :                 // requests different range
     144 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     145                 :            :                     rSubset.mnSubsetEnd != 1 )
     146                 :          0 :                     return false;
     147                 :            : 
     148                 :          0 :                 return CachedPrimitiveBase::render( rTransformation );
     149                 :            :             }
     150                 :            : 
     151                 :          0 :             ::basegfx::B2DRange RenderGraphicAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
     152                 :            :             {
     153                 :          0 :                 ::basegfx::B2DRange aRet;
     154                 :            : 
     155         [ #  # ]:          0 :                 if( mxBitmap.is() )
     156                 :            :                 {
     157         [ #  # ]:          0 :                     rendering::RenderState aLocalState( maState );
     158         [ #  # ]:          0 :                     ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     159                 :            : 
     160 [ #  # ][ #  # ]:          0 :                     geometry::IntegerSize2D aSize( mxBitmap->getSize() );
     161                 :            : 
     162                 :            :                     aRet = tools::calcDevicePixelBounds( ::basegfx::B2DRange( 0, 0, aSize.Width, aSize.Height ),
     163 [ #  # ][ #  # ]:          0 :                                                          mpCanvas->getViewState(), aLocalState );
         [ #  # ][ #  # ]
                 [ #  # ]
     164                 :            :                 }
     165                 :            : 
     166                 :          0 :                 return( aRet );
     167                 :            :             }
     168                 :            : 
     169                 :          0 :             ::basegfx::B2DRange RenderGraphicAction::getBounds( const ::basegfx::B2DHomMatrix&  rTransformation,
     170                 :            :                                                          const Subset&                  rSubset ) const
     171                 :            :             {
     172                 :            :                 // rendergraphic only contains a single action, empty bounds
     173                 :            :                 // if subset requests different range
     174 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     175                 :            :                     rSubset.mnSubsetEnd != 1 )
     176                 :          0 :                     return ::basegfx::B2DRange();
     177                 :            : 
     178                 :          0 :                 return getBounds( rTransformation );
     179                 :            :             }
     180                 :            : 
     181                 :          0 :             sal_Int32 RenderGraphicAction::getActionCount() const
     182                 :            :             {
     183                 :          0 :                 return 1;
     184                 :            :             }
     185                 :            :         }
     186                 :            : 
     187                 :          0 :         ActionSharedPtr RenderGraphicActionFactory::createRenderGraphicAction( const ::vcl::RenderGraphic& rRenderGraphic,
     188                 :            :                                                                  const ::basegfx::B2DPoint&  rDstPoint,
     189                 :            :                                                                  const ::basegfx::B2DVector& rDstSize,
     190                 :            :                                                                  const CanvasSharedPtr&      rCanvas,
     191                 :            :                                                                  const OutDevState&          rState )
     192                 :            :         {
     193                 :            :             return ActionSharedPtr( new RenderGraphicAction(rRenderGraphic,
     194                 :            :                                                      rDstPoint,
     195                 :            :                                                      rDstSize,
     196                 :            :                                                      rCanvas,
     197         [ #  # ]:          0 :                                                      rState ) );
     198                 :            :         }
     199                 :            :     }
     200                 :            : }
     201                 :            : 
     202                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10