LCOV - code coverage report
Current view: top level - libreoffice/canvas/source/cairo - cairo_canvascustomsprite.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 51 0.0 %
Date: 2012-12-27 Functions: 0 15 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             : #include <canvas/debug.hxx>
      21             : #include <canvas/verbosetrace.hxx>
      22             : #include <tools/diagnose_ex.h>
      23             : 
      24             : #include <rtl/logfile.hxx>
      25             : #include <rtl/math.hxx>
      26             : 
      27             : #include <canvas/canvastools.hxx>
      28             : 
      29             : #include <basegfx/matrix/b2dhommatrix.hxx>
      30             : #include <basegfx/point/b2dpoint.hxx>
      31             : 
      32             : #include "cairo_canvascustomsprite.hxx"
      33             : #include "cairo_spritecanvas.hxx"
      34             : 
      35             : 
      36             : using namespace ::cairo;
      37             : using namespace ::com::sun::star;
      38             : 
      39             : namespace cairocanvas
      40             : {
      41           0 :     CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D&   rSpriteSize,
      42             :                                             const SpriteCanvasRef&                          rRefDevice ) :
      43             :         mpSpriteCanvas( rRefDevice ),
      44             :         maSize( ::canvas::tools::roundUp( rSpriteSize.Width ),
      45           0 :                 ::canvas::tools::roundUp( rSpriteSize.Height ) )
      46             :     {
      47           0 :         ENSURE_OR_THROW( rRefDevice.get(),
      48             :                           "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
      49             : 
      50             :         OSL_TRACE("sprite size: %d, %d",
      51             :                   ::canvas::tools::roundUp( rSpriteSize.Width ),
      52             :                   ::canvas::tools::roundUp( rSpriteSize.Height ));
      53             : 
      54           0 :         mpBufferSurface = mpSpriteCanvas->createSurface( maSize );
      55             : 
      56             :         maCanvasHelper.init( maSize,
      57           0 :                              *rRefDevice,
      58           0 :                              rRefDevice.get() );
      59           0 :         maCanvasHelper.setSurface( mpBufferSurface, true );
      60             : 
      61             :         maSpriteHelper.init( rSpriteSize,
      62           0 :                              rRefDevice );
      63           0 :         maSpriteHelper.setSurface( mpBufferSurface );
      64             : 
      65             :         // clear sprite to 100% transparent
      66           0 :         maCanvasHelper.clear();
      67           0 :     }
      68             : 
      69           0 :     void CanvasCustomSprite::disposeThis()
      70             :     {
      71           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      72             : 
      73           0 :         mpSpriteCanvas.clear();
      74           0 :         mpBufferSurface.reset();
      75             : 
      76             :         // forward to parent
      77           0 :         CanvasCustomSpriteBaseT::disposeThis();
      78           0 :     }
      79             : 
      80           0 :     void CanvasCustomSprite::redraw( const CairoSharedPtr& pCairo,
      81             :                                      bool                  bBufferedUpdate ) const
      82             :     {
      83           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      84             : 
      85           0 :         redraw( pCairo, maSpriteHelper.getPosPixel(), bBufferedUpdate );
      86           0 :     }
      87             : 
      88           0 :     void CanvasCustomSprite::redraw( const CairoSharedPtr&      pCairo,
      89             :                                      const ::basegfx::B2DPoint& rOrigOutputPos,
      90             :                                      bool                       bBufferedUpdate ) const
      91             :     {
      92           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      93             : 
      94             :         maSpriteHelper.redraw( pCairo,
      95             :                                rOrigOutputPos,
      96             :                                mbSurfaceDirty,
      97           0 :                                bBufferedUpdate );
      98             : 
      99           0 :         mbSurfaceDirty = false;
     100           0 :     }
     101             : 
     102           0 :     bool CanvasCustomSprite::repaint( const SurfaceSharedPtr&       pSurface,
     103             :                                       const rendering::ViewState&   viewState,
     104             :                                       const rendering::RenderState& renderState )
     105             :     {
     106           0 :         return maCanvasHelper.repaint( pSurface, viewState, renderState );
     107             :     }
     108             : 
     109           0 :     SurfaceSharedPtr CanvasCustomSprite::getSurface()
     110             :     {
     111           0 :         return mpBufferSurface;
     112             :     }
     113             : 
     114           0 :     SurfaceSharedPtr CanvasCustomSprite::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
     115             :     {
     116           0 :         return mpSpriteCanvas->createSurface(rSize,aContent);
     117             :     }
     118             : 
     119           0 :     SurfaceSharedPtr CanvasCustomSprite::createSurface( ::Bitmap& rBitmap )
     120             :     {
     121           0 :         return mpSpriteCanvas->createSurface(rBitmap);
     122             :     }
     123             : 
     124           0 :     SurfaceSharedPtr CanvasCustomSprite::changeSurface( bool bHasAlpha, bool bCopyContent )
     125             :     {
     126           0 :         if( !bHasAlpha && !bCopyContent )
     127             :         {
     128             :             OSL_TRACE("replacing sprite background surface");
     129             : 
     130           0 :             mpBufferSurface = mpSpriteCanvas->createSurface( maSize, CAIRO_CONTENT_COLOR );
     131           0 :             maSpriteHelper.setSurface( mpBufferSurface );
     132             : 
     133           0 :             return mpBufferSurface;
     134             :         }
     135             : 
     136           0 :         return SurfaceSharedPtr();
     137             :     }
     138             : 
     139           0 :     OutputDevice* CanvasCustomSprite::getOutputDevice()
     140             :     {
     141           0 :         return mpSpriteCanvas->getOutputDevice();
     142             :     }
     143             : 
     144             : #define IMPLEMENTATION_NAME "CairoCanvas.CanvasCustomSprite"
     145             : #define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite"
     146             : 
     147           0 :     OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException )
     148             :     {
     149           0 :         return OUString( IMPLEMENTATION_NAME );
     150             :     }
     151             : 
     152           0 :     sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const OUString& ServiceName ) throw( uno::RuntimeException )
     153             :     {
     154           0 :         return ServiceName == SERVICE_NAME;
     155             :     }
     156             : 
     157           0 :     uno::Sequence< OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames()  throw( uno::RuntimeException )
     158             :     {
     159           0 :         uno::Sequence< OUString > aRet(1);
     160           0 :         aRet[0] = SERVICE_NAME;
     161             : 
     162           0 :         return aRet;
     163             :     }
     164           0 : }
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10