LCOV - code coverage report
Current view: top level - libreoffice/canvas/source/vcl - spritedevicehelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 48 0.0 %
Date: 2012-12-27 Functions: 0 14 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 <canvas/canvastools.hxx>
      23             : 
      24             : #include <toolkit/helper/vclunohelper.hxx>
      25             : #include <vcl/canvastools.hxx>
      26             : #include <basegfx/tools/canvastools.hxx>
      27             : 
      28             : #include "spritedevicehelper.hxx"
      29             : #include "spritecanvas.hxx"
      30             : #include "spritecanvashelper.hxx"
      31             : #include "canvasbitmap.hxx"
      32             : 
      33             : 
      34             : using namespace ::com::sun::star;
      35             : 
      36             : namespace vclcanvas
      37             : {
      38           0 :     SpriteDeviceHelper::SpriteDeviceHelper() :
      39           0 :         mpBackBuffer()
      40             :     {
      41           0 :     }
      42             : 
      43           0 :     void SpriteDeviceHelper::init( const OutDevProviderSharedPtr& pOutDev )
      44             :     {
      45           0 :         DeviceHelper::init(pOutDev);
      46             : 
      47             :         // setup back buffer
      48           0 :         OutputDevice& rOutDev( pOutDev->getOutDev() );
      49           0 :         mpBackBuffer.reset( new BackBuffer( rOutDev ));
      50           0 :         mpBackBuffer->setSize( rOutDev.GetOutputSizePixel() );
      51             : 
      52             :         // #i95645#
      53             : #if defined( QUARTZ )
      54             :         // use AA on VCLCanvas for Mac
      55             :         mpBackBuffer->getOutDev().SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW | mpBackBuffer->getOutDev().GetAntialiasing() );
      56             : #else
      57             :         // switch off AA for WIN32 and UNIX, the VCLCanvas does not look good with it and
      58             :         // is not required to do AA. It would need to be adapted to use it correctly
      59             :         // (especially gradient painting). This will need extra work.
      60           0 :         mpBackBuffer->getOutDev().SetAntialiasing(mpBackBuffer->getOutDev().GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW);
      61             : #endif
      62           0 :     }
      63             : 
      64           0 :     ::sal_Int32 SpriteDeviceHelper::createBuffers( ::sal_Int32 nBuffers )
      65             :     {
      66             :         (void)nBuffers;
      67             : 
      68             :         // TODO(F3): implement XBufferStrategy interface. For now, we
      69             :         // _always_ will have exactly one backbuffer
      70           0 :         return 1;
      71             :     }
      72             : 
      73           0 :     void SpriteDeviceHelper::destroyBuffers()
      74             :     {
      75             :         // TODO(F3): implement XBufferStrategy interface. For now, we
      76             :         // _always_ will have exactly one backbuffer
      77           0 :     }
      78             : 
      79           0 :     ::sal_Bool SpriteDeviceHelper::showBuffer( bool, ::sal_Bool )
      80             :     {
      81             :         OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
      82           0 :         return sal_False;
      83             :     }
      84             : 
      85           0 :     ::sal_Bool SpriteDeviceHelper::switchBuffer( bool, ::sal_Bool )
      86             :     {
      87             :         OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
      88           0 :         return sal_False;
      89             :     }
      90             : 
      91           0 :     void SpriteDeviceHelper::disposing()
      92             :     {
      93             :         // release all references
      94           0 :         mpBackBuffer.reset();
      95             : 
      96           0 :         DeviceHelper::disposing();
      97           0 :     }
      98             : 
      99           0 :     uno::Any SpriteDeviceHelper::isAccelerated() const
     100             :     {
     101           0 :         return DeviceHelper::isAccelerated();
     102             :     }
     103             : 
     104           0 :     uno::Any SpriteDeviceHelper::getDeviceHandle() const
     105             :     {
     106           0 :         return DeviceHelper::getDeviceHandle();
     107             :     }
     108             : 
     109           0 :     uno::Any SpriteDeviceHelper::getSurfaceHandle() const
     110             :     {
     111           0 :         if( !mpBackBuffer )
     112           0 :             return uno::Any();
     113             : 
     114             :         return uno::makeAny(
     115           0 :             reinterpret_cast< sal_Int64 >(&mpBackBuffer->getOutDev()) );
     116             :     }
     117             : 
     118           0 :     void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
     119             :     {
     120           0 :         if( mpBackBuffer )
     121             :             mpBackBuffer->setSize( ::Size(rBounds.Width,
     122           0 :                                           rBounds.Height) );
     123           0 :     }
     124             : 
     125           0 :     void SpriteDeviceHelper::dumpScreenContent() const
     126             :     {
     127           0 :         DeviceHelper::dumpScreenContent();
     128             : 
     129             :         static sal_Int32 nFilePostfixCount(0);
     130             : 
     131           0 :         if( mpBackBuffer )
     132             :         {
     133           0 :             rtl::OUString aFilename("dbg_backbuffer");
     134           0 :             aFilename += rtl::OUString::valueOf(nFilePostfixCount);
     135           0 :             aFilename += rtl::OUString(".bmp");
     136             : 
     137           0 :             SvFileStream aStream( aFilename, STREAM_STD_READWRITE );
     138             : 
     139           0 :             const ::Point aEmptyPoint;
     140           0 :             mpBackBuffer->getOutDev().EnableMapMode( sal_False );
     141           0 :             aStream << mpBackBuffer->getOutDev().GetBitmap(aEmptyPoint,
     142           0 :                                                             mpBackBuffer->getOutDev().GetOutputSizePixel());
     143             :         }
     144             : 
     145           0 :         ++nFilePostfixCount;
     146           0 :     }
     147             : 
     148           0 : }
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10