LCOV - code coverage report
Current view: top level - canvas/source/vcl - canvascustomsprite.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 41 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11