LCOV - code coverage report
Current view: top level - canvas/source/cairo - cairo_canvascustomsprite.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 51 2.0 %
Date: 2014-11-03 Functions: 2 15 13.3 %
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 <cppuhelper/supportsservice.hxx>
      23             : #include <tools/diagnose_ex.h>
      24             : 
      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             :         SAL_INFO( "canvas.cairo", "sprite size: " << ::canvas::tools::roundUp( rSpriteSize.Width ) << ", " << ::canvas::tools::roundUp( rSpriteSize.Height ));
      51             : 
      52           0 :         mpBufferSurface = mpSpriteCanvas->createSurface( maSize );
      53             : 
      54             :         maCanvasHelper.init( maSize,
      55           0 :                              *rRefDevice,
      56           0 :                              rRefDevice.get() );
      57           0 :         maCanvasHelper.setSurface( mpBufferSurface, true );
      58             : 
      59             :         maSpriteHelper.init( rSpriteSize,
      60           0 :                              rRefDevice );
      61           0 :         maSpriteHelper.setSurface( mpBufferSurface );
      62             : 
      63             :         // clear sprite to 100% transparent
      64           0 :         maCanvasHelper.clear();
      65           0 :     }
      66             : 
      67           0 :     void CanvasCustomSprite::disposeThis()
      68             :     {
      69           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      70             : 
      71           0 :         mpSpriteCanvas.clear();
      72           0 :         mpBufferSurface.reset();
      73             : 
      74             :         // forward to parent
      75           0 :         CanvasCustomSpriteBaseT::disposeThis();
      76           0 :     }
      77             : 
      78           0 :     void CanvasCustomSprite::redraw( const CairoSharedPtr& pCairo,
      79             :                                      bool                  bBufferedUpdate ) const
      80             :     {
      81           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      82             : 
      83           0 :         redraw( pCairo, maSpriteHelper.getPosPixel(), bBufferedUpdate );
      84           0 :     }
      85             : 
      86           0 :     void CanvasCustomSprite::redraw( const CairoSharedPtr&      pCairo,
      87             :                                      const ::basegfx::B2DPoint& rOrigOutputPos,
      88             :                                      bool                       bBufferedUpdate ) const
      89             :     {
      90           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      91             : 
      92             :         maSpriteHelper.redraw( pCairo,
      93             :                                rOrigOutputPos,
      94             :                                mbSurfaceDirty,
      95           0 :                                bBufferedUpdate );
      96             : 
      97           0 :         mbSurfaceDirty = false;
      98           0 :     }
      99             : 
     100           0 :     bool CanvasCustomSprite::repaint( const SurfaceSharedPtr&       pSurface,
     101             :                                       const rendering::ViewState&   viewState,
     102             :                                       const rendering::RenderState& renderState )
     103             :     {
     104           0 :         return maCanvasHelper.repaint( pSurface, viewState, renderState );
     105             :     }
     106             : 
     107           0 :     SurfaceSharedPtr CanvasCustomSprite::getSurface()
     108             :     {
     109           0 :         return mpBufferSurface;
     110             :     }
     111             : 
     112           0 :     SurfaceSharedPtr CanvasCustomSprite::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
     113             :     {
     114           0 :         return mpSpriteCanvas->createSurface(rSize,aContent);
     115             :     }
     116             : 
     117           0 :     SurfaceSharedPtr CanvasCustomSprite::createSurface( ::Bitmap& rBitmap )
     118             :     {
     119           0 :         return mpSpriteCanvas->createSurface(rBitmap);
     120             :     }
     121             : 
     122           0 :     SurfaceSharedPtr CanvasCustomSprite::changeSurface( bool bHasAlpha, bool bCopyContent )
     123             :     {
     124           0 :         if( !bHasAlpha && !bCopyContent )
     125             :         {
     126             :             SAL_INFO( "canvas.cairo", "replacing sprite background surface");
     127             : 
     128           0 :             mpBufferSurface = mpSpriteCanvas->createSurface( maSize, CAIRO_CONTENT_COLOR );
     129           0 :             maSpriteHelper.setSurface( mpBufferSurface );
     130             : 
     131           0 :             return mpBufferSurface;
     132             :         }
     133             : 
     134           0 :         return SurfaceSharedPtr();
     135             :     }
     136             : 
     137           0 :     OutputDevice* CanvasCustomSprite::getOutputDevice()
     138             :     {
     139           0 :         return mpSpriteCanvas->getOutputDevice();
     140             :     }
     141             : 
     142           0 :     OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException, std::exception )
     143             :     {
     144           0 :         return OUString( "CairoCanvas.CanvasCustomSprite" );
     145             :     }
     146             : 
     147           0 :     sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const OUString& ServiceName ) throw( uno::RuntimeException, std::exception )
     148             :     {
     149           0 :         return cppu::supportsService( this, ServiceName );
     150             :     }
     151             : 
     152           0 :     uno::Sequence< OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames()  throw( uno::RuntimeException, std::exception )
     153             :     {
     154           0 :         uno::Sequence< OUString > aRet(1);
     155           0 :         aRet[0] = "com.sun.star.rendering.CanvasCustomSprite";
     156             : 
     157           0 :         return aRet;
     158             :     }
     159           6 : }
     160             : 
     161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10