LCOV - code coverage report
Current view: top level - canvas/source/vcl - canvashelper.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 3 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 3 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             : #ifndef INCLUDED_CANVAS_SOURCE_VCL_CANVASHELPER_HXX
      21             : #define INCLUDED_CANVAS_SOURCE_VCL_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 <vcl/outdev.hxx>
      28             : 
      29             : #include <canvas/vclwrapper.hxx>
      30             : 
      31             : #include "cachedbitmap.hxx"
      32             : #include "outdevprovider.hxx"
      33             : 
      34             : #include <boost/utility.hpp>
      35             : 
      36             : 
      37             : namespace vclcanvas
      38             : {
      39             :     class SpriteCanvas;
      40             : 
      41             :     /** Helper class for basic canvas functionality. Also offers
      42             :         optional backbuffer painting, when providing it with a second
      43             :         OutputDevice to render into.
      44             :      */
      45           0 :     class CanvasHelper : private ::boost::noncopyable
      46             :     {
      47             :     public:
      48             :         /** Create canvas helper
      49             :          */
      50             :         CanvasHelper();
      51             : 
      52             :         /// Release all references
      53             :         void disposing();
      54             : 
      55             :         /** Initialize canvas helper
      56             : 
      57             :             This method late-initializes the canvas helper, providing
      58             :             it with the necessary device and output objects. Note that
      59             :             the CanvasHelper does <em>not</em> take ownership of the
      60             :             passed rDevice reference, nor does it perform any
      61             :             reference counting. Thus, to prevent the reference counted
      62             :             SpriteCanvas object from deletion, the user of this class
      63             :             is responsible for holding ref-counted references itself!
      64             : 
      65             :             @param rDevice
      66             :             Reference device this canvas is associated with
      67             : 
      68             :             @param rOutDev
      69             :             Set primary output device for this canvas. That's where
      70             :             all content is output to.
      71             : 
      72             :             @param bProtect
      73             :             When true, all output operations preserve outdev
      74             :             state. When false, outdev state might change at any time.
      75             : 
      76             :             @param bHaveAlpha
      77             :             When true, hasAlpha() will always return true, otherwise, false.
      78             :          */
      79             :         void init( ::com::sun::star::rendering::XGraphicDevice& rDevice,
      80             :                    const OutDevProviderSharedPtr&               rOutDev,
      81             :                    bool                                         bProtect,
      82             :                    bool                                         bHaveAlpha );
      83             : 
      84             :         /** Set primary output device
      85             : 
      86             :             This changes the primary output device, where rendering is
      87             :             sent to.
      88             :          */
      89             :         void setOutDev( const OutDevProviderSharedPtr&  rOutDev,
      90             :                         bool                            bProtect);
      91             : 
      92             :         /** Set secondary output device
      93             : 
      94             :             Used for sprites, to generate mask bitmap.
      95             :          */
      96             :         void setBackgroundOutDev( const OutDevProviderSharedPtr& rOutDev );
      97             : 
      98             : 
      99             :         // CanvasHelper functionality
     100             :         // ==========================
     101             : 
     102             :         // XCanvas (only providing, not implementing the
     103             :         // interface. Also note subtle method parameter differences)
     104             :         void clear();
     105             :         void drawPoint( const ::com::sun::star::rendering::XCanvas*         rCanvas,
     106             :                         const ::com::sun::star::geometry::RealPoint2D&      aPoint,
     107             :                         const ::com::sun::star::rendering::ViewState&       viewState,
     108             :                         const ::com::sun::star::rendering::RenderState&     renderState );
     109             :         void drawLine( const ::com::sun::star::rendering::XCanvas*      rCanvas,
     110             :                        const ::com::sun::star::geometry::RealPoint2D&   aStartPoint,
     111             :                        const ::com::sun::star::geometry::RealPoint2D&   aEndPoint,
     112             :                        const ::com::sun::star::rendering::ViewState&    viewState,
     113             :                        const ::com::sun::star::rendering::RenderState&  renderState );
     114             :         void drawBezier( const ::com::sun::star::rendering::XCanvas*            rCanvas,
     115             :                          const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment,
     116             :                          const ::com::sun::star::geometry::RealPoint2D&         aEndPoint,
     117             :                          const ::com::sun::star::rendering::ViewState&          viewState,
     118             :                          const ::com::sun::star::rendering::RenderState&        renderState );
     119             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     120             :             drawPolyPolygon( const ::com::sun::star::rendering::XCanvas*        rCanvas,
     121             :                              const ::com::sun::star::uno::Reference<
     122             :                                  ::com::sun::star::rendering::XPolyPolygon2D >&     xPolyPolygon,
     123             :                              const ::com::sun::star::rendering::ViewState&      viewState,
     124             :                              const ::com::sun::star::rendering::RenderState&    renderState );
     125             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     126             :             strokePolyPolygon( const ::com::sun::star::rendering::XCanvas*          rCanvas,
     127             :                                const ::com::sun::star::uno::Reference<
     128             :                                        ::com::sun::star::rendering::XPolyPolygon2D >&   xPolyPolygon,
     129             :                                const ::com::sun::star::rendering::ViewState&        viewState,
     130             :                                const ::com::sun::star::rendering::RenderState&      renderState,
     131             :                                const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
     132             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     133             :             strokeTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas*          rCanvas,
     134             :                                        const ::com::sun::star::uno::Reference<
     135             :                                                ::com::sun::star::rendering::XPolyPolygon2D >&   xPolyPolygon,
     136             :                                        const ::com::sun::star::rendering::ViewState&        viewState,
     137             :                                        const ::com::sun::star::rendering::RenderState&      renderState,
     138             :                                        const ::com::sun::star::uno::Sequence<
     139             :                                                ::com::sun::star::rendering::Texture >&      textures,
     140             :                                        const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
     141             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     142             :             strokeTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas*             rCanvas,
     143             :                                             const ::com::sun::star::uno::Reference<
     144             :                                                     ::com::sun::star::rendering::XPolyPolygon2D >&  xPolyPolygon,
     145             :                                             const ::com::sun::star::rendering::ViewState&           viewState,
     146             :                                             const ::com::sun::star::rendering::RenderState&         renderState,
     147             :                                             const ::com::sun::star::uno::Sequence<
     148             :                                                     ::com::sun::star::rendering::Texture >&         textures,
     149             :                                             const ::com::sun::star::uno::Reference<
     150             :                                                     ::com::sun::star::geometry::XMapping2D >&       xMapping,
     151             :                                             const ::com::sun::star::rendering::StrokeAttributes&    strokeAttributes );
     152             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >
     153             :             queryStrokeShapes( const ::com::sun::star::rendering::XCanvas*          rCanvas,
     154             :                                const ::com::sun::star::uno::Reference<
     155             :                                        ::com::sun::star::rendering::XPolyPolygon2D >&   xPolyPolygon,
     156             :                                const ::com::sun::star::rendering::ViewState&        viewState,
     157             :                                const ::com::sun::star::rendering::RenderState&      renderState,
     158             :                                const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes );
     159             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     160             :             fillPolyPolygon( const ::com::sun::star::rendering::XCanvas*            rCanvas,
     161             :                              const ::com::sun::star::uno::Reference<
     162             :                                      ::com::sun::star::rendering::XPolyPolygon2D >&     xPolyPolygon,
     163             :                              const ::com::sun::star::rendering::ViewState&          viewState,
     164             :                              const ::com::sun::star::rendering::RenderState&        renderState );
     165             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     166             :             fillTexturedPolyPolygon( const ::com::sun::star::rendering::XCanvas*            rCanvas,
     167             :                                      const ::com::sun::star::uno::Reference<
     168             :                                              ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon,
     169             :                                      const ::com::sun::star::rendering::ViewState&          viewState,
     170             :                                      const ::com::sun::star::rendering::RenderState&        renderState,
     171             :                                      const ::com::sun::star::uno::Sequence<
     172             :                                              ::com::sun::star::rendering::Texture >&        textures );
     173             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     174             :             fillTextureMappedPolyPolygon( const ::com::sun::star::rendering::XCanvas*           rCanvas,
     175             :                                           const ::com::sun::star::uno::Reference<
     176             :                                                   ::com::sun::star::rendering::XPolyPolygon2D >&    xPolyPolygon,
     177             :                                           const ::com::sun::star::rendering::ViewState&         viewState,
     178             :                                           const ::com::sun::star::rendering::RenderState&       renderState,
     179             :                                           const ::com::sun::star::uno::Sequence<
     180             :                                                   ::com::sun::star::rendering::Texture >&       textures,
     181             :                                           const ::com::sun::star::uno::Reference<
     182             :                                                   ::com::sun::star::geometry::XMapping2D >&         xMapping );
     183             : 
     184             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont >
     185             :             createFont( const ::com::sun::star::rendering::XCanvas*         rCanvas,
     186             :                         const ::com::sun::star::rendering::FontRequest&     fontRequest,
     187             :                         const ::com::sun::star::uno::Sequence<
     188             :                             ::com::sun::star::beans::PropertyValue >&       extraFontProperties,
     189             :                         const ::com::sun::star::geometry::Matrix2D&         fontMatrix );
     190             : 
     191             :         ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo >
     192             :             queryAvailableFonts( const ::com::sun::star::rendering::XCanvas*        rCanvas,
     193             :                                  const ::com::sun::star::rendering::FontInfo&       aFilter,
     194             :                                  const ::com::sun::star::uno::Sequence<
     195             :                                          ::com::sun::star::beans::PropertyValue >&  aFontProperties );
     196             : 
     197             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     198             :             drawText( const ::com::sun::star::rendering::XCanvas*       rCanvas,
     199             :                       const ::com::sun::star::rendering::StringContext& text,
     200             :                       const ::com::sun::star::uno::Reference<
     201             :                               ::com::sun::star::rendering::XCanvasFont >& xFont,
     202             :                       const ::com::sun::star::rendering::ViewState&     viewState,
     203             :                       const ::com::sun::star::rendering::RenderState&   renderState,
     204             :                       sal_Int8                                          textDirection );
     205             : 
     206             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     207             :             drawTextLayout( const ::com::sun::star::rendering::XCanvas*         rCanvas,
     208             :                             const ::com::sun::star::uno::Reference<
     209             :                                     ::com::sun::star::rendering::XTextLayout >& laidOutText,
     210             :                             const ::com::sun::star::rendering::ViewState&       viewState,
     211             :                             const ::com::sun::star::rendering::RenderState&     renderState );
     212             : 
     213             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     214             :             drawBitmap( const ::com::sun::star::rendering::XCanvas*     rCanvas,
     215             :                         const ::com::sun::star::uno::Reference<
     216             :                                 ::com::sun::star::rendering::XBitmap >& xBitmap,
     217             :                         const ::com::sun::star::rendering::ViewState&   viewState,
     218             :                         const ::com::sun::star::rendering::RenderState& renderState );
     219             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     220             :             drawBitmapModulated( const ::com::sun::star::rendering::XCanvas*        rCanvas,
     221             :                                  const ::com::sun::star::uno::Reference<
     222             :                                          ::com::sun::star::rendering::XBitmap >&        xBitmap,
     223             :                                  const ::com::sun::star::rendering::ViewState&      viewState,
     224             :                                  const ::com::sun::star::rendering::RenderState&    renderState );
     225             :         // cast away const, need to change refcount (as this is
     226             :         // ~invisible to client code, still logically const)
     227             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >
     228           0 :             getDevice() { return css::uno::Reference< css::rendering::XGraphicDevice >(mpDevice); }
     229             : 
     230             : 
     231             :         // BitmapCanvasHelper functionality
     232             :         // ================================
     233             : 
     234             :         ::com::sun::star::geometry::IntegerSize2D getSize();
     235             : 
     236             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > queryBitmapCanvas();
     237             : 
     238             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >
     239             :             getScaledBitmap( const ::com::sun::star::geometry::RealSize2D&  newSize,
     240             :                              bool                                           beFast );
     241             : 
     242             :         ::com::sun::star::uno::Sequence< sal_Int8 >
     243             :             getData( ::com::sun::star::rendering::IntegerBitmapLayout&      bitmapLayout,
     244             :                      const ::com::sun::star::geometry::IntegerRectangle2D&  rect );
     245             : 
     246             :         void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >&        data,
     247             :                       const ::com::sun::star::rendering::IntegerBitmapLayout&   bitmapLayout,
     248             :                       const ::com::sun::star::geometry::IntegerRectangle2D&     rect );
     249             : 
     250             :         void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >&       color,
     251             :                        const ::com::sun::star::rendering::IntegerBitmapLayout&  bitmapLayout,
     252             :                        const ::com::sun::star::geometry::IntegerPoint2D&        pos );
     253             : 
     254             :         ::com::sun::star::uno::Sequence< sal_Int8 >
     255             :             getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
     256             :                       const ::com::sun::star::geometry::IntegerPoint2D& pos );
     257             : 
     258             :         ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout();
     259             : 
     260             :         /// Repaint a cached bitmap
     261             :         bool repaint( const GraphicObjectSharedPtr&                   rGrf,
     262             :                       const ::com::sun::star::rendering::ViewState&   viewState,
     263             :                       const ::com::sun::star::rendering::RenderState& renderState,
     264             :                       const ::Point&                                  rPt,
     265             :                       const ::Size&                                   rSz,
     266             :                       const GraphicAttr&                              rAttr ) const;
     267             : 
     268             :         /** Flush drawing queue.
     269             : 
     270             :             This only works for Window canvases, and ensures that all
     271             :             pending render operations are flushed to the
     272             :             driver/hardware.
     273             :          */
     274             :         void flush() const;
     275             : 
     276             :         enum ColorType
     277             :         {
     278             :             LINE_COLOR, FILL_COLOR, TEXT_COLOR, IGNORE_COLOR
     279             :         };
     280             : 
     281             :         // returns transparency of color
     282             :         int setupOutDevState( const ::com::sun::star::rendering::ViewState&     viewState,
     283             :                               const ::com::sun::star::rendering::RenderState&   renderState,
     284             :                               ColorType                                         eColorType ) const;
     285             : 
     286           0 :         bool hasAlpha() const { return mbHaveAlpha; }
     287             : 
     288             :     protected:
     289             :         /** Phyical output device
     290             : 
     291             :             Deliberately not a refcounted reference, because of
     292             :             potential circular references for spritecanvas.
     293             :          */
     294             :         ::com::sun::star::rendering::XGraphicDevice* mpDevice;
     295             : 
     296             :         /// Rendering to this outdev preserves its state
     297             :         OutDevProviderSharedPtr                      mpProtectedOutDev;
     298             : 
     299             :         /// Rendering to this outdev does not preserve its state
     300             :         OutDevProviderSharedPtr                      mpOutDev;
     301             : 
     302             :         /// Rendering to this outdev does not preserve its state
     303             :         OutDevProviderSharedPtr                      mp2ndOutDev;
     304             : 
     305             :         /// When true, content is able to represent alpha
     306             :         bool                                         mbHaveAlpha;
     307             : 
     308             :     private:
     309             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     310             :             implDrawBitmap( const ::com::sun::star::rendering::XCanvas*     rCanvas,
     311             :                             const ::com::sun::star::uno::Reference<
     312             :                                     ::com::sun::star::rendering::XBitmap >&     xBitmap,
     313             :                             const ::com::sun::star::rendering::ViewState&   viewState,
     314             :                             const ::com::sun::star::rendering::RenderState& renderState,
     315             :                             bool                                            bModulateColors );
     316             : 
     317             :         bool setupTextOutput( ::Point&                                                                              o_rOutPos,
     318             :                               const ::com::sun::star::rendering::ViewState&                                         viewState,
     319             :                               const ::com::sun::star::rendering::RenderState&                                       renderState,
     320             :                               const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont >&   xFont ) const;
     321             : 
     322             :     };
     323             : }
     324             : 
     325             : #endif // INCLUDED_CANVAS_SOURCE_VCL_CANVASHELPER_HXX
     326             : 
     327             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11