LCOV - code coverage report
Current view: top level - canvas/source/cairo - cairo_canvas.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 27 50 54.0 %
Date: 2014-11-03 Functions: 6 14 42.9 %
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 <canvas/verbosetrace.hxx>
      22             : #include <canvas/canvastools.hxx>
      23             : #include <tools/diagnose_ex.h>
      24             : 
      25             : #include <osl/mutex.hxx>
      26             : 
      27             : #include <com/sun/star/registry/XRegistryKey.hpp>
      28             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      29             : #include <com/sun/star/uno/XComponentContext.hpp>
      30             : #include <com/sun/star/lang/NoSupportException.hpp>
      31             : 
      32             : #include <toolkit/helper/vclunohelper.hxx>
      33             : 
      34             : #include <basegfx/matrix/b2dhommatrix.hxx>
      35             : #include <basegfx/point/b2dpoint.hxx>
      36             : #include <basegfx/tools/canvastools.hxx>
      37             : #include <basegfx/numeric/ftools.hxx>
      38             : 
      39             : #include <vcl/sysdata.hxx>
      40             : 
      41             : #include "cairo_canvas.hxx"
      42             : 
      43             : using namespace ::cairo;
      44             : using namespace ::com::sun::star;
      45             : 
      46             : namespace cairocanvas
      47             : {
      48           2 :     Canvas::Canvas( const uno::Sequence< uno::Any >&                aArguments,
      49             :                     const uno::Reference< uno::XComponentContext >& rxContext ) :
      50             :         maArguments(aArguments),
      51           2 :         mxComponentContext( rxContext )
      52             :     {
      53           2 :     }
      54             : 
      55           2 :     void Canvas::initialize()
      56             :     {
      57             :         // #i64742# Only perform initialization when not in probe mode
      58           2 :         if( maArguments.getLength() == 0 )
      59           0 :             return;
      60             : 
      61             :         /* maArguments:
      62             :            0: ptr to creating instance (Window or VirtualDevice)
      63             :            1: SystemEnvData as a streamed Any (or empty for VirtualDevice)
      64             :            2: current bounds of creating instance
      65             :            3: bool, denoting always on top state for Window (always false for VirtualDevice)
      66             :            4: XWindow for creating Window (or empty for VirtualDevice)
      67             :            5: SystemGraphicsData as a streamed Any
      68             :          */
      69             :         VERBOSE_TRACE("Canvas created %p\n", this);
      70             : 
      71           2 :         ENSURE_ARG_OR_THROW( maArguments.getLength() >= 6 &&
      72             :                              maArguments[0].getValueTypeClass() == uno::TypeClass_HYPER &&
      73             :                              maArguments[5].getValueTypeClass() == uno::TypeClass_SEQUENCE,
      74             :                              "Canvas::initialize: wrong number of arguments, or wrong types" );
      75             : 
      76             :         // We expect a single Any here, containing a pointer to a valid
      77             :         // VCL output device, on which to output (mostly needed for text)
      78           2 :         sal_Int64 nPtr = 0;
      79           2 :         maArguments[0] >>= nPtr;
      80           2 :         OutputDevice* pOutDev = reinterpret_cast<OutputDevice*>(nPtr);
      81             : 
      82           2 :         ENSURE_ARG_OR_THROW( pOutDev != NULL,
      83             :                              "Canvas::initialize: invalid OutDev pointer" );
      84             : 
      85           2 :         awt::Rectangle aBounds;
      86           2 :         maArguments[2] >>= aBounds;
      87             : 
      88           2 :         uno::Sequence<sal_Int8> aSeq;
      89           2 :         maArguments[5] >>= aSeq;
      90             : 
      91           2 :         const SystemGraphicsData* pSysData=reinterpret_cast<const SystemGraphicsData*>(aSeq.getConstArray());
      92           2 :         if( !pSysData || !pSysData->nSize )
      93           0 :             throw lang::NoSupportException( "Passed SystemGraphicsData invalid!" );
      94             : 
      95           2 :         bool bHasXRender = IsCairoWorking(pOutDev);
      96           2 :         ENSURE_ARG_OR_THROW( bHasXRender == true, "SpriteCanvas::SpriteCanvas: No RENDER extension" );
      97             : 
      98             :         // setup helper
      99           0 :         maDeviceHelper.init( *this, *pOutDev );
     100             : 
     101           0 :         maCanvasHelper.init( basegfx::B2ISize(aBounds.Width, aBounds.Height), *this, this );
     102             : 
     103             :         // forward surface to render on to canvashelper
     104           0 :         maCanvasHelper.setSurface( maDeviceHelper.getSurface(), false );
     105             : 
     106           2 :         maArguments.realloc(0);
     107             :     }
     108             : 
     109           2 :     Canvas::~Canvas()
     110             :     {
     111             :         OSL_TRACE( "CairoCanvas destroyed" );
     112           2 :     }
     113             : 
     114           2 :     void Canvas::disposeThis()
     115             :     {
     116           2 :         ::osl::MutexGuard aGuard( m_aMutex );
     117             : 
     118           2 :         mxComponentContext.clear();
     119             : 
     120             :         // forward to parent
     121           2 :         CanvasBaseT::disposeThis();
     122           2 :     }
     123             : 
     124           0 :     OUString SAL_CALL Canvas::getServiceName(  ) throw (uno::RuntimeException, std::exception)
     125             :     {
     126           0 :         return OUString( CANVAS_SERVICE_NAME );
     127             :     }
     128             : 
     129           0 :     bool Canvas::repaint( const SurfaceSharedPtr&       pSurface,
     130             :                           const rendering::ViewState&   viewState,
     131             :                           const rendering::RenderState& renderState )
     132             :     {
     133           0 :         return maCanvasHelper.repaint( pSurface, viewState, renderState );
     134             :     }
     135             : 
     136           0 :     SurfaceSharedPtr Canvas::getSurface()
     137             :     {
     138           0 :         return maDeviceHelper.getSurface();
     139             :     }
     140             : 
     141           0 :     SurfaceSharedPtr Canvas::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
     142             :     {
     143           0 :         return maDeviceHelper.createSurface( rSize, aContent );
     144             :     }
     145             : 
     146           0 :     SurfaceSharedPtr Canvas::createSurface( ::Bitmap& rBitmap )
     147             :     {
     148           0 :         SurfaceSharedPtr pSurface;
     149             : 
     150             :         BitmapSystemData aData;
     151           0 :         if( rBitmap.GetSystemData( aData ) ) {
     152           0 :             const Size& rSize = rBitmap.GetSizePixel();
     153             : 
     154           0 :             pSurface = maDeviceHelper.createSurface( aData, rSize );
     155             :         }
     156             : 
     157           0 :         return pSurface;
     158             :     }
     159             : 
     160           0 :     SurfaceSharedPtr Canvas::changeSurface( bool, bool )
     161             :     {
     162             :         // non-modifiable surface here
     163           0 :         return SurfaceSharedPtr();
     164             :     }
     165             : 
     166           0 :     OutputDevice* Canvas::getOutputDevice()
     167             :     {
     168           0 :         return maDeviceHelper.getOutputDevice();
     169             :     }
     170           6 : }
     171             : 
     172             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10