LCOV - code coverage report
Current view: top level - canvas/source/vcl - devicehelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 79 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 19 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 :     void DeviceHelper::disposing()
     153             :     {
     154             :         // release all references
     155           0 :         mpOutDev.reset();
     156           0 :     }
     157             : 
     158           0 :     uno::Any DeviceHelper::isAccelerated() const
     159             :     {
     160           0 :         return ::com::sun::star::uno::makeAny(false);
     161             :     }
     162             : 
     163           0 :     uno::Any DeviceHelper::getDeviceHandle() const
     164             :     {
     165           0 :         if( !mpOutDev )
     166           0 :             return uno::Any();
     167             : 
     168             :         return uno::makeAny(
     169           0 :             reinterpret_cast< sal_Int64 >(&mpOutDev->getOutDev()) );
     170             :     }
     171             : 
     172           0 :     uno::Any DeviceHelper::getSurfaceHandle() const
     173             :     {
     174           0 :         return getDeviceHandle();
     175             :     }
     176             : 
     177             :     namespace
     178             :     {
     179             :         struct DeviceColorSpace: public rtl::StaticWithInit<uno::Reference<rendering::XColorSpace>,
     180             :                                                             DeviceColorSpace>
     181             :         {
     182           0 :             uno::Reference<rendering::XColorSpace> operator()()
     183             :             {
     184           0 :                 uno::Reference< rendering::XColorSpace > xColorSpace( canvas::tools::getStdColorSpace(), uno::UNO_QUERY );
     185             :                 assert( xColorSpace.is() );
     186           0 :                 return xColorSpace;
     187             :             }
     188             :         };
     189             :     }
     190             : 
     191           0 :     uno::Reference<rendering::XColorSpace> DeviceHelper::getColorSpace() const
     192             :     {
     193             :         // always the same
     194           0 :         return DeviceColorSpace::get();
     195             :     }
     196             : 
     197           0 :     void DeviceHelper::dumpScreenContent() const
     198             :     {
     199             :         static sal_Int32 nFilePostfixCount(0);
     200             : 
     201           0 :         if( mpOutDev )
     202             :         {
     203           0 :             OUString aFilename = "dbg_frontbuffer" + OUString::number(nFilePostfixCount) + ".bmp";
     204             : 
     205           0 :             SvFileStream aStream( aFilename, STREAM_STD_READWRITE );
     206             : 
     207           0 :             const ::Point aEmptyPoint;
     208           0 :             OutputDevice& rOutDev = mpOutDev->getOutDev();
     209           0 :             bool bOldMap( rOutDev.IsMapModeEnabled() );
     210           0 :             rOutDev.EnableMapMode( false );
     211           0 :             WriteDIB(rOutDev.GetBitmap(aEmptyPoint, rOutDev.GetOutputSizePixel()), aStream, false, true);
     212           0 :             rOutDev.EnableMapMode( bOldMap );
     213             : 
     214           0 :             ++nFilePostfixCount;
     215             :         }
     216           0 :     }
     217             : 
     218           0 : }
     219             : 
     220             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11