LCOV - code coverage report
Current view: top level - canvas/source/cairo - cairo_canvashelper.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 4 25.0 %
Date: 2014-11-03 Functions: 1 4 25.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             : #ifndef INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CANVASHELPER_HXX
      21             : #define INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CANVASHELPER_HXX
      22             : 
      23             : #include <com/sun/star/rendering/XCanvas.hpp>
      24             : #include <com/sun/star/rendering/XBitmapCanvas.hpp>
      25             : #include <com/sun/star/rendering/XIntegerBitmap.hpp>
      26             : 
      27             : #include <basegfx/vector/b2isize.hxx>
      28             : #include <basegfx/vector/b2dsize.hxx>
      29             : #include <com/sun/star/rendering/XLinePolyPolygon2D.hpp>
      30             : 
      31             : #include <boost/utility.hpp>
      32             : 
      33             : #include "cairo_cairo.hxx"
      34             : #include "cairo_surfaceprovider.hxx"
      35             : 
      36             : class VirtualDevice;
      37             : 
      38             : namespace basegfx {
      39             :     class B2DPolyPolygon;
      40             : }
      41             : 
      42             : namespace cairocanvas
      43             : {
      44             :     class SpriteCanvas;
      45             : 
      46             :     enum Operation {
      47             :         Stroke,
      48             :         Fill,
      49             :         Clip
      50             :     };
      51             : 
      52           2 :     class CanvasHelper : private ::boost::noncopyable
      53             :     {
      54             :     public:
      55             :         CanvasHelper();
      56             : 
      57             :         /// Release all references
      58             :         void disposing();
      59             : 
      60             :         /** Initialize canvas helper
      61             : 
      62             :             This method late-initializes the canvas helper, providing
      63             :             it with the necessary device and size. Note that the
      64             :             CanvasHelper does <em>not</em> take ownership of the
      65             :             passed rDevice reference, nor does it perform any
      66             :             reference counting. Thus, to prevent the reference counted
      67             :             SpriteCanvas object from deletion, the user of this class
      68             :             is responsible for holding ref-counted references itself!
      69             : 
      70             :             @param rSizePixel
      71             :             Size of the output surface in pixel.
      72             : 
      73             :             @param rDevice
      74             :             Reference device this canvas is associated with
      75             : 
      76             :          */
      77             :         void init( const ::basegfx::B2ISize& rSizePixel,
      78             :                    SurfaceProvider&          rSurfaceProvider,
      79             :                    ::com::sun::star::rendering::XGraphicDevice* pDevice );
      80             : 
      81             :         void setSize( const ::basegfx::B2ISize& rSize );
      82             :         void setSurface( const ::cairo::SurfaceSharedPtr& pSurface, bool bHasAlpha );
      83             : 
      84             :         // CanvasHelper functionality
      85             :         // ==========================
      86             : 
      87             :         // XCanvas (only providing, not implementing the
      88             :         // interface. Also note subtle method parameter differences)
      89             :         void clear();
      90             :         void drawPoint( const ::com::sun::star::rendering::XCanvas*     pCanvas,
      91             :                         const ::com::sun::star::geometry::RealPoint2D&  aPoint,
      92             :                         const ::com::sun::star::rendering::ViewState&   viewState,
      93             :                         const ::com::sun::star::rendering::RenderState& renderState );
      94             :         void drawLine( const ::com::sun::star::rendering::XCanvas*      pCanvas,
      95             :                        const ::com::sun::star::geometry::RealPoint2D&   aStartPoint,
      96             :                        const ::com::sun::star::geometry::RealPoint2D&   aEndPoint,
      97             :                        const ::com::sun::star::rendering::ViewState&    viewState,
      98             :                        const ::com::sun::star::rendering::RenderState&  renderState );
      99             :         void drawBezier( const ::com::sun::star::rendering::XCanvas*            pCanvas,
     100             :                          const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
     101             :                          const ::com::sun::star::geometry::RealPoint2D&         aEndPoint,
     102             :                          const ::com::sun::star::rendering::ViewState&          viewState,
     103             :                          const ::com::sun::star::rendering::RenderState&        renderState );
     104             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     105             :             drawPolyPolygon( const ::com::sun::star::rendering::XCanvas*            pCanvas,
     106             :                              const ::com::sun::star::uno::Reference<
     107             :                                      ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
     108             :                              const ::com::sun::star::rendering::ViewState&          viewState,
     109             :                              const ::com::sun::star::rendering::RenderState&        renderState );
     110             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     111             :             strokePolyPolygon( const ::com::sun::star::rendering::XCanvas*          pCanvas,
     112             :                                const ::com::sun::star::uno::Reference<
     113             :                                        ::com::sun::star::rendering::XPolyPolygon2D >&   xPolyPolygon,
     114             :                                const ::com::sun::star::rendering::ViewState&        viewState,
     115             :                                const ::com::sun::star::rendering::RenderState&      renderState,
     116             :                                const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
     117             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     118             :             strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas*          pCanvas,
     119             :                                        const ::com::sun::star::uno::Reference<
     120             :                                                ::com::sun::star::rendering::XPolyPolygon2D >&   xPolyPolygon,
     121             :                                        const ::com::sun::star::rendering::ViewState&        viewState,
     122             :                                        const ::com::sun::star::rendering::RenderState&      renderState,
     123             :                                        const ::com::sun::star::uno::Sequence<
     124             :                                                ::com::sun::star::rendering::Texture >&      textures,
     125             :                                        const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
     126             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     127             :             strokeTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas*             pCanvas,
     128             :                                             const ::com::sun::star::uno::Reference<
     129             :                                                     ::com::sun::star::rendering::XPolyPolygon2D >&  xPolyPolygon,
     130             :                                             const ::com::sun::star::rendering::ViewState&           viewState,
     131             :                                             const ::com::sun::star::rendering::RenderState&         renderState,
     132             :                                             const ::com::sun::star::uno::Sequence<
     133             :                                                     ::com::sun::star::rendering::Texture >&         textures,
     134             :                                             const ::com::sun::star::uno::Reference<
     135             :                                                     ::com::sun::star::geometry::XMapping2D >&       xMapping,
     136             :                                             const ::com::sun::star::rendering::StrokeAttributes&    strokeAttributes );
     137             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
     138             :             queryStrokeShapes( const ::com::sun::star::rendering::XCanvas*          pCanvas,
     139             :                                const ::com::sun::star::uno::Reference<
     140             :                                        ::com::sun::star::rendering::XPolyPolygon2D >&   xPolyPolygon,
     141             :                                const ::com::sun::star::rendering::ViewState&        viewState,
     142             :                                const ::com::sun::star::rendering::RenderState&      renderState,
     143             :                                const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
     144             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     145             :             fillPolyPolygon( const ::com::sun::star::rendering::XCanvas*            pCanvas,
     146             :                              const ::com::sun::star::uno::Reference<
     147             :                                      ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
     148             :                              const ::com::sun::star::rendering::ViewState&          viewState,
     149             :                              const ::com::sun::star::rendering::RenderState&        renderState );
     150             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     151             :             fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas*            pCanvas,
     152             :                                      const ::com::sun::star::uno::Reference<
     153             :                                              ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
     154             :                                      const ::com::sun::star::rendering::ViewState&          viewState,
     155             :                                      const ::com::sun::star::rendering::RenderState&        renderState,
     156             :                                      const ::com::sun::star::uno::Sequence<
     157             :                                              ::com::sun::star::rendering::Texture >&        textures );
     158             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     159             :             fillTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas*           pCanvas,
     160             :                                           const ::com::sun::star::uno::Reference<
     161             :                                                   ::com::sun::star::rendering::XPolyPolygon2D >&    xPolyPolygon,
     162             :                                           const ::com::sun::star::rendering::ViewState&         viewState,
     163             :                                           const ::com::sun::star::rendering::RenderState&       renderState,
     164             :                                           const ::com::sun::star::uno::Sequence<
     165             :                                                   ::com::sun::star::rendering::Texture >&       textures,
     166             :                                           const ::com::sun::star::uno::Reference<
     167             :                                                   ::com::sun::star::geometry::XMapping2D >&     xMapping );
     168             : 
     169             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL
     170             :             createFont( const ::com::sun::star::rendering::XCanvas*             pCanvas,
     171             :                         const ::com::sun::star::rendering::FontRequest&         fontRequest,
     172             :                         const ::com::sun::star::uno::Sequence<
     173             :                                 ::com::sun::star::beans::PropertyValue >&       extraFontProperties,
     174             :                         const ::com::sun::star::geometry::Matrix2D&             fontMatrix );
     175             : 
     176             :         ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo >
     177             :             queryAvailableFonts( const ::com::sun::star::rendering::XCanvas*        pCanvas,
     178             :                                  const ::com::sun::star::rendering::FontInfo&       aFilter,
     179             :                                  const ::com::sun::star::uno::Sequence<
     180             :                                          ::com::sun::star::beans::PropertyValue >&  aFontProperties );
     181             : 
     182             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     183             :             drawText( const ::com::sun::star::rendering::XCanvas*           pCanvas,
     184             :                       const ::com::sun::star::rendering::StringContext&     text,
     185             :                       const ::com::sun::star::uno::Reference<
     186             :                               ::com::sun::star::rendering::XCanvasFont >&   xFont,
     187             :                       const ::com::sun::star::rendering::ViewState&         viewState,
     188             :                       const ::com::sun::star::rendering::RenderState&       renderState,
     189             :                       sal_Int8                                              textDirection );
     190             : 
     191             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     192             :             drawTextLayout( const ::com::sun::star::rendering::XCanvas*     pCanvas,
     193             :                             const ::com::sun::star::uno::Reference<
     194             :                                 ::com::sun::star::rendering::XTextLayout >& laidOutText,
     195             :                             const ::com::sun::star::rendering::ViewState&   viewState,
     196             :                             const ::com::sun::star::rendering::RenderState& renderState );
     197             : 
     198             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     199             :             drawBitmap( const ::com::sun::star::rendering::XCanvas*     pCanvas,
     200             :                         const ::com::sun::star::uno::Reference<
     201             :                                 ::com::sun::star::rendering::XBitmap >& xBitmap,
     202             :                         const ::com::sun::star::rendering::ViewState&   viewState,
     203             :                         const ::com::sun::star::rendering::RenderState& renderState );
     204             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     205             :             drawBitmapModulated( const ::com::sun::star::rendering::XCanvas*        pCanvas,
     206             :                                  const ::com::sun::star::uno::Reference<
     207             :                                          ::com::sun::star::rendering::XBitmap >&    xBitmap,
     208             :                                  const ::com::sun::star::rendering::ViewState&      viewState,
     209             :                                  const ::com::sun::star::rendering::RenderState&    renderState );
     210             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
     211           0 :             getDevice() { return css::uno::Reference< css::rendering::XGraphicDevice >(mpDevice); }
     212             : 
     213             :         // BitmapCanvasHelper functionality
     214             :         // ================================
     215             : 
     216             :         void copyRect( const ::com::sun::star::rendering::XCanvas*          pCanvas,
     217             :                        const ::com::sun::star::uno::Reference<
     218             :                                ::com::sun::star::rendering::XBitmapCanvas >&    sourceCanvas,
     219             :                        const ::com::sun::star::geometry::RealRectangle2D&   sourceRect,
     220             :                        const ::com::sun::star::rendering::ViewState&        sourceViewState,
     221             :                        const ::com::sun::star::rendering::RenderState&      sourceRenderState,
     222             :                        const ::com::sun::star::geometry::RealRectangle2D&   destRect,
     223             :                        const ::com::sun::star::rendering::ViewState&        destViewState,
     224             :                        const ::com::sun::star::rendering::RenderState&      destRenderState );
     225             : 
     226             :         ::com::sun::star::geometry::IntegerSize2D getSize();
     227             : 
     228             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >
     229             :             getScaledBitmap( const ::com::sun::star::geometry::RealSize2D&  newSize,
     230             :                              bool                                           beFast );
     231             : 
     232             :         ::com::sun::star::uno::Sequence< sal_Int8 >
     233             :             getData( ::com::sun::star::rendering::IntegerBitmapLayout&      bitmapLayout,
     234             :                      const ::com::sun::star::geometry::IntegerRectangle2D&  rect );
     235             : 
     236             :         void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >&         data,
     237             :                       const ::com::sun::star::rendering::IntegerBitmapLayout&    bitmapLayout,
     238             :                       const ::com::sun::star::geometry::IntegerRectangle2D&      rect );
     239             : 
     240             :         void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >&        color,
     241             :                        const ::com::sun::star::rendering::IntegerBitmapLayout&   bitmapLayout,
     242             :                        const ::com::sun::star::geometry::IntegerPoint2D&         pos );
     243             : 
     244             :         ::com::sun::star::uno::Sequence< sal_Int8 >
     245             :             getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
     246             :                       const ::com::sun::star::geometry::IntegerPoint2D& pos );
     247             : 
     248             :         ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout();
     249             : 
     250             :         /** Called from XCanvas base classes, to notify that content
     251             :             is _about_ to change
     252             :         */
     253           0 :         void modifying() {}
     254             : 
     255           0 :         bool hasAlpha() const { return mbHaveAlpha; }
     256             : 
     257             :         enum ColorType
     258             :         {
     259             :             LINE_COLOR, FILL_COLOR, TEXT_COLOR, IGNORE_COLOR
     260             :         };
     261             : 
     262             :         void doPolyPolygonPath( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
     263             :                                 Operation aOperation,
     264             :                                 bool bNoLineJoin = false,
     265             :                                 const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* pTextures=NULL,
     266             :                                 ::cairo::Cairo* pCairo=NULL ) const;
     267             : 
     268             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > implDrawBitmapSurface(
     269             :                    const ::com::sun::star::rendering::XCanvas*      pCanvas,
     270             :                    const ::cairo::SurfaceSharedPtr&                 pSurface,
     271             :                    const ::com::sun::star::rendering::ViewState&    viewState,
     272             :                    const ::com::sun::star::rendering::RenderState&  renderState,
     273             :                    const ::com::sun::star::geometry::IntegerSize2D& rSize,
     274             :                    bool bModulateColors,
     275             :                    bool bHasAlpha );
     276             : 
     277             :         bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
     278             :               const ::com::sun::star::rendering::ViewState& viewState,
     279             :               const ::com::sun::star::rendering::RenderState& renderState );
     280             : 
     281             :     protected:
     282             :         /** Surface provider
     283             : 
     284             :             Deliberately not a refcounted reference, because of
     285             :             potential circular references for canvas. Provides us with
     286             :             our output surface and associated functionality.
     287             :          */
     288             :         SurfaceProvider* mpSurfaceProvider;
     289             : 
     290             :         /** Phyical output device
     291             : 
     292             :             Deliberately not a refcounted reference, because of
     293             :             potential circular references for spritecanvas.
     294             :          */
     295             :         ::com::sun::star::rendering::XGraphicDevice* mpDevice;
     296             : 
     297             :     private:
     298             : 
     299             :         boost::shared_ptr<VirtualDevice> mpVirtualDevice;
     300             : 
     301             :         void useStates( const ::com::sun::star::rendering::ViewState& viewState,
     302             :                         const ::com::sun::star::rendering::RenderState& renderState,
     303             :                         bool setColor );
     304             : 
     305             :         com::sun::star::rendering::IntegerBitmapLayout impl_getMemoryLayout( sal_Int32 nWidth, sal_Int32 nHeight );
     306             : 
     307             :         /// When true, content is able to represent alpha
     308             :         bool mbHaveAlpha;
     309             : 
     310             :         ::cairo::CairoSharedPtr     mpCairo;
     311             :         ::cairo::SurfaceSharedPtr   mpSurface;
     312             :         ::basegfx::B2ISize maSize;
     313             :     };
     314             : 
     315             :     /// also needed from SpriteHelper
     316             :     void doPolyPolygonImplementation( ::basegfx::B2DPolyPolygon aPolyPolygon,
     317             :                                       Operation aOperation,
     318             :                                       ::cairo::Cairo* pCairo,
     319             :                                       const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >* pTextures,
     320             :                                       const SurfaceProviderRef& pDevice,
     321             :                                       ::com::sun::star::rendering::FillRule eFillrule );
     322             : }
     323             : 
     324             : #endif // INCLUDED_CANVAS_SOURCE_CAIRO_CAIRO_CANVASHELPER_HXX
     325             : 
     326             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10