LCOV - code coverage report
Current view: top level - canvas/source/cairo - cairo_spritedevicehelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 55 1.8 %
Date: 2015-06-13 12:38:46 Functions: 2 16 12.5 %
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             : 
      24             : #include <osl/mutex.hxx>
      25             : #include <cppuhelper/compbase1.hxx>
      26             : 
      27             : #include <com/sun/star/lang/NoSupportException.hpp>
      28             : 
      29             : #include <toolkit/helper/vclunohelper.hxx>
      30             : #include <basegfx/tools/canvastools.hxx>
      31             : #include <basegfx/tools/unopolypolygon.hxx>
      32             : 
      33             : #include <vcl/syschild.hxx>
      34             : #include <vcl/cairo.hxx>
      35             : #include <vcl/canvastools.hxx>
      36             : 
      37             : #include "cairo_spritecanvas.hxx"
      38             : #include "cairo_canvasbitmap.hxx"
      39             : #include "cairo_devicehelper.hxx"
      40             : 
      41             : using namespace ::cairo;
      42             : using namespace ::com::sun::star;
      43             : 
      44             : namespace cairocanvas
      45             : {
      46             : 
      47           0 :     SpriteDeviceHelper::SpriteDeviceHelper() :
      48             :         mpSpriteCanvas( NULL ),
      49             :         mpBufferSurface(),
      50             :         maSize(),
      51           0 :         mbFullScreen( false )
      52           0 :     {}
      53             : 
      54           0 :     void SpriteDeviceHelper::init( vcl::Window&                   rOutputWindow,
      55             :                                    SpriteCanvas&             rSpriteCanvas,
      56             :                                    const ::basegfx::B2ISize& rSize,
      57             :                                    bool                      bFullscreen )
      58             :     {
      59             :         DeviceHelper::init(rSpriteCanvas,
      60           0 :                            rOutputWindow);
      61             : 
      62           0 :         mpSpriteCanvas = &rSpriteCanvas;
      63           0 :         mbFullScreen = bFullscreen;
      64             : 
      65           0 :         setSize( rSize );
      66           0 :     }
      67             : 
      68           0 :     void SpriteDeviceHelper::disposing()
      69             :     {
      70             :         // release all references
      71           0 :         mpBufferSurface.reset();
      72           0 :         mpSpriteCanvas = NULL;
      73           0 :     }
      74             : 
      75           0 :     bool SpriteDeviceHelper::showBuffer( bool, bool )
      76             :     {
      77             :         OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
      78           0 :         return false;
      79             :     }
      80             : 
      81           0 :     bool SpriteDeviceHelper::switchBuffer( bool, bool )
      82             :     {
      83             :         OSL_FAIL("Not supposed to be called, handled by SpriteCanvas");
      84           0 :         return false;
      85             :     }
      86             : 
      87           0 :     uno::Any SpriteDeviceHelper::isAccelerated() const
      88             :     {
      89           0 :         return ::com::sun::star::uno::makeAny(true);
      90             :     }
      91             : 
      92           0 :     uno::Any SpriteDeviceHelper::getDeviceHandle() const
      93             :     {
      94           0 :         return DeviceHelper::getDeviceHandle();
      95             :     }
      96             : 
      97           0 :     uno::Any SpriteDeviceHelper::getSurfaceHandle() const
      98             :     {
      99           0 :         return DeviceHelper::getSurfaceHandle();
     100             :     }
     101             : 
     102           0 :     void SpriteDeviceHelper::setSize( const ::basegfx::B2ISize& rSize )
     103             :     {
     104             :         SAL_INFO(
     105             :             "canvas.cairo",
     106             :             "device size " << rSize.getX() << " x " << rSize.getY());
     107             : 
     108           0 :         if( !mpSpriteCanvas )
     109           0 :             return; // disposed
     110             : 
     111           0 :         DeviceHelper::setSize(rSize);
     112             : 
     113           0 :         if( mpBufferSurface && maSize != rSize )
     114           0 :             mpBufferSurface.reset();
     115           0 :         if( !mpBufferSurface )
     116           0 :             mpBufferSurface = getWindowSurface()->getSimilar(
     117             :                 CAIRO_CONTENT_COLOR,
     118           0 :                 rSize.getX(), rSize.getY() );
     119             : 
     120           0 :         if( maSize != rSize )
     121           0 :             maSize = rSize;
     122             : 
     123           0 :         mpSpriteCanvas->setSizePixel( maSize );
     124             :     }
     125             : 
     126             : 
     127           0 :     void SpriteDeviceHelper::notifySizeUpdate( const awt::Rectangle& rBounds )
     128             :     {
     129           0 :         setSize( ::basegfx::B2ISize(rBounds.Width, rBounds.Height) );
     130           0 :     }
     131             : 
     132           0 :     SurfaceSharedPtr SpriteDeviceHelper::getWindowSurface()
     133             :     {
     134           0 :         return DeviceHelper::getSurface();
     135             :     }
     136             : 
     137           0 :     SurfaceSharedPtr SpriteDeviceHelper::createSurface( const ::basegfx::B2ISize& rSize, int aContent )
     138             :     {
     139           0 :         if( mpBufferSurface )
     140           0 :             return mpBufferSurface->getSimilar( aContent, rSize.getX(), rSize.getY() );
     141             : 
     142           0 :         return SurfaceSharedPtr();
     143             :     }
     144             : 
     145           0 :     SurfaceSharedPtr SpriteDeviceHelper::createSurface( BitmapSystemData& rData, const Size& rSize )
     146             :     {
     147           0 :         OutputDevice *pDevice = getOutputDevice();
     148           0 :         if (pDevice)
     149           0 :             return pDevice->CreateBitmapSurface(rData, rSize);
     150           0 :         return SurfaceSharedPtr();
     151             :     }
     152             : 
     153             :     /** SpriteDeviceHelper::flush  Flush the platform native window
     154             :      *
     155             :      * Flushes the window by using the internally stored mpSysData.
     156             :      *
     157             :      **/
     158           0 :     void SpriteDeviceHelper::flush()
     159             :     {
     160           0 :         SurfaceSharedPtr pWinSurface=getWindowSurface();
     161           0 :         if( pWinSurface )
     162           0 :             pWinSurface->flush();
     163           0 :     }
     164           6 : }
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11