LibreOffice Module vcl (master)  1
genpspgraphics.h
Go to the documentation of this file.
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_GENERIC_GENPSPGRAPHICS_H
21 #define INCLUDED_VCL_INC_GENERIC_GENPSPGRAPHICS_H
22 
23 #include <vcl/vclenum.hxx>
24 #include <config_cairo_canvas.h>
25 
26 #include <unx/fontmanager.hxx>
27 #include <salgdi.hxx>
28 #include <sallayout.hxx>
29 
30 class PhysicalFontFace;
32 
33 namespace psp { struct JobData; class PrinterGfx; }
34 
35 class FreetypeFont;
36 class FontAttributes;
37 class SalInfoPrinter;
38 class ImplFontMetricData;
39 
41 {
44 
45  FreetypeFont* m_pFreetypeFont[ MAX_FALLBACK ];
46 public:
48  virtual ~GenPspGraphics() override;
49 
50  void Init( psp::JobData* pJob, psp::PrinterGfx* pGfx );
51 
52  // helper methods
53  static const void * DoGetEmbedFontData(psp::fontID aFont, long* pDataLen);
54  static void DoFreeEmbedFontData( const void* pData, long nLen );
55 
56  // helper methods for sharing with X11SalGraphics
57  static void DoGetGlyphWidths( psp::fontID aFont,
58  bool bVertical,
59  std::vector< sal_Int32 >& rWidths,
60  Ucs2UIntMap& rUnicodeEnc );
61 
62  static FontAttributes Info2FontAttributes( const psp::FastPrintFontInfo& );
63  static void AnnounceFonts( PhysicalFontCollection*,
64  const psp::FastPrintFontInfo& );
65 
66  // override all pure virtual methods
67  virtual SalGraphicsImpl*GetImpl() const override { return nullptr; };
68  virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) override;
69  virtual sal_uInt16 GetBitCount() const override;
70  virtual long GetGraphicsWidth() const override;
71 
72  virtual void ResetClipRegion() override;
73  virtual bool setClipRegion( const vcl::Region& ) override;
74 
75  virtual void SetLineColor() override;
76  virtual void SetLineColor( Color nColor ) override;
77  virtual void SetFillColor() override;
78  virtual void SetFillColor( Color nColor ) override;
79  virtual void SetXORMode( bool bSet, bool ) override;
80  virtual void SetROPLineColor( SalROPColor nROPColor ) override;
81  virtual void SetROPFillColor( SalROPColor nROPColor ) override;
82 
83  virtual void SetTextColor( Color nColor ) override;
84  virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
85  virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) override;
86  virtual FontCharMapRef GetFontCharMap() const override;
87  virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override;
88  virtual void GetDevFontList( PhysicalFontCollection* ) override;
89  // graphics must drop any cached font info
90  virtual void ClearDevFontCache() override;
92  const OUString& rFileURL,
93  const OUString& rFontName ) override;
94  static bool AddTempDevFontHelper( PhysicalFontCollection* pFontCollection,
95  const OUString& rFileURL,
96  const OUString& rFontName);
97 
98  virtual bool CreateFontSubset( const OUString& rToFile,
99  const PhysicalFontFace*,
100  const sal_GlyphId* pGlyphIDs,
101  const sal_uInt8* pEncoding,
102  sal_Int32* pWidths,
103  int nGlyphs,
104  FontSubsetInfo& rInfo ) override;
105  virtual const void* GetEmbedFontData(const PhysicalFontFace*, long* pDataLen) override;
106  virtual void FreeEmbedFontData( const void* pData, long nDataLen ) override;
107  virtual void GetGlyphWidths( const PhysicalFontFace*,
108  bool bVertical,
109  std::vector< sal_Int32 >& rWidths,
110  Ucs2UIntMap& rUnicodeEnc ) override;
111  virtual std::unique_ptr<GenericSalLayout>
112  GetTextLayout(int nFallbackLevel) override;
113  virtual void DrawTextLayout( const GenericSalLayout& ) override;
114  virtual bool supportsOperation( OutDevSupportType ) const override;
115  virtual void drawPixel( long nX, long nY ) override;
116  virtual void drawPixel( long nX, long nY, Color nColor ) override;
117  virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ) override;
118  virtual void drawRect( long nX, long nY, long nWidth, long nHeight ) override;
119  virtual void drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
120  virtual void drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry ) override;
121  virtual void drawPolyPolygon( sal_uInt32 nPoly,
122  const sal_uInt32* pPoints,
123  PCONSTSALPOINT* pPtAry ) override;
124 
125  virtual bool drawPolyPolygon(
126  const basegfx::B2DHomMatrix& rObjectToDevice,
128  double fTransparency) override;
129 
130  virtual bool drawPolyLine(
131  const basegfx::B2DHomMatrix& rObjectToDevice,
132  const basegfx::B2DPolygon&,
133  double fTransparency,
134  const basegfx::B2DVector& rLineWidths,
136  css::drawing::LineCap,
137  double fMiterMinimumAngle,
138  bool bPixelSnapHairline) override;
139  virtual bool drawPolyLineBezier( sal_uInt32 nPoints,
140  const SalPoint* pPtAry,
141  const PolyFlags* pFlgAry ) override;
142  virtual bool drawPolygonBezier( sal_uInt32 nPoints,
143  const SalPoint* pPtAry,
144  const PolyFlags* pFlgAry ) override;
145  virtual bool drawPolyPolygonBezier( sal_uInt32 nPoly,
146  const sal_uInt32* pPoints,
147  const SalPoint* const* pPtAry,
148  const PolyFlags* const* pFlgAry ) override;
149  virtual bool drawGradient( const tools::PolyPolygon&, const Gradient& ) override { return false; };
150 
151  virtual void copyArea( long nDestX,
152  long nDestY,
153  long nSrcX,
154  long nSrcY,
155  long nSrcWidth,
156  long nSrcHeight,
157  bool bWindowInvalidate) override;
158  virtual void copyBits( const SalTwoRect& rPosAry,
159  SalGraphics* pSrcGraphics ) override;
160  virtual void drawBitmap( const SalTwoRect& rPosAry,
161  const SalBitmap& rSalBitmap ) override;
162  virtual void drawBitmap( const SalTwoRect& rPosAry,
163  const SalBitmap& rSalBitmap,
164  const SalBitmap& rTransparentBitmap ) override;
165  virtual void drawMask( const SalTwoRect& rPosAry,
166  const SalBitmap& rSalBitmap,
167  Color nMaskColor ) override;
168  virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
169  virtual Color getPixel( long nX, long nY ) override;
170  virtual void invert( long nX, long nY, long nWidth, long nHeight,
171  SalInvert nFlags ) override;
172  virtual void invert( sal_uInt32 nPoints, const SalPoint* pPtAry,
173  SalInvert nFlags ) override;
174 
175  virtual bool drawEPS( long nX, long nY, long nWidth, long nHeight,
176  void* pPtr, sal_uInt32 nSize ) override;
177  virtual bool blendBitmap( const SalTwoRect&,
178  const SalBitmap& rBitmap ) override;
179  virtual bool blendAlphaBitmap( const SalTwoRect&,
180  const SalBitmap& rSrcBitmap,
181  const SalBitmap& rMaskBitmap,
182  const SalBitmap& rAlphaBitmap ) override;
183  virtual bool drawAlphaBitmap( const SalTwoRect&,
184  const SalBitmap& rSourceBitmap,
185  const SalBitmap& rAlphaBitmap ) override;
186  virtual bool drawTransformedBitmap( const basegfx::B2DPoint& rNull,
187  const basegfx::B2DPoint& rX,
188  const basegfx::B2DPoint& rY,
189  const SalBitmap& rSourceBitmap,
190  const SalBitmap* pAlphaBitmap) override;
191  virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight,
192  sal_uInt8 nTransparency ) override;
193 
194  virtual SystemGraphicsData GetGraphicsData() const override;
195 
196  virtual OUString getRenderBackendName() const override { return "genpsp"; }
197 
198 #if ENABLE_CAIRO_CANVAS
199  virtual bool SupportsCairo() const override;
200  virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
201  virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
202  virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice, const BitmapSystemData& rData, const Size& rSize) const override;
203  virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const override;
204 
205  virtual SystemFontData GetSysFontData( int nFallbacklevel ) const override;
206 #endif // ENABLE_CAIRO_CANVAS
207 };
208 
209 #endif // INCLUDED_VCL_INC_GENERIC_GENPSPGRAPHICS_H
210 
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool drawAlphaBitmap(const SalTwoRect &, const SalBitmap &rSourceBitmap, const SalBitmap &rAlphaBitmap)=0
Render bitmap with alpha channel.
virtual long GetGraphicsWidth() const =0
virtual void ClearDevFontCache()=0
virtual bool drawTransformedBitmap(const basegfx::B2DPoint &rNull, const basegfx::B2DPoint &rX, const basegfx::B2DPoint &rY, const SalBitmap &rSourceBitmap, const SalBitmap *pAlphaBitmap)=0
draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system ...
psp::PrinterGfx * m_pPrinterGfx
void Init()
virtual void DrawTextLayout(const GenericSalLayout &)=0
virtual OUString getRenderBackendName() const override
SalROPColor
Definition: salgtype.hxx:80
virtual bool blendAlphaBitmap(const SalTwoRect &, const SalBitmap &rSrcBitmap, const SalBitmap &rMaskBitmap, const SalBitmap &rAlphaBitmap)=0
Draw the bitmap by blending using the mask and alpha channel.
virtual const void * GetEmbedFontData(const PhysicalFontFace *pFont, long *pDataLen)=0
psp::JobData * m_pJobData
virtual bool supportsOperation(OutDevSupportType) const =0
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
virtual bool drawGradient(const tools::PolyPolygon &, const Gradient &) override
#define MAX_FALLBACK
Definition: sallayout.hxx:41
virtual void copyArea(long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, bool bWindowInvalidate)=0
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const =0
virtual void invert(long nX, long nY, long nWidth, long nHeight, SalInvert nFlags)=0
virtual bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32 *pPoints, const SalPoint *const *pPtAry, const PolyFlags *const *pFlgAry)=0
virtual bool blendBitmap(const SalTwoRect &, const SalBitmap &rBitmap)=0
Blend the bitmap with the current buffer.
virtual void drawPolygon(sal_uInt32 nPoints, const SalPoint *pPtAry)=0
virtual bool drawPolyLineBezier(sal_uInt32 nPoints, const SalPoint *pPtAry, const PolyFlags *pFlgAry)=0
virtual bool CreateFontSubset(const OUString &rToFile, const PhysicalFontFace *pFont, const sal_GlyphId *pGlyphIDs, const sal_uInt8 *pEncoding, sal_Int32 *pWidths, int nGlyphs, FontSubsetInfo &rInfo)=0
virtual std::unique_ptr< GenericSalLayout > GetTextLayout(int nFallbackLevel)=0
sal_uInt16 sal_GlyphId
Definition: glyphitem.hxx:26
OutDevSupportType
Definition: vclenum.hxx:195
virtual FontCharMapRef GetFontCharMap() const =0
virtual SalGraphicsImpl * GetImpl() const override
virtual void SetROPLineColor(SalROPColor nROPColor)=0
virtual void FreeEmbedFontData(const void *pData, long nDataLen)=0
virtual void drawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap)=0
abstract base class for physical font faces
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
virtual void SetFillColor()=0
virtual Color getPixel(long nX, long nY)=0
virtual bool setClipRegion(const vcl::Region &)=0
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY)=0
virtual void SetLineColor()=0
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
virtual std::shared_ptr< SalBitmap > getBitmap(long nX, long nY, long nWidth, long nHeight)=0
SalInvert
Definition: salgtype.hxx:84
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
virtual SystemGraphicsData GetGraphicsData() const =0
virtual void copyBits(const SalTwoRect &rPosAry, SalGraphics *pSrcGraphics)=0
virtual void GetGlyphWidths(const PhysicalFontFace *pFont, bool bVertical, std::vector< sal_Int32 > &rWidths, Ucs2UIntMap &rUnicodeEnc)=0
virtual void SetXORMode(bool bSet, bool bInvertOnly)=0
virtual sal_uInt16 GetBitCount() const =0
virtual void drawRect(long nX, long nY, long nWidth, long nHeight)=0
virtual bool drawPolygonBezier(sal_uInt32 nPoints, const SalPoint *pPtAry, const PolyFlags *pFlgAry)=0
virtual void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32 *pPoints, PCONSTSALPOINT *pPtAry)=0
unsigned char sal_uInt8
virtual void SetROPFillColor(SalROPColor nROPColor)=0
virtual void drawMask(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap, Color nMaskColor)=0
virtual void drawLine(long nX1, long nY1, long nX2, long nY2)=0
virtual void drawPixel(long nX, long nY)=0
virtual void drawPolyLine(sal_uInt32 nPoints, const SalPoint *pPtAry)=0
int fontID
Definition: fontmanager.hxx:47
virtual void GetFontMetric(ImplFontMetricDataRef &, int nFallbackLevel)=0
virtual bool AddTempDevFont(PhysicalFontCollection *, const OUString &rFileURL, const OUString &rFontName)=0
virtual void SetFont(LogicalFontInstance *, int nFallbackLevel)=0
virtual bool drawAlphaRect(long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency)=0
Render solid rectangle with given transparency.
std::map< sal_Ucs, sal_uInt32 > Ucs2UIntMap
Definition: salgdi.hxx:62
virtual void ResetClipRegion()=0
virtual bool drawEPS(long nX, long nY, long nWidth, long nHeight, void *pPtr, sal_uInt32 nSize)=0
virtual void SetTextColor(Color nColor)=0
PolyFlags
virtual void GetDevFontList(PhysicalFontCollection *)=0