LCOV - code coverage report
Current view: top level - slideshow/source/engine/transitions - combtransition.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 48 0.0 %
Date: 2014-04-14 Functions: 0 6 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 <basegfx/polygon/b2dpolygon.hxx>
      23             : #include <basegfx/polygon/b2dpolygontools.hxx>
      24             : #include <basegfx/matrix/b2dhommatrix.hxx>
      25             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      26             : 
      27             : #include <cppcanvas/spritecanvas.hxx>
      28             : 
      29             : #include "combtransition.hxx"
      30             : 
      31             : #include <boost/bind.hpp>
      32             : 
      33             : 
      34             : namespace slideshow {
      35             : namespace internal {
      36             : 
      37             : namespace {
      38             : 
      39           0 : basegfx::B2DPolyPolygon createClipPolygon(
      40             :     const ::basegfx::B2DVector& rDirection,
      41             :     const ::basegfx::B2DSize& rSlideSize,
      42             :     int nNumStrips, int nOffset )
      43             : {
      44             :     // create clip polygon in standard orientation (will later
      45             :     // be rotated to match direction vector)
      46           0 :     ::basegfx::B2DPolyPolygon aClipPoly;
      47             : 
      48             :     // create nNumStrips/2 vertical strips
      49           0 :     for( int i=nOffset; i<nNumStrips; i+=2 )
      50             :     {
      51             :         aClipPoly.append(
      52             :             ::basegfx::tools::createPolygonFromRect(
      53             :                 ::basegfx::B2DRectangle( double(i)/nNumStrips, 0.0,
      54           0 :                                          double(i+1)/nNumStrips, 1.0) ) );
      55             : 
      56             :     }
      57             : 
      58             :     // rotate polygons, such that the strips are parallel to
      59             :     // the given direction vector
      60           0 :     const ::basegfx::B2DVector aUpVec(0.0, 1.0);
      61           0 :     basegfx::B2DHomMatrix aMatrix(basegfx::tools::createRotateAroundPoint(0.5, 0.5, aUpVec.angle( rDirection )));
      62             : 
      63             :     // blow up clip polygon to slide size
      64             :     aMatrix.scale( rSlideSize.getX(),
      65           0 :                    rSlideSize.getY() );
      66             : 
      67           0 :     aClipPoly.transform( aMatrix );
      68             : 
      69           0 :     return aClipPoly;
      70             : }
      71             : 
      72             : }
      73             : 
      74           0 : CombTransition::CombTransition(
      75             :     boost::optional<SlideSharedPtr> const & leavingSlide,
      76             :     const SlideSharedPtr&                   pEnteringSlide,
      77             :     const SoundPlayerSharedPtr&             pSoundPlayer,
      78             :     const UnoViewContainer&                 rViewContainer,
      79             :     ScreenUpdater&                          rScreenUpdater,
      80             :     EventMultiplexer&                       rEventMultiplexer,
      81             :     const ::basegfx::B2DVector&             rPushDirection,
      82             :     sal_Int32                               nNumStripes )
      83             :     : SlideChangeBase( leavingSlide, pEnteringSlide, pSoundPlayer,
      84             :                        rViewContainer, rScreenUpdater, rEventMultiplexer,
      85             :                        false /* no leaving sprite */,
      86             :                        false /* no entering sprite */ ),
      87             :       maPushDirectionUnit( rPushDirection ),
      88           0 :       mnNumStripes( nNumStripes )
      89             : {
      90           0 : }
      91             : 
      92           0 : void CombTransition::renderComb( double           t,
      93             :                                  const ViewEntry& rViewEntry ) const
      94             : {
      95           0 :     const SlideBitmapSharedPtr& pEnteringBitmap = getEnteringBitmap(rViewEntry);
      96           0 :     const cppcanvas::CanvasSharedPtr pCanvas_ = rViewEntry.mpView->getCanvas();
      97             : 
      98           0 :     if( !pEnteringBitmap || !pCanvas_ )
      99           0 :         return;
     100             : 
     101             :     // calc bitmap offsets. The enter/leaving bitmaps are only
     102             :     // as large as the actual slides. For scaled-down
     103             :     // presentations, we have to move the left, top edge of
     104             :     // those bitmaps to the actual position, governed by the
     105             :     // given view transform. The aBitmapPosPixel local
     106             :     // variable is already in device coordinate space
     107             :     // (i.e. pixel).
     108             : 
     109             :     // TODO(F2): Properly respect clip here. Might have to be transformed, too.
     110           0 :     const basegfx::B2DHomMatrix viewTransform( rViewEntry.mpView->getTransformation() );
     111           0 :     const basegfx::B2DPoint pageOrigin( viewTransform * basegfx::B2DPoint() );
     112             : 
     113             :     // change transformation on cloned canvas to be in
     114             :     // device pixel
     115           0 :     cppcanvas::CanvasSharedPtr pCanvas( pCanvas_->clone() );
     116           0 :     basegfx::B2DPoint p;
     117             : 
     118             :     // TODO(Q2): Use basegfx bitmaps here
     119             :     // TODO(F1): SlideBitmap is not fully portable between different canvases!
     120             : 
     121             :     const basegfx::B2DSize enteringSizePixel(
     122           0 :         getEnteringSlideSizePixel( rViewEntry.mpView) );
     123             : 
     124             :     const basegfx::B2DVector aPushDirection = basegfx::B2DVector(
     125           0 :         enteringSizePixel * maPushDirectionUnit );
     126             :     const basegfx::B2DPolyPolygon aClipPolygon1 = basegfx::B2DPolyPolygon(
     127             :         createClipPolygon( maPushDirectionUnit,
     128             :                            enteringSizePixel,
     129           0 :                            mnNumStripes, 0 ) );
     130             :     const basegfx::B2DPolyPolygon aClipPolygon2 = basegfx::B2DPolyPolygon(
     131             :         createClipPolygon( maPushDirectionUnit,
     132             :                            enteringSizePixel,
     133           0 :                            mnNumStripes, 1 ) );
     134             : 
     135           0 :     SlideBitmapSharedPtr const & pLeavingBitmap = getLeavingBitmap(rViewEntry);
     136           0 :     if( pLeavingBitmap )
     137             :     {
     138             :         // render odd strips:
     139           0 :         pLeavingBitmap->clip( aClipPolygon1 );
     140             :         // don't modify bitmap object (no move!):
     141           0 :         p = basegfx::B2DPoint( pageOrigin + (t * aPushDirection) );
     142           0 :         pCanvas->setTransformation(basegfx::tools::createTranslateB2DHomMatrix(p.getX(), p.getY()));
     143           0 :         pLeavingBitmap->draw( pCanvas );
     144             : 
     145             :         // render even strips:
     146           0 :         pLeavingBitmap->clip( aClipPolygon2 );
     147             :         // don't modify bitmap object (no move!):
     148           0 :         p = basegfx::B2DPoint( pageOrigin - (t * aPushDirection) );
     149           0 :         pCanvas->setTransformation(basegfx::tools::createTranslateB2DHomMatrix(p.getX(), p.getY()));
     150           0 :         pLeavingBitmap->draw( pCanvas );
     151             :     }
     152             : 
     153             :     // TODO(Q2): Use basegfx bitmaps here
     154             :     // TODO(F1): SlideBitmap is not fully portable between different canvases!
     155             : 
     156             :     // render odd strips:
     157           0 :     pEnteringBitmap->clip( aClipPolygon1 );
     158             :     // don't modify bitmap object (no move!):
     159           0 :     p = basegfx::B2DPoint( pageOrigin + ((t - 1.0) * aPushDirection) );
     160           0 :     pCanvas->setTransformation(basegfx::tools::createTranslateB2DHomMatrix(p.getX(), p.getY()));
     161           0 :     pEnteringBitmap->draw( pCanvas );
     162             : 
     163             :     // render even strips:
     164           0 :     pEnteringBitmap->clip( aClipPolygon2 );
     165             :     // don't modify bitmap object (no move!):
     166           0 :     p = basegfx::B2DPoint( pageOrigin + ((1.0 - t) * aPushDirection) );
     167           0 :     pCanvas->setTransformation(basegfx::tools::createTranslateB2DHomMatrix(p.getX(), p.getY()));
     168           0 :     pEnteringBitmap->draw( pCanvas );
     169             : }
     170             : 
     171           0 : bool CombTransition::operator()( double t )
     172             : {
     173             :     std::for_each( beginViews(),
     174             :                    endViews(),
     175             :                    boost::bind( &CombTransition::renderComb,
     176             :                                 this,
     177             :                                 t,
     178           0 :                                 _1 ));
     179             : 
     180           0 :     getScreenUpdater().notifyUpdate();
     181             : 
     182           0 :     return true;
     183             : }
     184             : 
     185             : } // namespace internal
     186           0 : } // namespace presentation
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10