LCOV - code coverage report
Current view: top level - canvas/source/vcl - canvashelper.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 4 0.0 %
Date: 2014-11-03 Functions: 0 4 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             :         void copyRect( const ::com::sun::star::rendering::XCanvas*          rCanvas,
     235             :                        const ::com::sun::star::uno::Reference<
     236             :                                ::com::sun::star::rendering::XBitmapCanvas >&    sourceCanvas,
     237             :                        const ::com::sun::star::geometry::RealRectangle2D&   sourceRect,
     238             :                        const ::com::sun::star::rendering::ViewState&        sourceViewState,
     239             :                        const ::com::sun::star::rendering::RenderState&      sourceRenderState,
     240             :                        const ::com::sun::star::geometry::RealRectangle2D&   destRect,
     241             :                        const ::com::sun::star::rendering::ViewState&        destViewState,
     242             :                        const ::com::sun::star::rendering::RenderState&      destRenderState );
     243             : 
     244             :         ::com::sun::star::geometry::IntegerSize2D getSize();
     245             : 
     246             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > queryBitmapCanvas();
     247             : 
     248             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >
     249             :             getScaledBitmap( const ::com::sun::star::geometry::RealSize2D&  newSize,
     250             :                              bool                                           beFast );
     251             : 
     252             :         ::com::sun::star::uno::Sequence< sal_Int8 >
     253             :             getData( ::com::sun::star::rendering::IntegerBitmapLayout&      bitmapLayout,
     254             :                      const ::com::sun::star::geometry::IntegerRectangle2D&  rect );
     255             : 
     256             :         void setData( const ::com::sun::star::uno::Sequence< sal_Int8 >&        data,
     257             :                       const ::com::sun::star::rendering::IntegerBitmapLayout&   bitmapLayout,
     258             :                       const ::com::sun::star::geometry::IntegerRectangle2D&     rect );
     259             : 
     260             :         void setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >&       color,
     261             :                        const ::com::sun::star::rendering::IntegerBitmapLayout&  bitmapLayout,
     262             :                        const ::com::sun::star::geometry::IntegerPoint2D&        pos );
     263             : 
     264             :         ::com::sun::star::uno::Sequence< sal_Int8 >
     265             :             getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout,
     266             :                       const ::com::sun::star::geometry::IntegerPoint2D& pos );
     267             : 
     268             :         ::com::sun::star::rendering::IntegerBitmapLayout getMemoryLayout();
     269             : 
     270             :         /// Repaint a cached bitmap
     271             :         bool repaint( const GraphicObjectSharedPtr&                   rGrf,
     272             :                       const ::com::sun::star::rendering::ViewState&   viewState,
     273             :                       const ::com::sun::star::rendering::RenderState& renderState,
     274             :                       const ::Point&                                  rPt,
     275             :                       const ::Size&                                   rSz,
     276             :                       const GraphicAttr&                              rAttr ) const;
     277             : 
     278             :         /** Flush drawing queue.
     279             : 
     280             :             This only works for Window canvases, and ensures that all
     281             :             pending render operations are flushed to the
     282             :             driver/hardware.
     283             :          */
     284             :         void flush() const;
     285             : 
     286             :         enum ColorType
     287             :         {
     288             :             LINE_COLOR, FILL_COLOR, TEXT_COLOR, IGNORE_COLOR
     289             :         };
     290             : 
     291             :         // returns transparency of color
     292             :         int setupOutDevState( const ::com::sun::star::rendering::ViewState&     viewState,
     293             :                               const ::com::sun::star::rendering::RenderState&   renderState,
     294             :                               ColorType                                         eColorType ) const;
     295             : 
     296             :         /** Called from XCanvas base classes, to notify that content
     297             :             is _about_ to change
     298             :         */
     299           0 :         void modifying() {}
     300             : 
     301           0 :         bool hasAlpha() const { return mbHaveAlpha; }
     302             : 
     303             :     protected:
     304             :         /** Phyical output device
     305             : 
     306             :             Deliberately not a refcounted reference, because of
     307             :             potential circular references for spritecanvas.
     308             :          */
     309             :         ::com::sun::star::rendering::XGraphicDevice* mpDevice;
     310             : 
     311             :         /// Rendering to this outdev preserves its state
     312             :         OutDevProviderSharedPtr                      mpProtectedOutDev;
     313             : 
     314             :         /// Rendering to this outdev does not preserve its state
     315             :         OutDevProviderSharedPtr                      mpOutDev;
     316             : 
     317             :         /// Rendering to this outdev does not preserve its state
     318             :         OutDevProviderSharedPtr                      mp2ndOutDev;
     319             : 
     320             :         /// When true, content is able to represent alpha
     321             :         bool                                         mbHaveAlpha;
     322             : 
     323             :     private:
     324             :         ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive >
     325             :             implDrawBitmap( const ::com::sun::star::rendering::XCanvas*     rCanvas,
     326             :                             const ::com::sun::star::uno::Reference<
     327             :                                     ::com::sun::star::rendering::XBitmap >&     xBitmap,
     328             :                             const ::com::sun::star::rendering::ViewState&   viewState,
     329             :                             const ::com::sun::star::rendering::RenderState& renderState,
     330             :                             bool                                            bModulateColors );
     331             : 
     332             :         bool setupTextOutput( ::Point&                                                                              o_rOutPos,
     333             :                               const ::com::sun::star::rendering::ViewState&                                         viewState,
     334             :                               const ::com::sun::star::rendering::RenderState&                                       renderState,
     335             :                               const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont >&   xFont ) const;
     336             : 
     337             :     };
     338             : }
     339             : 
     340             : #endif // INCLUDED_CANVAS_SOURCE_VCL_CANVASHELPER_HXX
     341             : 
     342             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10