LCOV - code coverage report
Current view: top level - canvas/source/vcl - spritecanvas.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 38 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 12 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 <tools/diagnose_ex.h>
      23             : #include <canvas/verbosetrace.hxx>
      24             : #include <canvas/canvastools.hxx>
      25             : 
      26             : #include <com/sun/star/registry/XRegistryKey.hpp>
      27             : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      28             : #include <com/sun/star/uno/XComponentContext.hpp>
      29             : 
      30             : #include <vcl/canvastools.hxx>
      31             : #include <vcl/outdev.hxx>
      32             : #include <vcl/window.hxx>
      33             : #include <vcl/bitmapex.hxx>
      34             : 
      35             : #include <basegfx/tools/canvastools.hxx>
      36             : 
      37             : #include <algorithm>
      38             : 
      39             : #include "spritecanvas.hxx"
      40             : #include "windowoutdevholder.hxx"
      41             : 
      42             : 
      43             : using namespace ::com::sun::star;
      44             : 
      45             : namespace vclcanvas
      46             : {
      47           0 :     SpriteCanvas::SpriteCanvas( const uno::Sequence< uno::Any >&                aArguments,
      48             :                                 const uno::Reference< uno::XComponentContext >& rxContext ) :
      49             :         maArguments(aArguments),
      50           0 :         mxComponentContext( rxContext )
      51             :     {
      52           0 :     }
      53             : 
      54           0 :     void SpriteCanvas::initialize()
      55             :     {
      56           0 :         SolarMutexGuard aGuard;
      57             : 
      58             :         // #i64742# Only call initialize when not in probe mode
      59           0 :         if( maArguments.getLength() == 0 )
      60           0 :             return;
      61             : 
      62             :         OSL_TRACE( "SpriteCanvas created" );
      63             : 
      64             :         // add our own property to GraphicDevice
      65             :         maPropHelper.addProperties(
      66             :             ::canvas::PropertySetHelper::MakeMap
      67             :             ("UnsafeScrolling",
      68             :              boost::bind(&SpriteCanvasHelper::isUnsafeScrolling,
      69             :                          boost::ref(maCanvasHelper)),
      70             :              boost::bind(&SpriteCanvasHelper::enableUnsafeScrolling,
      71             :                          boost::ref(maCanvasHelper),
      72             :                          _1))
      73             :             ("SpriteBounds",
      74             :              boost::bind(&SpriteCanvasHelper::isSpriteBounds,
      75             :                          boost::ref(maCanvasHelper)),
      76             :              boost::bind(&SpriteCanvasHelper::enableSpriteBounds,
      77             :                          boost::ref(maCanvasHelper),
      78           0 :                          _1)));
      79             : 
      80             :         VERBOSE_TRACE( "VCLSpriteCanvas::initialize called" );
      81             : 
      82           0 :         ENSURE_ARG_OR_THROW( maArguments.getLength() >= 1,
      83             :                              "VCLSpriteCanvas::initialize: wrong number of arguments" );
      84             : 
      85             :         /* maArguments:
      86             :            0: ptr to creating instance (Window or VirtualDevice)
      87             :            1: SystemEnvData as a streamed Any (or empty for VirtualDevice)
      88             :            2: current bounds of creating instance
      89             :            3: bool, denoting always on top state for Window (always false for VirtualDevice)
      90             :            4: XWindow for creating Window (or empty for VirtualDevice)
      91             :            5: SystemGraphicsData as a streamed Any
      92             :          */
      93           0 :         ENSURE_ARG_OR_THROW( maArguments.getLength() >= 4 &&
      94             :                              maArguments[0].getValueTypeClass() == uno::TypeClass_HYPER &&
      95             :                              maArguments[4].getValueTypeClass() == uno::TypeClass_INTERFACE,
      96             :                              "VCLSpriteCanvas::initialize: wrong number of arguments, or wrong types" );
      97             : 
      98           0 :         uno::Reference< awt::XWindow > xParentWindow;
      99           0 :         maArguments[4] >>= xParentWindow;
     100             : 
     101           0 :         OutDevProviderSharedPtr pOutDev( new WindowOutDevHolder(xParentWindow) );
     102             : 
     103             :         // setup helper
     104           0 :         maDeviceHelper.init( pOutDev );
     105           0 :         setWindow(uno::Reference<awt::XWindow2>(xParentWindow, uno::UNO_QUERY_THROW));
     106             :         maCanvasHelper.init( maDeviceHelper.getBackBuffer(),
     107             :                              *this,
     108             :                              maRedrawManager,
     109             :                              false,   // no OutDev state preservation
     110           0 :                              false ); // no alpha on surface
     111             : 
     112           0 :         maArguments.realloc(0);
     113             :     }
     114             : 
     115           0 :     SpriteCanvas::~SpriteCanvas()
     116             :     {
     117             :         OSL_TRACE( "SpriteCanvas destroyed" );
     118           0 :     }
     119             : 
     120             : 
     121           0 :     void SpriteCanvas::disposeThis()
     122             :     {
     123           0 :         SolarMutexGuard aGuard;
     124             : 
     125           0 :         mxComponentContext.clear();
     126             : 
     127             :         // forward to parent
     128           0 :         SpriteCanvasBaseT::disposeThis();
     129           0 :     }
     130             : 
     131           0 :     sal_Bool SAL_CALL SpriteCanvas::showBuffer( sal_Bool bUpdateAll ) throw (uno::RuntimeException, std::exception)
     132             :     {
     133           0 :         return updateScreen( bUpdateAll );
     134             :     }
     135             : 
     136           0 :     sal_Bool SAL_CALL SpriteCanvas::switchBuffer( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
     137             :     {
     138           0 :         return updateScreen( bUpdateAll );
     139             :     }
     140             : 
     141           0 :     sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException, std::exception)
     142             :     {
     143           0 :         SolarMutexGuard aGuard;
     144             : 
     145             :         // avoid repaints on hidden window (hidden: not mapped to
     146             :         // screen). Return failure, since the screen really has _not_
     147             :         // been updated (caller should try again later)
     148           0 :         return !mbIsVisible && maCanvasHelper.updateScreen(bUpdateAll,
     149           0 :                                                                   mbSurfaceDirty);
     150             :     }
     151             : 
     152           0 :     OUString SAL_CALL SpriteCanvas::getServiceName(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     153             :     {
     154           0 :         return OUString( SPRITECANVAS_SERVICE_NAME );
     155             :     }
     156             : 
     157           0 :     bool SpriteCanvas::repaint( const GraphicObjectSharedPtr&   rGrf,
     158             :                                 const rendering::ViewState&     viewState,
     159             :                                 const rendering::RenderState&   renderState,
     160             :                                 const ::Point&                  rPt,
     161             :                                 const ::Size&                   rSz,
     162             :                                 const GraphicAttr&              rAttr ) const
     163             :     {
     164           0 :         SolarMutexGuard aGuard;
     165             : 
     166           0 :         return maCanvasHelper.repaint( rGrf, viewState, renderState, rPt, rSz, rAttr );
     167             :     }
     168           0 : }
     169             : 
     170             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11