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