LCOV - code coverage report
Current view: top level - include/canvas/base - spritecanvasbase.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 47 0.0 %
Date: 2014-04-14 Functions: 0 24 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             : #ifndef INCLUDED_CANVAS_BASE_SPRITECANVASBASE_HXX
      21             : #define INCLUDED_CANVAS_BASE_SPRITECANVASBASE_HXX
      22             : 
      23             : #include <rtl/ref.hxx>
      24             : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
      25             : #include <com/sun/star/rendering/InterpolationMode.hpp>
      26             : #include <canvas/base/integerbitmapbase.hxx>
      27             : #include <canvas/spriteredrawmanager.hxx>
      28             : 
      29             : 
      30             : namespace canvas
      31             : {
      32             :     /** Helper template to handle XIntegerBitmap method forwarding to
      33             :         BitmapCanvasHelper
      34             : 
      35             :         Use this helper to handle the XIntegerBitmap part of your
      36             :         implementation.
      37             : 
      38             :         @tpl Base
      39             :         Base class to use, most probably one of the
      40             :         WeakComponentImplHelperN templates with the appropriate
      41             :         interfaces. At least XSpriteCanvas and SpriteSurface should be
      42             :         among them (why else would you use this template, then?). Base
      43             :         class must have an Base( const Mutex& ) constructor (like the
      44             :         WeakComponentImplHelperN templates have).
      45             : 
      46             :         @tpl CanvasHelper
      47             :         Canvas helper implementation for the backend in question
      48             : 
      49             :         @tpl Mutex
      50             :         Lock strategy to use. Defaults to using the
      51             :         OBaseMutex-provided lock.  Everytime one of the methods is
      52             :         entered, an object of type Mutex is created with m_aMutex as
      53             :         the sole parameter, and destroyed again when the method scope
      54             :         is left.
      55             : 
      56             :         @tpl UnambiguousBase
      57             :         Optional unambiguous base class for XInterface of Base. It's
      58             :         sometimes necessary to specify this parameter, e.g. if Base
      59             :         derives from multiple UNO interface (were each provides its
      60             :         own version of XInterface, making the conversion ambiguous)
      61             : 
      62             :         @see CanvasBase for further contractual requirements towards
      63             :         the CanvasHelper type, and some examples.
      64             :      */
      65             :     template< class Base,
      66             :               class CanvasHelper,
      67             :               class Mutex=::osl::MutexGuard,
      68           0 :               class UnambiguousBase=::com::sun::star::uno::XInterface > class SpriteCanvasBase :
      69             :         public IntegerBitmapBase< BitmapCanvasBase<Base, CanvasHelper, Mutex, UnambiguousBase> >
      70             :     {
      71             :     public:
      72             :         typedef IntegerBitmapBase< BitmapCanvasBase<Base, CanvasHelper, Mutex, UnambiguousBase> > BaseType;
      73             :         typedef ::rtl::Reference< SpriteCanvasBase >                            Reference;
      74             : 
      75           0 :         SpriteCanvasBase() :
      76           0 :             maRedrawManager()
      77             :         {
      78           0 :         }
      79             : 
      80           0 :         virtual void disposeThis() SAL_OVERRIDE
      81             :         {
      82           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
      83             : 
      84           0 :             maRedrawManager.disposing();
      85             : 
      86             :             // pass on to base class
      87           0 :             BaseType::disposeThis();
      88           0 :         }
      89             : 
      90             :         // XSpriteCanvas
      91           0 :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromAnimation( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation ) throw (::com::sun::star::lang::IllegalArgumentException,
      92             :                                                                                                                                                                                                                                            ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
      93             :         {
      94           0 :             tools::verifyArgs(animation,
      95             :                               BOOST_CURRENT_FUNCTION,
      96           0 :                               static_cast< typename BaseType::UnambiguousBaseType* >(this));
      97             : 
      98           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
      99             : 
     100           0 :             return BaseType::maCanvasHelper.createSpriteFromAnimation(animation);
     101             :         }
     102             : 
     103           0 :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromBitmaps( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > >& animationBitmaps,
     104             :                                                                                                                                    sal_Int8                                                                                                           interpolationMode ) throw (::com::sun::star::lang::IllegalArgumentException,
     105             :                                                                                                                                                                                                                                                                                  ::com::sun::star::rendering::VolatileContentDestroyedException,
     106             :                                                                                                                                                                                                                                                                                  ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
     107             :         {
     108           0 :             tools::verifyArgs(animationBitmaps,
     109             :                               BOOST_CURRENT_FUNCTION,
     110           0 :                               static_cast< typename BaseType::UnambiguousBaseType* >(this));
     111           0 :             tools::verifyRange( interpolationMode,
     112             :                                 ::com::sun::star::rendering::InterpolationMode::NEAREST_NEIGHBOR,
     113           0 :                                 ::com::sun::star::rendering::InterpolationMode::BEZIERSPLINE4 );
     114             : 
     115           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
     116             : 
     117           0 :             return BaseType::maCanvasHelper.createSpriteFromBitmaps(animationBitmaps, interpolationMode);
     118             :         }
     119             : 
     120           0 :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCustomSprite > SAL_CALL createCustomSprite( const ::com::sun::star::geometry::RealSize2D& spriteSize ) throw (::com::sun::star::lang::IllegalArgumentException,
     121             :                                                                                                                                                                                               ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
     122             :         {
     123           0 :             tools::verifySpriteSize(spriteSize,
     124             :                                     BOOST_CURRENT_FUNCTION,
     125           0 :                                     static_cast< typename BaseType::UnambiguousBaseType* >(this));
     126             : 
     127           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
     128             : 
     129           0 :             return BaseType::maCanvasHelper.createCustomSprite(spriteSize);
     130             :         }
     131             : 
     132           0 :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite > SAL_CALL createClonedSprite( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original ) throw (::com::sun::star::lang::IllegalArgumentException,
     133             :                                                                                                                                                                                                                         ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE
     134             :         {
     135           0 :             tools::verifyArgs(original,
     136             :                               BOOST_CURRENT_FUNCTION,
     137           0 :                               static_cast< typename BaseType::UnambiguousBaseType* >(this));
     138             : 
     139           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
     140             : 
     141           0 :             return BaseType::maCanvasHelper.createClonedSprite(original);
     142             :         }
     143             : 
     144             :         // SpriteSurface
     145           0 :         virtual void showSprite( const Sprite::Reference& rSprite )
     146             :         {
     147             :             OSL_ASSERT( rSprite.is() );
     148             : 
     149           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
     150             : 
     151           0 :             maRedrawManager.showSprite( rSprite );
     152           0 :         }
     153             : 
     154           0 :         virtual void hideSprite( const Sprite::Reference& rSprite )
     155             :         {
     156             :             OSL_ASSERT( rSprite.is() );
     157             : 
     158           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
     159             : 
     160           0 :             maRedrawManager.hideSprite( rSprite );
     161           0 :         }
     162             : 
     163           0 :         virtual void moveSprite( const Sprite::Reference&       rSprite,
     164             :                                  const ::basegfx::B2DPoint&     rOldPos,
     165             :                                  const ::basegfx::B2DPoint&     rNewPos,
     166             :                                  const ::basegfx::B2DVector&    rSpriteSize )
     167             :         {
     168             :             OSL_ASSERT( rSprite.is() );
     169             : 
     170           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
     171             : 
     172           0 :             maRedrawManager.moveSprite( rSprite, rOldPos, rNewPos, rSpriteSize );
     173           0 :         }
     174             : 
     175           0 :         virtual void updateSprite( const Sprite::Reference&     rSprite,
     176             :                                    const ::basegfx::B2DPoint&   rPos,
     177             :                                    const ::basegfx::B2DRange&   rUpdateArea )
     178             :         {
     179             :             OSL_ASSERT( rSprite.is() );
     180             : 
     181           0 :             typename BaseType::MutexType aGuard( BaseType::m_aMutex );
     182             : 
     183           0 :             maRedrawManager.updateSprite( rSprite, rPos, rUpdateArea );
     184           0 :         }
     185             : 
     186             :     protected:
     187             :         SpriteRedrawManager maRedrawManager;
     188             :     };
     189             : }
     190             : 
     191             : #endif // INCLUDED_CANVAS_BASE_SPRITECANVASBASE_HXX
     192             : 
     193             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10