LCOV - code coverage report
Current view: top level - canvas/source/cairo - cairo_spritecanvas.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 70 0.0 %
Date: 2014-04-14 Functions: 0 20 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 <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 "cairo_spritecanvas.hxx"
      40             : 
      41             : using namespace ::cairo;
      42             : using namespace ::com::sun::star;
      43             : 
      44             : namespace cairocanvas
      45             : {
      46           0 :     SpriteCanvas::SpriteCanvas( const uno::Sequence< uno::Any >&                aArguments,
      47             :                                 const uno::Reference< uno::XComponentContext >& rxContext ) :
      48             :         maArguments(aArguments),
      49           0 :         mxComponentContext( rxContext )
      50             :     {
      51           0 :     }
      52             : 
      53           0 :     void SpriteCanvas::initialize()
      54             :     {
      55             :         VERBOSE_TRACE("CairoSpriteCanvas created %p\n", this);
      56             : 
      57             :         // #i64742# Only call initialize when not in probe mode
      58           0 :         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           0 :         ENSURE_ARG_OR_THROW( maArguments.getLength() >= 4 &&
      70             :                              maArguments[0].getValueTypeClass() == uno::TypeClass_HYPER &&
      71             :                              maArguments[4].getValueTypeClass() == uno::TypeClass_INTERFACE,
      72             :                              "CairoSpriteCanvas::initialize: wrong number of arguments, or wrong types" );
      73             : 
      74           0 :         awt::Rectangle aRect;
      75           0 :         maArguments[2] >>= aRect;
      76             : 
      77           0 :         sal_Bool bIsFullscreen( sal_False );
      78           0 :         maArguments[3] >>= bIsFullscreen;
      79             : 
      80           0 :         uno::Reference< awt::XWindow > xParentWindow;
      81           0 :         maArguments[4] >>= xParentWindow;
      82             : 
      83           0 :         Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow);
      84           0 :         if( !pParentWindow )
      85             :             throw lang::NoSupportException(
      86           0 :                 "Parent window not VCL window, or canvas out-of-process!", NULL);
      87             : 
      88           0 :         bool bHasXRender = IsCairoWorking(pParentWindow);
      89           0 :         ENSURE_ARG_OR_THROW( bHasXRender == true,
      90             :                              "CairoSpriteCanvas::SpriteCanvas: No RENDER extension" );
      91             : 
      92           0 :         Size aPixelSize( pParentWindow->GetOutputSizePixel() );
      93           0 :         const ::basegfx::B2ISize aSize( aPixelSize.Width(),
      94           0 :                                         aPixelSize.Height() );
      95             : 
      96           0 :         ENSURE_ARG_OR_THROW( pParentWindow != NULL,
      97             :                              "CairoSpriteCanvas::initialize: invalid Window pointer" );
      98             : 
      99             :         // setup helper
     100             :         maDeviceHelper.init( *pParentWindow,
     101             :                              *this,
     102             :                              aSize,
     103           0 :                              bIsFullscreen );
     104             : 
     105           0 :         setWindow(uno::Reference<awt::XWindow2>(xParentWindow, uno::UNO_QUERY_THROW));
     106             : 
     107             :         maCanvasHelper.init( maRedrawManager,
     108             :                              *this,
     109           0 :                              aSize );
     110             : 
     111           0 :         maArguments.realloc(0);
     112             :     }
     113             : 
     114           0 :     void SpriteCanvas::disposeThis()
     115             :     {
     116           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     117             : 
     118           0 :         mxComponentContext.clear();
     119             : 
     120             :         // forward to parent
     121           0 :         SpriteCanvasBaseT::disposeThis();
     122           0 :     }
     123             : 
     124           0 :     sal_Bool SAL_CALL SpriteCanvas::showBuffer( sal_Bool bUpdateAll ) throw (uno::RuntimeException, std::exception)
     125             :     {
     126           0 :         return updateScreen( bUpdateAll );
     127             :     }
     128             : 
     129           0 :     sal_Bool SAL_CALL SpriteCanvas::switchBuffer( sal_Bool bUpdateAll ) throw (uno::RuntimeException)
     130             :     {
     131           0 :         return updateScreen( bUpdateAll );
     132             :     }
     133             : 
     134           0 :     sal_Bool SAL_CALL SpriteCanvas::updateScreen( sal_Bool bUpdateAll ) throw (uno::RuntimeException, std::exception)
     135             :     {
     136           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     137             : 
     138             :         // avoid repaints on hidden window (hidden: not mapped to
     139             :         // screen). Return failure, since the screen really has _not_
     140             :         // been updated (caller should try again later)
     141             :         return !mbIsVisible ? false : maCanvasHelper.updateScreen(
     142           0 :             ::basegfx::unotools::b2IRectangleFromAwtRectangle(maBounds),
     143             :             bUpdateAll,
     144           0 :             mbSurfaceDirty);
     145             :     }
     146             : 
     147           0 :     OUString SAL_CALL SpriteCanvas::getServiceName(  ) throw (uno::RuntimeException, std::exception)
     148             :     {
     149           0 :         return OUString( SPRITECANVAS_SERVICE_NAME );
     150             :     }
     151             : 
     152           0 :     SurfaceSharedPtr SpriteCanvas::getSurface()
     153             :     {
     154           0 :         return maDeviceHelper.getBufferSurface();
     155             :     }
     156             : 
     157           0 :     SurfaceSharedPtr SpriteCanvas::createSurface( const ::basegfx::B2ISize& rSize, Content aContent )
     158             :     {
     159           0 :         return maDeviceHelper.createSurface( rSize, aContent );
     160             :     }
     161             : 
     162           0 :     SurfaceSharedPtr SpriteCanvas::createSurface( ::Bitmap& rBitmap )
     163             :     {
     164             :         BitmapSystemData aData;
     165           0 :         if( rBitmap.GetSystemData( aData ) ) {
     166           0 :             const Size& rSize = rBitmap.GetSizePixel();
     167             : 
     168           0 :             return maDeviceHelper.createSurface( aData, rSize );
     169             :         }
     170             : 
     171           0 :         return SurfaceSharedPtr();
     172             :     }
     173             : 
     174           0 :     SurfaceSharedPtr SpriteCanvas::changeSurface( bool, bool )
     175             :     {
     176             :         // non-modifiable surface here
     177           0 :         return SurfaceSharedPtr();
     178             :     }
     179             : 
     180           0 :     OutputDevice* SpriteCanvas::getOutputDevice()
     181             :     {
     182           0 :         return maDeviceHelper.getOutputDevice();
     183             :     }
     184             : 
     185           0 :     SurfaceSharedPtr SpriteCanvas::getBufferSurface()
     186             :     {
     187           0 :         return maDeviceHelper.getBufferSurface();
     188             :     }
     189             : 
     190           0 :     SurfaceSharedPtr SpriteCanvas::getWindowSurface()
     191             :     {
     192           0 :         return maDeviceHelper.getWindowSurface();
     193             :     }
     194             : 
     195           0 :     const ::basegfx::B2ISize& SpriteCanvas::getSizePixel()
     196             :     {
     197           0 :         return maDeviceHelper.getSizePixel();
     198             :     }
     199             : 
     200           0 :     void SpriteCanvas::setSizePixel( const ::basegfx::B2ISize& rSize )
     201             :     {
     202           0 :         maCanvasHelper.setSize( rSize );
     203             :         // re-set background surface, in case it needed recreation
     204             :         maCanvasHelper.setSurface( maDeviceHelper.getBufferSurface(),
     205           0 :                                    false );
     206           0 :     }
     207             : 
     208           0 :     void SpriteCanvas::flush()
     209             :     {
     210           0 :         maDeviceHelper.flush();
     211           0 :     }
     212             : 
     213           0 :     bool SpriteCanvas::repaint( const SurfaceSharedPtr&       pSurface,
     214             :                                 const rendering::ViewState&   viewState,
     215             :                                 const rendering::RenderState& renderState )
     216             :     {
     217           0 :         return maCanvasHelper.repaint( pSurface, viewState, renderState );
     218             :     }
     219           0 : }
     220             : 
     221             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10