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

Generated by: LCOV version 1.10