LCOV - code coverage report
Current view: top level - canvas/source/vcl - canvascustomsprite.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 41 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                 :            :  *
       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 <canvas/debug.hxx>
      31                 :            : #include <tools/diagnose_ex.h>
      32                 :            : #include <canvas/verbosetrace.hxx>
      33                 :            : 
      34                 :            : #include <rtl/math.hxx>
      35                 :            : 
      36                 :            : #include <vcl/outdev.hxx>
      37                 :            : #include <vcl/bitmap.hxx>
      38                 :            : #include <vcl/alpha.hxx>
      39                 :            : #include <vcl/bitmapex.hxx>
      40                 :            : #include <vcl/canvastools.hxx>
      41                 :            : 
      42                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      43                 :            : #include <basegfx/point/b2dpoint.hxx>
      44                 :            : #include <basegfx/tools/canvastools.hxx>
      45                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      46                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      47                 :            : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      48                 :            : #include <basegfx/numeric/ftools.hxx>
      49                 :            : 
      50                 :            : #include <canvas/canvastools.hxx>
      51                 :            : 
      52                 :            : #include "canvascustomsprite.hxx"
      53                 :            : 
      54                 :            : 
      55                 :            : using namespace ::com::sun::star;
      56                 :            : 
      57                 :            : 
      58                 :            : namespace vclcanvas
      59                 :            : {
      60                 :            : 
      61                 :          0 :     CanvasCustomSprite::CanvasCustomSprite( const geometry::RealSize2D&               rSpriteSize,
      62                 :            :                                             rendering::XGraphicDevice&                rDevice,
      63                 :            :                                             const ::canvas::SpriteSurface::Reference& rOwningSpriteCanvas,
      64                 :            :                                             const OutDevProviderSharedPtr&            rOutDevProvider,
      65                 :          0 :                                             bool                                      bShowSpriteBounds )
      66                 :            :     {
      67                 :          0 :         ENSURE_OR_THROW( rOwningSpriteCanvas.get() &&
      68                 :            :                          rOutDevProvider,
      69                 :            :                          "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
      70                 :            : 
      71                 :            :         // setup back buffer
      72                 :            :         // -----------------
      73                 :            : 
      74                 :            :         const ::Size aSize(
      75                 :            :             static_cast<sal_Int32>( ::std::max( 1.0,
      76                 :          0 :                                                 ceil( rSpriteSize.Width ))),  // round up to nearest int,
      77                 :            :                                                                               // enforce sprite to have at
      78                 :            :                                                                                // least (1,1) pixel size
      79                 :            :             static_cast<sal_Int32>( ::std::max( 1.0,
      80                 :          0 :                                                 ceil( rSpriteSize.Height ))) );
      81                 :            : 
      82                 :            :         // create content backbuffer in screen depth
      83                 :          0 :         BackBufferSharedPtr pBackBuffer( new BackBuffer( rOutDevProvider->getOutDev() ) );
      84                 :          0 :         pBackBuffer->setSize( aSize );
      85                 :            : 
      86                 :            :         // create mask backbuffer, with one bit color depth
      87                 :          0 :         BackBufferSharedPtr pBackBufferMask( new BackBuffer( rOutDevProvider->getOutDev(),
      88                 :          0 :                                                              true ) );
      89                 :          0 :         pBackBufferMask->setSize( aSize );
      90                 :            : 
      91                 :            :         // TODO(F1): Implement alpha vdev (could prolly enable
      92                 :            :         // antialiasing again, then)
      93                 :            : 
      94                 :            :         // disable font antialiasing (causes ugly shadows otherwise)
      95                 :          0 :         pBackBuffer->getOutDev().SetAntialiasing( ANTIALIASING_DISABLE_TEXT );
      96                 :          0 :         pBackBufferMask->getOutDev().SetAntialiasing( ANTIALIASING_DISABLE_TEXT );
      97                 :            : 
      98                 :            :         // set mask vdev drawmode, such that everything is painted
      99                 :            :         // black. That leaves us with a binary image, white for
     100                 :            :         // background, black for painted content
     101                 :          0 :         pBackBufferMask->getOutDev().SetDrawMode( DRAWMODE_BLACKLINE | DRAWMODE_BLACKFILL | DRAWMODE_BLACKTEXT |
     102                 :          0 :                                                   DRAWMODE_BLACKGRADIENT | DRAWMODE_BLACKBITMAP );
     103                 :            : 
     104                 :            : 
     105                 :            :         // setup canvas helper
     106                 :            :         // -------------------
     107                 :            : 
     108                 :            :         // always render into back buffer, don't preserve state (it's
     109                 :            :         // our private VDev, after all), have notion of alpha
     110                 :            :         maCanvasHelper.init( rDevice,
     111                 :            :                              pBackBuffer,
     112                 :            :                              false,
     113                 :          0 :                              true );
     114                 :          0 :         maCanvasHelper.setBackgroundOutDev( pBackBufferMask );
     115                 :            : 
     116                 :            : 
     117                 :            :         // setup sprite helper
     118                 :            :         // -------------------
     119                 :            : 
     120                 :            :         maSpriteHelper.init( rSpriteSize,
     121                 :            :                              rOwningSpriteCanvas,
     122                 :            :                              pBackBuffer,
     123                 :            :                              pBackBufferMask,
     124                 :          0 :                              bShowSpriteBounds );
     125                 :            : 
     126                 :            :         // clear sprite to 100% transparent
     127                 :          0 :         maCanvasHelper.clear();
     128                 :          0 :     }
     129                 :            : 
     130                 :            : #define IMPLEMENTATION_NAME "VCLCanvas.CanvasCustomSprite"
     131                 :            : #define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite"
     132                 :            : 
     133                 :          0 :     ::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException )
     134                 :            :     {
     135                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
     136                 :            :     }
     137                 :            : 
     138                 :          0 :     sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
     139                 :            :     {
     140                 :          0 :         return ServiceName == SERVICE_NAME;
     141                 :            :     }
     142                 :            : 
     143                 :          0 :     uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames()  throw( uno::RuntimeException )
     144                 :            :     {
     145                 :          0 :         uno::Sequence< ::rtl::OUString > aRet(1);
     146                 :          0 :         aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
     147                 :            : 
     148                 :          0 :         return aRet;
     149                 :            :     }
     150                 :            : 
     151                 :            :     // Sprite
     152                 :          0 :     void CanvasCustomSprite::redraw( OutputDevice& rOutDev,
     153                 :            :                                      bool          bBufferedUpdate ) const
     154                 :            :     {
     155                 :          0 :         SolarMutexGuard aGuard;
     156                 :            : 
     157                 :          0 :         redraw( rOutDev, maSpriteHelper.getPosPixel(), bBufferedUpdate );
     158                 :          0 :     }
     159                 :            : 
     160                 :          0 :     void CanvasCustomSprite::redraw( OutputDevice&              rOutDev,
     161                 :            :                                      const ::basegfx::B2DPoint& rOrigOutputPos,
     162                 :            :                                      bool                       bBufferedUpdate ) const
     163                 :            :     {
     164                 :          0 :         SolarMutexGuard aGuard;
     165                 :            : 
     166                 :            :         maSpriteHelper.redraw( rOutDev,
     167                 :            :                                rOrigOutputPos,
     168                 :            :                                mbSurfaceDirty,
     169                 :          0 :                                bBufferedUpdate );
     170                 :            : 
     171                 :          0 :         mbSurfaceDirty = false;
     172                 :          0 :     }
     173                 :            : 
     174                 :          0 :     bool CanvasCustomSprite::repaint( const GraphicObjectSharedPtr& rGrf,
     175                 :            :                                       const rendering::ViewState&   viewState,
     176                 :            :                                       const rendering::RenderState& renderState,
     177                 :            :                                       const ::Point&                rPt,
     178                 :            :                                       const ::Size&                 rSz,
     179                 :            :                                       const GraphicAttr&            rAttr ) const
     180                 :            :     {
     181                 :          0 :         SolarMutexGuard aGuard;
     182                 :            : 
     183                 :          0 :         mbSurfaceDirty = true;
     184                 :            : 
     185                 :          0 :         return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
     186                 :            :     }
     187                 :            : 
     188                 :          0 : }
     189                 :            : 
     190                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10