LibreOffice Module vcl (master)  1
Qt5Graphics.hxx
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 #pragma once
21 
22 #include <salgdi.hxx>
23 
24 #include <memory>
25 
26 #include <QtGui/QPainter>
27 #include <QtGui/QPainterPath>
28 #include <QtGui/QRegion>
29 
30 #include "Qt5GraphicsBase.hxx"
31 
33 class QImage;
34 class QPushButton;
35 class Qt5Font;
36 class Qt5FontFace;
37 class Qt5Frame;
38 class Qt5Painter;
39 
40 class Qt5Graphics final : public SalGraphics, public Qt5GraphicsBase
41 {
42  friend class Qt5Bitmap;
43  friend class Qt5Painter;
44 
46  QImage* m_pQImage;
47  QRegion m_aClipRegion;
48  QPainterPath m_aClipPath;
51  QPainter::CompositionMode m_eCompositionMode;
52 
55 
56  Qt5Graphics(Qt5Frame* pFrame, QImage* pQImage);
57 
58  void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
59 
60  void handleDamage(const tools::Rectangle&) override;
61 
62 public:
64  : Qt5Graphics(pFrame, nullptr)
65  {
66  }
67  Qt5Graphics(QImage* pQImage)
68  : Qt5Graphics(nullptr, pQImage)
69  {
70  }
71  virtual ~Qt5Graphics() override;
72 
73  void ChangeQImage(QImage* pImage);
74 
75  virtual SalGraphicsImpl* GetImpl() const override;
76  virtual SystemGraphicsData GetGraphicsData() const override;
77  virtual bool supportsOperation(OutDevSupportType) const override;
78  virtual OUString getRenderBackendName() const override { return "qt5"; }
79 
80 #if ENABLE_CAIRO_CANVAS
81  virtual bool SupportsCairo() const override;
83  CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
84  virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y,
85  int width, int height) const override;
86  virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice,
87  const BitmapSystemData& rData,
88  const Size& rSize) const override;
89  virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface,
90  const basegfx::B2ISize& rSize) const override;
91 #endif // ENABLE_CAIRO_CANVAS
92 
93  // GDI
94 
95  virtual bool setClipRegion(const vcl::Region&) override;
96  virtual void ResetClipRegion() override;
97 
98  virtual void drawPixel(tools::Long nX, tools::Long nY) override;
99  virtual void drawPixel(tools::Long nX, tools::Long nY, Color nColor) override;
100  virtual void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2,
101  tools::Long nY2) override;
102  virtual void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth,
103  tools::Long nHeight) override;
104  virtual void drawPolyLine(sal_uInt32 nPoints, const Point* pPtAry) override;
105  virtual void drawPolygon(sal_uInt32 nPoints, const Point* pPtAry) override;
106  virtual void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints,
107  const Point** pPtAry) override;
108  virtual bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
109  const basegfx::B2DPolyPolygon&, double fTransparency) override;
110  virtual bool drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPtAry,
111  const PolyFlags* pFlgAry) override;
112  virtual bool drawPolygonBezier(sal_uInt32 nPoints, const Point* pPtAry,
113  const PolyFlags* pFlgAry) override;
114  virtual bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints,
115  const Point* const* pPtAry,
116  const PolyFlags* const* pFlgAry) override;
117  virtual bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice,
118  const basegfx::B2DPolygon&, double fTransparency, double fLineWidths,
119  const std::vector<double>* pStroke, // MM01
120  basegfx::B2DLineJoin, css::drawing::LineCap eLineCap,
121  double fMiterMinimumAngle, bool bPixelSnapHairline) override;
122  virtual bool drawGradient(const tools::PolyPolygon&, const Gradient&) override;
123 
124  virtual void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX,
125  tools::Long nSrcY, tools::Long nSrcWidth, tools::Long nSrcHeight,
126  bool bWindowInvalidate) override;
127 
128  virtual void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override;
129  virtual void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) override;
130  virtual void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
131  const SalBitmap& rTransparentBitmap) override;
132  virtual void drawMask(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
133  Color nMaskColor) override;
134 
135  virtual std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth,
136  tools::Long nHeight) override;
137  virtual Color getPixel(tools::Long nX, tools::Long nY) override;
138 
139  virtual void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
140  SalInvert nFlags) override;
141  virtual void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) override;
142 
143  virtual bool drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
144  void* pPtr, sal_uInt32 nSize) override;
145 
146  virtual bool blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) override;
147 
148  virtual bool blendAlphaBitmap(const SalTwoRect&, const SalBitmap& rSrcBitmap,
149  const SalBitmap& rMaskBitmap,
150  const SalBitmap& rAlphaBitmap) override;
151 
152  virtual bool drawAlphaBitmap(const SalTwoRect&, const SalBitmap& rSourceBitmap,
153  const SalBitmap& rAlphaBitmap) override;
154 
155  bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX,
156  const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap,
157  const SalBitmap* pAlphaBitmap, double fAlpha) override;
158  virtual bool hasFastDrawTransformedBitmap() const override;
159 
160  virtual bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth,
161  tools::Long nHeight, sal_uInt8 nTransparency) override;
162 
163  virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
164  virtual sal_uInt16 GetBitCount() const override;
165  virtual tools::Long GetGraphicsWidth() const override;
166 
167  virtual void SetLineColor() override;
168  virtual void SetLineColor(Color nColor) override;
169  virtual void SetFillColor() override;
170  virtual void SetFillColor(Color nColor) override;
171  virtual void SetXORMode(bool bSet, bool bInvertOnly) override;
172  virtual void SetROPLineColor(SalROPColor nROPColor) override;
173  virtual void SetROPFillColor(SalROPColor nROPColor) override;
174 
175  // Text rendering + font support
176 
177  virtual void SetTextColor(Color nColor) override;
178  virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
179  virtual void GetFontMetric(ImplFontMetricDataRef&, int nFallbackLevel) override;
180  virtual FontCharMapRef GetFontCharMap() const override;
181  virtual bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const override;
182  virtual void GetDevFontList(PhysicalFontCollection*) override;
183  virtual void ClearDevFontCache() override;
184  virtual bool AddTempDevFont(PhysicalFontCollection*, const OUString& rFileURL,
185  const OUString& rFontName) override;
186  virtual bool CreateFontSubset(const OUString& rToFile, const PhysicalFontFace* pFont,
187  const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
188  sal_Int32* pWidths, int nGlyphs,
189  FontSubsetInfo& rInfo // out parameter
190  ) override;
191 
192  virtual const void* GetEmbedFontData(const PhysicalFontFace*, tools::Long* pDataLen) override;
193  virtual void FreeEmbedFontData(const void* pData, tools::Long nDataLen) override;
194 
195  virtual void GetGlyphWidths(const PhysicalFontFace*, bool bVertical,
196  std::vector<sal_Int32>& rWidths, Ucs2UIntMap& rUnicodeEnc) override;
197 
198  virtual std::unique_ptr<GenericSalLayout> GetTextLayout(int nFallbackLevel) override;
199  virtual void DrawTextLayout(const GenericSalLayout&) override;
200 };
201 
202 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ResetClipRegion() override
virtual void GetGlyphWidths(const PhysicalFontFace *, bool bVertical, std::vector< sal_Int32 > &rWidths, Ucs2UIntMap &rUnicodeEnc) override
void drawScaledImage(const SalTwoRect &rPosAry, const QImage &rImage)
virtual bool AddTempDevFont(PhysicalFontCollection *, const OUString &rFileURL, const OUString &rFontName) override
SalROPColor
Definition: salgtype.hxx:71
virtual tools::Long GetGraphicsWidth() const override
#define MAX_FALLBACK
Definition: sallayout.hxx:42
long Long
virtual std::shared_ptr< SalBitmap > getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override
virtual sal_uInt16 GetBitCount() const override
virtual FontCharMapRef GetFontCharMap() const override
virtual void SetFont(LogicalFontInstance *, int nFallbackLevel) override
virtual std::unique_ptr< GenericSalLayout > GetTextLayout(int nFallbackLevel) override
virtual void ClearDevFontCache() override
virtual bool blendAlphaBitmap(const SalTwoRect &, const SalBitmap &rSrcBitmap, const SalBitmap &rMaskBitmap, const SalBitmap &rAlphaBitmap) override
Draw the bitmap by blending using the mask and alpha channel.
Color m_aLineColor
Definition: Qt5Graphics.hxx:49
sal_uInt16 sal_GlyphId
Definition: glyphitem.hxx:28
virtual bool hasFastDrawTransformedBitmap() const override
Used e.g.
virtual bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) override
Render solid rectangle with given transparency.
OutDevSupportType
Definition: vclenum.hxx:196
Qt5Graphics(Qt5Frame *pFrame)
Definition: Qt5Graphics.hxx:63
Qt5Frame * m_pFrame
Definition: Qt5Graphics.hxx:45
QRegion m_aClipRegion
Definition: Qt5Graphics.hxx:47
virtual void GetDevFontList(PhysicalFontCollection *) override
virtual SalGraphicsImpl * GetImpl() const override
virtual ~Qt5Graphics() override
virtual void copyBits(const SalTwoRect &rPosAry, SalGraphics *pSrcGraphics) override
bool drawTransformedBitmap(const basegfx::B2DPoint &rNull, const basegfx::B2DPoint &rX, const basegfx::B2DPoint &rY, const SalBitmap &rSourceBitmap, const SalBitmap *pAlphaBitmap, double fAlpha) override
draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system ...
abstract base class for physical font faces
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
virtual void SetXORMode(bool bSet, bool bInvertOnly) override
virtual void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) override
virtual bool drawPolyLineBezier(sal_uInt32 nPoints, const Point *pPtAry, const PolyFlags *pFlgAry) override
void ChangeQImage(QImage *pImage)
virtual void drawPixel(tools::Long nX, tools::Long nY) override
virtual void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32 *pPoints, const Point **pPtAry) override
virtual OUString getRenderBackendName() const override
Definition: Qt5Graphics.hxx:78
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:303
SalInvert
Definition: salgtype.hxx:75
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
virtual const void * GetEmbedFontData(const PhysicalFontFace *, tools::Long *pDataLen) override
virtual SystemGraphicsData GetGraphicsData() const override
virtual void drawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap) override
virtual void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, SalInvert nFlags) override
virtual bool drawAlphaBitmap(const SalTwoRect &, const SalBitmap &rSourceBitmap, const SalBitmap &rAlphaBitmap) override
Render bitmap with alpha channel.
QImage * m_pQImage
Definition: Qt5Graphics.hxx:46
Color m_aFillColor
Definition: Qt5Graphics.hxx:50
Color m_aTextColor
Definition: Qt5Graphics.hxx:54
virtual void drawMask(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap, Color nMaskColor) override
virtual bool drawGradient(const tools::PolyPolygon &, const Gradient &) override
virtual bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32 *pPoints, const Point *const *pPtAry, const PolyFlags *const *pFlgAry) override
virtual void GetFontMetric(ImplFontMetricDataRef &, int nFallbackLevel) override
void handleDamage(const tools::Rectangle &) override
Handle damage done by drawing with a widget draw override.
virtual void drawPolygon(sal_uInt32 nPoints, const Point *pPtAry) override
virtual void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY, tools::Long nSrcWidth, tools::Long nSrcHeight, bool bWindowInvalidate) override
virtual void drawPolyLine(sal_uInt32 nPoints, const Point *pPtAry) override
unsigned char sal_uInt8
virtual void DrawTextLayout(const GenericSalLayout &) override
virtual void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY) override
Qt5Graphics(Qt5Frame *pFrame, QImage *pQImage)
virtual void SetTextColor(Color nColor) override
virtual void SetROPLineColor(SalROPColor nROPColor) override
QPainterPath m_aClipPath
Definition: Qt5Graphics.hxx:48
virtual Color getPixel(tools::Long nX, tools::Long nY) override
virtual void SetROPFillColor(SalROPColor nROPColor) override
virtual bool setClipRegion(const vcl::Region &) override
virtual void SetFillColor() override
std::map< sal_Ucs, sal_uInt32 > Ucs2UIntMap
Definition: salgdi.hxx:64
virtual bool drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, void *pPtr, sal_uInt32 nSize) override
rtl::Reference< Qt5Font > m_pTextStyle[MAX_FALLBACK]
Definition: Qt5Graphics.hxx:53
QPainter::CompositionMode m_eCompositionMode
Definition: Qt5Graphics.hxx:51
virtual void SetLineColor() override
virtual bool drawPolygonBezier(sal_uInt32 nPoints, const Point *pPtAry, const PolyFlags *pFlgAry) override
virtual bool supportsOperation(OutDevSupportType) const override
virtual void FreeEmbedFontData(const void *pData, tools::Long nDataLen) override
Qt5Graphics(QImage *pQImage)
Definition: Qt5Graphics.hxx:67
virtual bool blendBitmap(const SalTwoRect &, const SalBitmap &rBitmap) override
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) override
PolyFlags
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override