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

Generated by: LCOV version 1.10