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 "Qt5Data.hxx"
31 
33 class QImage;
34 class QPushButton;
35 class Qt5Font;
36 class Qt5FontFace;
37 class Qt5Frame;
38 class Qt5Painter;
39 
40 class Qt5Graphics : public SalGraphics
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 
56  std::unique_ptr<QPushButton> m_focusedButton;
57  std::unique_ptr<QImage> m_image;
59 
60  Qt5Graphics(Qt5Frame* pFrame, QImage* pQImage);
61 
62  void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
63 
64 protected:
65  void handleDamage(const tools::Rectangle&) override;
66 
67 public:
69  : Qt5Graphics(pFrame, nullptr)
70  {
71  }
72  Qt5Graphics(QImage* pQImage)
73  : Qt5Graphics(nullptr, pQImage)
74  {
75  }
76  virtual ~Qt5Graphics() override;
77 
78  void ChangeQImage(QImage* pImage);
79 
80  virtual SalGraphicsImpl* GetImpl() const override;
81  virtual SystemGraphicsData GetGraphicsData() const override;
82  virtual bool supportsOperation(OutDevSupportType) const override;
83 
84 #if ENABLE_CAIRO_CANVAS
85  virtual bool SupportsCairo() const override;
87  CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
88  virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y,
89  int width, int height) const override;
90  virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice,
91  const BitmapSystemData& rData,
92  const Size& rSize) const override;
93  virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface,
94  const basegfx::B2ISize& rSize) const override;
95  virtual SystemFontData GetSysFontData(int nFallbacklevel) const override;
96 #endif // ENABLE_CAIRO_CANVAS
97 
98  // GDI
99 
100  virtual bool setClipRegion(const vcl::Region&) override;
101  virtual void ResetClipRegion() override;
102 
103  virtual void drawPixel(long nX, long nY) override;
104  virtual void drawPixel(long nX, long nY, Color nColor) override;
105  virtual void drawLine(long nX1, long nY1, long nX2, long nY2) override;
106  virtual void drawRect(long nX, long nY, long nWidth, long nHeight) override;
107  virtual void drawPolyLine(sal_uInt32 nPoints, const SalPoint* pPtAry) override;
108  virtual void drawPolygon(sal_uInt32 nPoints, const SalPoint* pPtAry) override;
109  virtual void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints,
110  PCONSTSALPOINT* pPtAry) override;
111  virtual bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
112  const basegfx::B2DPolyPolygon&, double fTransparency) override;
113  virtual bool drawPolyLineBezier(sal_uInt32 nPoints, const SalPoint* pPtAry,
114  const PolyFlags* pFlgAry) override;
115  virtual bool drawPolygonBezier(sal_uInt32 nPoints, const SalPoint* pPtAry,
116  const PolyFlags* pFlgAry) override;
117  virtual bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints,
118  const SalPoint* const* pPtAry,
119  const PolyFlags* const* pFlgAry) override;
120  virtual bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice,
121  const basegfx::B2DPolygon&, double fTransparency,
122  const basegfx::B2DVector& rLineWidths, basegfx::B2DLineJoin,
123  css::drawing::LineCap eLineCap, double fMiterMinimumAngle,
124  bool bPixelSnapHairline) override;
125  virtual bool drawGradient(const tools::PolyPolygon&, const Gradient&) override;
126 
127  virtual void copyArea(long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth,
128  long nSrcHeight, bool bWindowInvalidate) override;
129 
130  virtual void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override;
131  virtual void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) override;
132  virtual void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
133  const SalBitmap& rTransparentBitmap) override;
134  virtual void drawMask(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
135  Color nMaskColor) override;
136 
137  virtual std::shared_ptr<SalBitmap> getBitmap(long nX, long nY, long nWidth,
138  long nHeight) override;
139  virtual Color getPixel(long nX, long nY) override;
140 
141  virtual void invert(long nX, long nY, long nWidth, long nHeight, SalInvert nFlags) override;
142  virtual void invert(sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags) override;
143 
144  virtual bool drawEPS(long nX, long nY, long nWidth, long nHeight, void* pPtr,
145  sal_uInt32 nSize) override;
146 
147  virtual bool blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) override;
148 
149  virtual bool blendAlphaBitmap(const SalTwoRect&, const SalBitmap& rSrcBitmap,
150  const SalBitmap& rMaskBitmap,
151  const SalBitmap& rAlphaBitmap) override;
152 
153  virtual bool drawAlphaBitmap(const SalTwoRect&, const SalBitmap& rSourceBitmap,
154  const SalBitmap& rAlphaBitmap) override;
155 
156  bool drawTransformedBitmap(const basegfx::B2DPoint& rNull, const basegfx::B2DPoint& rX,
157  const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap,
158  const SalBitmap* pAlphaBitmap) override;
159 
160  virtual bool drawAlphaRect(long nX, long nY, long nWidth, long nHeight,
161  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 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*, long* pDataLen) override;
193  virtual void FreeEmbedFontData(const void* pData, 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 drawPolyLineBezier(sal_uInt32 nPoints, const SalPoint *pPtAry, const PolyFlags *pFlgAry) override
virtual const void * GetEmbedFontData(const PhysicalFontFace *, long *pDataLen) override
virtual bool drawPolygonBezier(sal_uInt32 nPoints, const SalPoint *pPtAry, const PolyFlags *pFlgAry) override
virtual bool AddTempDevFont(PhysicalFontCollection *, const OUString &rFileURL, const OUString &rFontName) override
SalROPColor
Definition: salgtype.hxx:80
#define MAX_FALLBACK
Definition: sallayout.hxx:41
virtual sal_uInt16 GetBitCount() const override
virtual FontCharMapRef GetFontCharMap() const override
virtual void SetFont(LogicalFontInstance *, int nFallbackLevel) override
std::unique_ptr< QImage > m_image
Definition: Qt5Graphics.hxx:57
virtual std::unique_ptr< GenericSalLayout > GetTextLayout(int nFallbackLevel) override
virtual void ClearDevFontCache() override
bool drawTransformedBitmap(const basegfx::B2DPoint &rNull, const basegfx::B2DPoint &rX, const basegfx::B2DPoint &rY, const SalBitmap &rSourceBitmap, const SalBitmap *pAlphaBitmap) override
draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system ...
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:26
OutDevSupportType
Definition: vclenum.hxx:195
Qt5Graphics(Qt5Frame *pFrame)
Definition: Qt5Graphics.hxx:68
Qt5Frame * m_pFrame
Definition: Qt5Graphics.hxx:45
QRegion m_aClipRegion
Definition: Qt5Graphics.hxx:47
virtual void drawPolyLine(sal_uInt32 nPoints, const SalPoint *pPtAry) override
virtual long GetGraphicsWidth() const override
virtual bool drawAlphaRect(long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency) override
Render solid rectangle with given transparency.
virtual void GetDevFontList(PhysicalFontCollection *) override
virtual SalGraphicsImpl * GetImpl() const override
virtual ~Qt5Graphics() override
virtual void copyBits(const SalTwoRect &rPosAry, SalGraphics *pSrcGraphics) override
abstract base class for physical font faces
virtual void drawPixel(long nX, long nY) override
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
virtual void SetXORMode(bool bSet, bool bInvertOnly) override
void ChangeQImage(QImage *pImage)
virtual void drawRect(long nX, long nY, long nWidth, long nHeight) override
QRect m_lastPopupRect
Definition: Qt5Graphics.hxx:58
virtual void invert(long nX, long nY, long nWidth, long nHeight, SalInvert nFlags) override
PhysicalFontCollection * m_pFontCollection
Definition: Qt5Graphics.hxx:53
virtual bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32 *pPoints, const SalPoint *const *pPtAry, const PolyFlags *const *pFlgAry) override
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
SalInvert
Definition: salgtype.hxx:84
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
virtual SystemGraphicsData GetGraphicsData() const override
virtual void drawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap) 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
virtual std::shared_ptr< SalBitmap > getBitmap(long nX, long nY, long nWidth, long nHeight) override
Color m_aTextColor
Definition: Qt5Graphics.hxx:55
virtual void drawMask(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap, Color nMaskColor) override
virtual bool drawGradient(const tools::PolyPolygon &, const Gradient &) override
virtual void GetFontMetric(ImplFontMetricDataRef &, int nFallbackLevel) override
virtual void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32 *pPoints, PCONSTSALPOINT *pPtAry) override
virtual void drawLine(long nX1, long nY1, long nX2, long nY2) override
void handleDamage(const tools::Rectangle &) override
Handle damage done by drawing with a widget draw override.
unsigned char sal_uInt8
virtual void DrawTextLayout(const GenericSalLayout &) override
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY) override
virtual Color getPixel(long nX, long nY) override
virtual void FreeEmbedFontData(const void *pData, long nDataLen) 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 void copyArea(long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, bool bWindowInvalidate) 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:62
virtual bool drawEPS(long nX, long nY, long nWidth, long nHeight, void *pPtr, sal_uInt32 nSize) override
rtl::Reference< Qt5Font > m_pTextStyle[MAX_FALLBACK]
Definition: Qt5Graphics.hxx:54
QPainter::CompositionMode m_eCompositionMode
Definition: Qt5Graphics.hxx:51
virtual void SetLineColor() override
virtual void drawPolygon(sal_uInt32 nPoints, const SalPoint *pPtAry) override
std::unique_ptr< QPushButton > m_focusedButton
Definition: Qt5Graphics.hxx:56
virtual bool supportsOperation(OutDevSupportType) const override
Qt5Graphics(QImage *pQImage)
Definition: Qt5Graphics.hxx:72
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