LCOV - code coverage report
Current view: top level - canvas/source/vcl - devicehelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 83 0.0 %
Date: 2014-04-14 Functions: 0 21 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 <tools/diagnose_ex.h>
      22             : #include <canvas/canvastools.hxx>
      23             : #include <rtl/instance.hxx>
      24             : #include <toolkit/helper/vclunohelper.hxx>
      25             : #include <vcl/canvastools.hxx>
      26             : #include <basegfx/tools/canvastools.hxx>
      27             : #include <basegfx/tools/unopolypolygon.hxx>
      28             : #include <vcl/dibtools.hxx>
      29             : 
      30             : #include "devicehelper.hxx"
      31             : #include "spritecanvas.hxx"
      32             : #include "spritecanvashelper.hxx"
      33             : #include "canvasbitmap.hxx"
      34             : 
      35             : using namespace ::com::sun::star;
      36             : 
      37             : namespace vclcanvas
      38             : {
      39           0 :     DeviceHelper::DeviceHelper() :
      40           0 :         mpOutDev()
      41           0 :     {}
      42             : 
      43           0 :     void DeviceHelper::init( const OutDevProviderSharedPtr& rOutDev )
      44             :     {
      45           0 :         mpOutDev = rOutDev;
      46           0 :     }
      47             : 
      48           0 :     geometry::RealSize2D DeviceHelper::getPhysicalResolution()
      49             :     {
      50           0 :         if( !mpOutDev )
      51           0 :             return ::canvas::tools::createInfiniteSize2D(); // we're disposed
      52             : 
      53             :         // Map a one-by-one millimeter box to pixel
      54           0 :         OutputDevice& rOutDev = mpOutDev->getOutDev();
      55           0 :         const MapMode aOldMapMode( rOutDev.GetMapMode() );
      56           0 :         rOutDev.SetMapMode( MapMode(MAP_MM) );
      57           0 :         const Size aPixelSize( rOutDev.LogicToPixel(Size(1,1)) );
      58           0 :         rOutDev.SetMapMode( aOldMapMode );
      59             : 
      60           0 :         return ::vcl::unotools::size2DFromSize( aPixelSize );
      61             :     }
      62             : 
      63           0 :     geometry::RealSize2D DeviceHelper::getPhysicalSize()
      64             :     {
      65           0 :         if( !mpOutDev )
      66           0 :             return ::canvas::tools::createInfiniteSize2D(); // we're disposed
      67             : 
      68             :         // Map the pixel dimensions of the output window to millimeter
      69           0 :         OutputDevice& rOutDev = mpOutDev->getOutDev();
      70           0 :         const MapMode aOldMapMode( rOutDev.GetMapMode() );
      71           0 :         rOutDev.SetMapMode( MapMode(MAP_MM) );
      72           0 :         const Size aLogSize( rOutDev.PixelToLogic(rOutDev.GetOutputSizePixel()) );
      73           0 :         rOutDev.SetMapMode( aOldMapMode );
      74             : 
      75           0 :         return ::vcl::unotools::size2DFromSize( aLogSize );
      76             :     }
      77             : 
      78           0 :     uno::Reference< rendering::XLinePolyPolygon2D > DeviceHelper::createCompatibleLinePolyPolygon(
      79             :         const uno::Reference< rendering::XGraphicDevice >&              ,
      80             :         const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >&  points )
      81             :     {
      82           0 :         uno::Reference< rendering::XLinePolyPolygon2D > xPoly;
      83           0 :         if( !mpOutDev )
      84           0 :             return xPoly; // we're disposed
      85             : 
      86             :         xPoly.set( new ::basegfx::unotools::UnoPolyPolygon(
      87           0 :                        ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence( points ) ) );
      88             :         // vcl only handles even_odd polygons
      89           0 :         xPoly->setFillRule(rendering::FillRule_EVEN_ODD);
      90             : 
      91           0 :         return xPoly;
      92             :     }
      93             : 
      94           0 :     uno::Reference< rendering::XBezierPolyPolygon2D > DeviceHelper::createCompatibleBezierPolyPolygon(
      95             :         const uno::Reference< rendering::XGraphicDevice >&                      ,
      96             :         const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >&  points )
      97             :     {
      98           0 :         uno::Reference< rendering::XBezierPolyPolygon2D > xPoly;
      99           0 :         if( !mpOutDev )
     100           0 :             return xPoly; // we're disposed
     101             : 
     102             :         xPoly.set( new ::basegfx::unotools::UnoPolyPolygon(
     103           0 :                        ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence( points ) ) );
     104             :         // vcl only handles even_odd polygons
     105           0 :         xPoly->setFillRule(rendering::FillRule_EVEN_ODD);
     106             : 
     107           0 :         return xPoly;
     108             :     }
     109             : 
     110           0 :     uno::Reference< rendering::XBitmap > DeviceHelper::createCompatibleBitmap(
     111             :         const uno::Reference< rendering::XGraphicDevice >& rDevice,
     112             :         const geometry::IntegerSize2D&                     size )
     113             :     {
     114           0 :         if( !mpOutDev )
     115           0 :             return uno::Reference< rendering::XBitmap >(); // we're disposed
     116             : 
     117             :         return uno::Reference< rendering::XBitmap >(
     118             :             new CanvasBitmap( ::vcl::unotools::sizeFromIntegerSize2D(size),
     119             :                               false,
     120             :                               *rDevice.get(),
     121           0 :                               mpOutDev ) );
     122             :     }
     123             : 
     124           0 :     uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileBitmap(
     125             :         const uno::Reference< rendering::XGraphicDevice >&  ,
     126             :         const geometry::IntegerSize2D&                       )
     127             :     {
     128           0 :         return uno::Reference< rendering::XVolatileBitmap >();
     129             :     }
     130             : 
     131           0 :     uno::Reference< rendering::XBitmap > DeviceHelper::createCompatibleAlphaBitmap(
     132             :         const uno::Reference< rendering::XGraphicDevice >& rDevice,
     133             :         const geometry::IntegerSize2D&                     size )
     134             :     {
     135           0 :         if( !mpOutDev )
     136           0 :             return uno::Reference< rendering::XBitmap >(); // we're disposed
     137             : 
     138             :         return uno::Reference< rendering::XBitmap >(
     139             :             new CanvasBitmap( ::vcl::unotools::sizeFromIntegerSize2D(size),
     140             :                               true,
     141             :                               *rDevice.get(),
     142           0 :                               mpOutDev ) );
     143             :     }
     144             : 
     145           0 :     uno::Reference< rendering::XVolatileBitmap > DeviceHelper::createVolatileAlphaBitmap(
     146             :         const uno::Reference< rendering::XGraphicDevice >&  ,
     147             :         const geometry::IntegerSize2D&                       )
     148             :     {
     149           0 :         return uno::Reference< rendering::XVolatileBitmap >();
     150             :     }
     151             : 
     152           0 :     sal_Bool DeviceHelper::hasFullScreenMode()
     153             :     {
     154           0 :         return false;
     155             :     }
     156             : 
     157           0 :     sal_Bool DeviceHelper::enterFullScreenMode( sal_Bool bEnter )
     158             :     {
     159             :         (void)bEnter;
     160           0 :         return false;
     161             :     }
     162             : 
     163           0 :     void DeviceHelper::disposing()
     164             :     {
     165             :         // release all references
     166           0 :         mpOutDev.reset();
     167           0 :     }
     168             : 
     169           0 :     uno::Any DeviceHelper::isAccelerated() const
     170             :     {
     171           0 :         return ::com::sun::star::uno::makeAny(false);
     172             :     }
     173             : 
     174           0 :     uno::Any DeviceHelper::getDeviceHandle() const
     175             :     {
     176           0 :         if( !mpOutDev )
     177           0 :             return uno::Any();
     178             : 
     179             :         return uno::makeAny(
     180           0 :             reinterpret_cast< sal_Int64 >(&mpOutDev->getOutDev()) );
     181             :     }
     182             : 
     183           0 :     uno::Any DeviceHelper::getSurfaceHandle() const
     184             :     {
     185           0 :         return getDeviceHandle();
     186             :     }
     187             : 
     188             :     namespace
     189             :     {
     190             :         struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,
     191             :                                                             DeviceColorSpace>
     192             :         {
     193           0 :             uno::Reference<rendering::XColorSpace> operator()()
     194             :             {
     195           0 :                 uno::Reference< rendering::XColorSpace > xColorSpace( canvas::tools::getStdColorSpace(), uno::UNO_QUERY );
     196             :                 assert( xColorSpace.is() );
     197           0 :                 return xColorSpace;
     198             :             }
     199             :         };
     200             :     }
     201             : 
     202           0 :     uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const
     203             :     {
     204             :         // always the same
     205           0 :         return DeviceColorSpace::get();
     206             :     }
     207             : 
     208           0 :     void DeviceHelper::dumpScreenContent() const
     209             :     {
     210             :         static sal_Int32 nFilePostfixCount(0);
     211             : 
     212           0 :         if( mpOutDev )
     213             :         {
     214           0 :             OUString aFilename = "dbg_frontbuffer" + OUString::number(nFilePostfixCount) + ".bmp";
     215             : 
     216           0 :             SvFileStream aStream( aFilename, STREAM_STD_READWRITE );
     217             : 
     218           0 :             const ::Point aEmptyPoint;
     219           0 :             OutputDevice& rOutDev = mpOutDev->getOutDev();
     220           0 :             bool bOldMap( rOutDev.IsMapModeEnabled() );
     221           0 :             rOutDev.EnableMapMode( false );
     222           0 :             WriteDIB(rOutDev.GetBitmap(aEmptyPoint, rOutDev.GetOutputSizePixel()), aStream, false, true);
     223           0 :             rOutDev.EnableMapMode( bOldMap );
     224             : 
     225           0 :             ++nFilePostfixCount;
     226             :         }
     227           0 :     }
     228             : 
     229           0 : }
     230             : 
     231             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10