LCOV - code coverage report
Current view: top level - vcl/inc/headless - svpgdi.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1 0.0 %
Date: 2014-04-14 Functions: 0 1 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_VCL_INC_HEADLESS_SVPGDI_HXX
      21             : #define INCLUDED_VCL_INC_HEADLESS_SVPGDI_HXX
      22             : 
      23             : #include <basebmp/bitmapdevice.hxx>
      24             : #include <basebmp/color.hxx>
      25             : #include <vcl/sysdata.hxx>
      26             : 
      27             : #include "salgdi.hxx"
      28             : #include "sallayout.hxx"
      29             : 
      30             : #ifdef IOS
      31             : #include "quartz/salgdi.h"
      32             : #include <premac.h>
      33             : #include <Foundation/Foundation.h>
      34             : #include <CoreGraphics/CoreGraphics.h>
      35             : #include <postmac.h>
      36             : #endif
      37             : 
      38             : class ServerFont;
      39             : 
      40             : #ifdef IOS
      41             : // To keep changes to the CoreText code shared with AOO to a minimum,
      42             : // let's continue calling the SalGraphics subclass "AquaSalGraphics" even if it
      43             : // is used by us also on iOS, where of course the term "Aqua" has no meaning at all.
      44             : // (Note that even on OS X, using the term "Aqua" is a misunderstanding or obsolete.)
      45             : #define SvpSalGraphics AquaSalGraphics
      46             : #endif
      47             : 
      48             : class SvpSalGraphics : public SalGraphics
      49             : {
      50             : #ifndef IOS
      51             :     basebmp::BitmapDeviceSharedPtr       m_aDevice;
      52             :     basebmp::BitmapDeviceSharedPtr       m_aOrigDevice;
      53             : 
      54             :     basebmp::BitmapDeviceSharedPtr       m_aClipMap;
      55             : 
      56             :     bool                                 m_bUseLineColor;
      57             :     basebmp::Color                       m_aLineColor;
      58             :     bool                                 m_bUseFillColor;
      59             :     basebmp::Color                       m_aFillColor;
      60             : 
      61             :     basebmp::DrawMode                    m_aDrawMode;
      62             : 
      63             :     // These fields are used only when we use FreeType to draw into a
      64             :     // headless backend, i.e. not on iOS.
      65             :     basebmp::Color                       m_aTextColor;
      66             :     ServerFont*                          m_pServerFont[ MAX_FALLBACK ];
      67             :     basebmp::Format                      m_eTextFmt;
      68             : 
      69             : protected:
      70             :     basegfx::B2IVector                   GetSize() { return m_aOrigDevice->getSize(); }
      71             : 
      72             : private:
      73             :     bool                                 m_bClipSetup;
      74             :     struct ClipUndoHandle {
      75             :         SvpSalGraphics                &m_rGfx;
      76             :         basebmp::BitmapDeviceSharedPtr m_aDevice;
      77           0 :         ClipUndoHandle( SvpSalGraphics *pGfx ) : m_rGfx( *pGfx ) {}
      78             :         ~ClipUndoHandle();
      79             :     };
      80             :     bool isClippedSetup( const basegfx::B2IBox &aRange, ClipUndoHandle &rUndo );
      81             :     void ensureClip();
      82             : 
      83             : public:
      84             :     void setDevice( basebmp::BitmapDeviceSharedPtr& rDevice );
      85             : 
      86             : #else
      87             :     friend class CTLayout;
      88             : 
      89             :     CGLayerRef                              mxLayer;
      90             :     // mirror AquaSalVirtualDevice::mbForeignContext for SvpSalGraphics objects related to such
      91             :     bool mbForeignContext;
      92             :     CGContextRef                            mrContext;
      93             :     int                                     mnContextStackDepth;
      94             :     class XorEmulation*                     mpXorEmulation;
      95             :     int                                     mnXorMode; // 0: off 1: on 2: invert only
      96             :     int                                     mnWidth;
      97             :     int                                     mnHeight;
      98             :     int                                  mnBitmapDepth;  // zero unless bitmap
      99             : 
     100             :     /// path representing current clip region
     101             :     CGMutablePathRef                        mxClipPath;
     102             : 
     103             :     /// Drawing colors
     104             :     /// pen color RGBA
     105             :     RGBAColor                               maLineColor;
     106             :     /// brush color RGBA
     107             :     RGBAColor                               maFillColor;
     108             : 
     109             :     // Device Font settings
     110             :     const CoreTextFontData*                 mpFontData;
     111             :     CoreTextStyle*                          mpTextStyle;
     112             :     RGBAColor                               maTextColor;
     113             :     /// allows text to be rendered without antialiasing
     114             :     bool                                    mbNonAntialiasedText;
     115             : 
     116             :     /// is this a printer graphics
     117             :     bool                                    mbPrinter;
     118             :     /// is this a virtual device graphics
     119             :     bool                                    mbVirDev;
     120             : #endif
     121             : 
     122             : protected:
     123             :     Region                               m_aClipRegion;
     124             : 
     125             : protected:
     126             :     virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
     127             :     virtual bool drawTransformedBitmap(
     128             :         const basegfx::B2DPoint& rNull,
     129             :         const basegfx::B2DPoint& rX,
     130             :         const basegfx::B2DPoint& rY,
     131             :         const SalBitmap& rSourceBitmap,
     132             :         const SalBitmap* pAlphaBitmap) SAL_OVERRIDE;
     133             :     virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) SAL_OVERRIDE;
     134             : 
     135             : public:
     136             :     SvpSalGraphics();
     137             :     virtual ~SvpSalGraphics();
     138             : 
     139             :     virtual void            GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) SAL_OVERRIDE;
     140             :     virtual sal_uInt16      GetBitCount() const SAL_OVERRIDE;
     141             :     virtual long            GetGraphicsWidth() const SAL_OVERRIDE;
     142             : 
     143             :     virtual void            ResetClipRegion() SAL_OVERRIDE;
     144             :     virtual bool            setClipRegion( const Region& ) SAL_OVERRIDE;
     145             : 
     146             :     virtual void            SetLineColor() SAL_OVERRIDE;
     147             :     virtual void            SetLineColor( SalColor nSalColor ) SAL_OVERRIDE;
     148             :     virtual void            SetFillColor() SAL_OVERRIDE;
     149             :     virtual void            SetFillColor( SalColor nSalColor ) SAL_OVERRIDE;
     150             : 
     151             :     virtual void            SetXORMode( bool bSet, bool ) SAL_OVERRIDE;
     152             : 
     153             :     virtual void            SetROPLineColor( SalROPColor nROPColor ) SAL_OVERRIDE;
     154             :     virtual void            SetROPFillColor( SalROPColor nROPColor ) SAL_OVERRIDE;
     155             : 
     156             :     virtual void            SetTextColor( SalColor nSalColor ) SAL_OVERRIDE;
     157             :     virtual sal_uInt16      SetFont( FontSelectPattern*, int nFallbackLevel ) SAL_OVERRIDE;
     158             :     virtual void            GetFontMetric( ImplFontMetricData*, int nFallbackLevel ) SAL_OVERRIDE;
     159             :     virtual const ImplFontCharMap* GetImplFontCharMap() const SAL_OVERRIDE;
     160             :     virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const SAL_OVERRIDE;
     161             :     virtual void            GetDevFontList( PhysicalFontCollection* ) SAL_OVERRIDE;
     162             :     virtual void ClearDevFontCache() SAL_OVERRIDE;
     163             :     virtual bool            AddTempDevFont( PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) SAL_OVERRIDE;
     164             :     virtual bool        CreateFontSubset( const OUString& rToFile,
     165             :                                               const PhysicalFontFace*,
     166             :                                               sal_GlyphId* pGlyphIds,
     167             :                                               sal_uInt8* pEncoding,
     168             :                                               sal_Int32* pWidths,
     169             :                                               int nGlyphs,
     170             :                                               FontSubsetInfo& rInfo
     171             :                                               ) SAL_OVERRIDE;
     172             :     virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded ) SAL_OVERRIDE;
     173             :     virtual const void*     GetEmbedFontData( const PhysicalFontFace*,
     174             :                                               const sal_Ucs* pUnicodes,
     175             :                                               sal_Int32* pWidths,
     176             :                                               FontSubsetInfo& rInfo,
     177             :                                               long* pDataLen ) SAL_OVERRIDE;
     178             :     virtual void            FreeEmbedFontData( const void* pData, long nDataLen ) SAL_OVERRIDE;
     179             :     virtual void            GetGlyphWidths( const PhysicalFontFace*,
     180             :                                             bool bVertical,
     181             :                                             Int32Vector& rWidths,
     182             :                                             Ucs2UIntMap& rUnicodeEnc ) SAL_OVERRIDE;
     183             :     virtual bool            GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ) SAL_OVERRIDE;
     184             :     virtual bool            GetGlyphOutline( sal_GlyphId nIndex, ::basegfx::B2DPolyPolygon& ) SAL_OVERRIDE;
     185             :     virtual SalLayout*      GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) SAL_OVERRIDE;
     186             :     virtual void            DrawServerFontLayout( const ServerFontLayout& ) SAL_OVERRIDE;
     187             :     virtual bool            supportsOperation( OutDevSupportType ) const SAL_OVERRIDE;
     188             :     virtual void            drawPixel( long nX, long nY ) SAL_OVERRIDE;
     189             :     virtual void            drawPixel( long nX, long nY, SalColor nSalColor ) SAL_OVERRIDE;
     190             :     virtual void            drawLine( long nX1, long nY1, long nX2, long nY2 ) SAL_OVERRIDE;
     191             :     virtual void            drawRect( long nX, long nY, long nWidth, long nHeight ) SAL_OVERRIDE;
     192             :     virtual bool            drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency ) SAL_OVERRIDE;
     193             :     virtual bool            drawPolyLine( const ::basegfx::B2DPolygon&,
     194             :                                           double fTransparency,
     195             :                                           const ::basegfx::B2DVector& rLineWidths,
     196             :                                           basegfx::B2DLineJoin,
     197             :                                           com::sun::star::drawing::LineCap) SAL_OVERRIDE;
     198             :     virtual void            drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) SAL_OVERRIDE;
     199             :     virtual void            drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) SAL_OVERRIDE;
     200             :     virtual void            drawPolyPolygon( sal_uInt32 nPoly,
     201             :                                              const sal_uInt32* pPoints,
     202             :                                              PCONSTSALPOINT* pPtAry ) SAL_OVERRIDE;
     203             :     virtual bool        drawPolyLineBezier( sal_uInt32 nPoints,
     204             :                                                 const SalPoint* pPtAry,
     205             :                                                 const sal_uInt8* pFlgAry ) SAL_OVERRIDE;
     206             :     virtual bool        drawPolygonBezier( sal_uInt32 nPoints,
     207             :                                                const SalPoint* pPtAry,
     208             :                                                const sal_uInt8* pFlgAry ) SAL_OVERRIDE;
     209             :     virtual bool        drawPolyPolygonBezier( sal_uInt32 nPoly,
     210             :                                                    const sal_uInt32* pPoints,
     211             :                                                    const SalPoint* const* pPtAry,
     212             :                                                    const sal_uInt8* const* pFlgAry ) SAL_OVERRIDE;
     213             : 
     214             :     virtual void            copyArea( long nDestX,
     215             :                                       long nDestY,
     216             :                                       long nSrcX,
     217             :                                       long nSrcY,
     218             :                                       long nSrcWidth,
     219             :                                       long nSrcHeight,
     220             :                                       sal_uInt16 nFlags ) SAL_OVERRIDE;
     221             :     virtual void            copyBits( const SalTwoRect& rPosAry,
     222             :                                       SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
     223             :     virtual void            drawBitmap( const SalTwoRect& rPosAry,
     224             :                                         const SalBitmap& rSalBitmap ) SAL_OVERRIDE;
     225             :     virtual void            drawBitmap( const SalTwoRect& rPosAry,
     226             :                                         const SalBitmap& rSalBitmap,
     227             :                                         SalColor nTransparentColor ) SAL_OVERRIDE;
     228             :     virtual void            drawBitmap( const SalTwoRect& rPosAry,
     229             :                                         const SalBitmap& rSalBitmap,
     230             :                                         const SalBitmap& rTransparentBitmap ) SAL_OVERRIDE;
     231             :     virtual void            drawMask( const SalTwoRect& rPosAry,
     232             :                                       const SalBitmap& rSalBitmap,
     233             :                                       SalColor nMaskColor ) SAL_OVERRIDE;
     234             :     virtual SalBitmap*      getBitmap( long nX, long nY, long nWidth, long nHeight ) SAL_OVERRIDE;
     235             :     virtual SalColor        getPixel( long nX, long nY ) SAL_OVERRIDE;
     236             :     virtual void            invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) SAL_OVERRIDE;
     237             :     virtual void            invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags ) SAL_OVERRIDE;
     238             : 
     239             :     virtual bool        drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) SAL_OVERRIDE;
     240             : 
     241             :     virtual SystemGraphicsData GetGraphicsData() const SAL_OVERRIDE;
     242             :     virtual SystemFontData  GetSysFontData( int nFallbacklevel ) const SAL_OVERRIDE;
     243             : 
     244             : #ifdef IOS
     245             :     void                SetVirDevGraphics( CGLayerRef xLayer, CGContextRef xContext, int = 0 );
     246             : 
     247             :     bool CheckContext();
     248             :     CGContextRef GetContext();
     249             :     bool GetRawFontData( const PhysicalFontFace* pFontData,
     250             :                          std::vector<unsigned char>& rBuffer,
     251             :                          bool* pJustCFF );
     252             :     void                RefreshRect( const CGRect& ) { };
     253             :     void                RefreshRect(float lX, float lY, float lWidth, float lHeight);
     254             :     void                SetState();
     255             :     void                UnsetState();
     256             :     void                InvalidateContext();
     257             :     bool                IsPenVisible() const    { return maLineColor.IsVisible(); }
     258             :     bool                IsBrushVisible() const  { return maFillColor.IsVisible(); }
     259             :     void                ImplDrawPixel( long nX, long nY, const RGBAColor& ); // helper to draw single pixels
     260             :     CGPoint*            makeCGptArray(sal_uInt32 nPoints, const SalPoint*  pPtAry);
     261             :     bool IsFlipped() const { return false; }
     262             :     void ApplyXorContext();
     263             :     void Pattern50Fill();
     264             : #endif
     265             : };
     266             : 
     267             : #endif // INCLUDED_VCL_INC_HEADLESS_SVPGDI_HXX
     268             : 
     269             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10