LibreOffice Module vcl (master) 1
qt5/QtGraphics.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 <sal/config.h>
23
24#include <salgdi.hxx>
25
26#include <memory>
27
28#include <QtGui/QPainter>
29#include <QtGui/QPainterPath>
30#include <QtGui/QRegion>
31
32#include "QtGraphicsBase.hxx"
33
34namespace vcl::font
35{
36class PhysicalFontCollection;
37}
38class QImage;
39class QPushButton;
40class QtFont;
41class QtFontFace;
42class QtFrame;
43class QtPainter;
44
46{
47 friend class QtPainter;
48
50 QImage* m_pQImage;
52 QPainterPath m_aClipPath;
55 QPainter::CompositionMode m_eCompositionMode;
56
57public:
58 QtGraphicsBackend(QtFrame* pFrame, QImage* pQImage);
60
61 void Init() override {}
62
63 QImage* getQImage() { return m_pQImage; }
64
65 void setQImage(QImage* pQImage) { m_pQImage = pQImage; }
66
67 void freeResources() override {}
68
69 OUString getRenderBackendName() const override { return "qt5"; }
70
71 bool setClipRegion(vcl::Region const& rRegion) override;
72 void ResetClipRegion() override;
73
74 sal_uInt16 GetBitCount() const override;
75
76 tools::Long GetGraphicsWidth() const override;
77
78 void SetLineColor() override;
79 void SetLineColor(Color nColor) override;
80 void SetFillColor() override;
81 void SetFillColor(Color nColor) override;
82 void SetXORMode(bool bSet, bool bInvertOnly) override;
83 void SetROPLineColor(SalROPColor nROPColor) override;
84 void SetROPFillColor(SalROPColor nROPColor) override;
85
86 void drawPixel(tools::Long nX, tools::Long nY) override;
87 void drawPixel(tools::Long nX, tools::Long nY, Color nColor) override;
88
89 void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) override;
90 void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override;
91 void drawPolyLine(sal_uInt32 nPoints, const Point* pPointArray) override;
92 void drawPolygon(sal_uInt32 nPoints, const Point* pPointArray) override;
93 void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints,
94 const Point** pPointArray) override;
95
96 bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
97 const basegfx::B2DPolyPolygon&, double fTransparency) override;
98
99 bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon&,
100 double fTransparency, double fLineWidth, const std::vector<double>* pStroke,
101 basegfx::B2DLineJoin, css::drawing::LineCap, double fMiterMinimumAngle,
102 bool bPixelSnapHairline) override;
103
104 bool drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPointArray,
105 const PolyFlags* pFlagArray) override;
106
107 bool drawPolygonBezier(sal_uInt32 nPoints, const Point* pPointArray,
108 const PolyFlags* pFlagArray) override;
109
110 bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints,
111 const Point* const* pPointArray,
112 const PolyFlags* const* pFlagArray) override;
113
114 void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY,
115 tools::Long nSrcWidth, tools::Long nSrcHeight, bool bWindowInvalidate) override;
116
117 void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override;
118
119 void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) override;
120
121 void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
122 const SalBitmap& rMaskBitmap) override;
123
124 void drawMask(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
125 Color nMaskColor) override;
126
127 std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth,
128 tools::Long nHeight) override;
129
131
133 SalInvert nFlags) override;
134
135 void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) override;
136
138 void* pPtr, sal_uInt32 nSize) override;
139
140 bool blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) override;
141
142 bool blendAlphaBitmap(const SalTwoRect&, const SalBitmap& rSrcBitmap,
143 const SalBitmap& rMaskBitmap, const SalBitmap& rAlphaBitmap) override;
144
145 bool drawAlphaBitmap(const SalTwoRect&, const SalBitmap& rSourceBitmap,
146 const SalBitmap& rAlphaBitmap) override;
147
149 const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap,
150 const SalBitmap* pAlphaBitmap, double fAlpha) override;
151
152 bool hasFastDrawTransformedBitmap() const override;
153
155 sal_uInt8 nTransparency) override;
156
157 bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override;
159 SalGradient const& rGradient) override;
160
161 bool supportsOperation(OutDevSupportType eType) const override;
162
163private:
164 void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
165};
166
168{
169 friend class QtBitmap;
170
171 std::unique_ptr<QtGraphicsBackend> m_pBackend;
172
174
177
178 QtGraphics(QtFrame* pFrame, QImage* pQImage);
179
180 void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
181
182 void handleDamage(const tools::Rectangle&) override;
183
184public:
186 : QtGraphics(pFrame, nullptr)
187 {
188 }
189 QtGraphics(QImage* pQImage)
190 : QtGraphics(nullptr, pQImage)
191 {
192 }
193 virtual ~QtGraphics() override;
194
195 QImage* getQImage() { return m_pBackend->getQImage(); }
196
197 void ChangeQImage(QImage* pImage);
198
199 virtual SalGraphicsImpl* GetImpl() const override;
200 virtual SystemGraphicsData GetGraphicsData() const override;
201 virtual OUString getRenderBackendName() const override
202 {
203 return m_pBackend->getRenderBackendName();
204 }
205
206#if ENABLE_CAIRO_CANVAS
207 virtual bool SupportsCairo() const override;
209 CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
210 virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y,
211 int width, int height) const override;
212 virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice,
213 const BitmapSystemData& rData,
214 const Size& rSize) const override;
215 virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface,
216 const basegfx::B2ISize& rSize) const override;
217#endif // ENABLE_CAIRO_CANVAS
218
219 // GDI
220
221 virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
222
223 // Text rendering + font support
224
225 virtual void SetTextColor(Color nColor) override;
226 virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
227 virtual void GetFontMetric(ImplFontMetricDataRef&, int nFallbackLevel) override;
228 virtual FontCharMapRef GetFontCharMap() const override;
229 virtual bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const override;
231 virtual void ClearDevFontCache() override;
232 virtual bool AddTempDevFont(vcl::font::PhysicalFontCollection*, const OUString& rFileURL,
233 const OUString& rFontName) override;
234 virtual bool CreateFontSubset(const OUString& rToFile, const vcl::font::PhysicalFontFace* pFont,
235 const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
236 sal_Int32* pWidths, int nGlyphs,
237 FontSubsetInfo& rInfo // out parameter
238 ) override;
239
241 tools::Long* pDataLen) override;
242 virtual void FreeEmbedFontData(const void* pData, tools::Long nDataLen) override;
243
244 virtual void GetGlyphWidths(const vcl::font::PhysicalFontFace*, bool bVertical,
245 std::vector<sal_Int32>& rWidths, Ucs2UIntMap& rUnicodeEnc) override;
246
247 virtual std::unique_ptr<GenericSalLayout> GetTextLayout(int nFallbackLevel) override;
248 virtual void DrawTextLayout(const GenericSalLayout&) override;
249};
250
251/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:176
void drawPixel(tools::Long nX, tools::Long nY) override
bool setClipRegion(vcl::Region const &rRegion) override
bool drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt8 nTransparency) override
QtGraphicsBackend(QtFrame *pFrame, QImage *pQImage)
void copyBits(const SalTwoRect &rPosAry, SalGraphics *pSrcGraphics) override
void SetLineColor(Color nColor) override
void drawPolyLine(sal_uInt32 nPoints, const Point *pPointArray) override
bool drawPolyLine(const basegfx::B2DHomMatrix &rObjectToDevice, const basegfx::B2DPolygon &, double fTransparency, double fLineWidth, const std::vector< double > *pStroke, basegfx::B2DLineJoin, css::drawing::LineCap, double fMiterMinimumAngle, bool bPixelSnapHairline) override
bool drawPolyLineBezier(sal_uInt32 nPoints, const Point *pPointArray, const PolyFlags *pFlagArray) override
tools::Long GetGraphicsWidth() const override
bool drawTransformedBitmap(const basegfx::B2DPoint &rNull, const basegfx::B2DPoint &rX, const basegfx::B2DPoint &rY, const SalBitmap &rSourceBitmap, const SalBitmap *pAlphaBitmap, double fAlpha) override
bool drawGradient(const tools::PolyPolygon &rPolygon, const Gradient &rGradient) override
std::shared_ptr< SalBitmap > getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override
bool supportsOperation(OutDevSupportType eType) const override
void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32 *pPoints, const Point **pPointArray) override
void SetXORMode(bool bSet, bool bInvertOnly) override
bool hasFastDrawTransformedBitmap() const override
void Init() override
void invert(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, SalInvert nFlags) override
void ResetClipRegion() override
bool drawEPS(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, void *pPtr, sal_uInt32 nSize) override
Color getPixel(tools::Long nX, tools::Long nY) override
void drawPolygon(sal_uInt32 nPoints, const Point *pPointArray) override
void drawScaledImage(const SalTwoRect &rPosAry, const QImage &rImage)
void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) override
void drawMask(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap, Color nMaskColor) override
void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override
OUString getRenderBackendName() const override
void SetROPLineColor(SalROPColor nROPColor) override
~QtGraphicsBackend() override
bool implDrawGradient(basegfx::B2DPolyPolygon const &rPolyPolygon, SalGradient const &rGradient) override
void freeResources() override
void SetLineColor() override
bool blendBitmap(const SalTwoRect &, const SalBitmap &rBitmap) override
void SetFillColor() override
bool drawAlphaBitmap(const SalTwoRect &, const SalBitmap &rSourceBitmap, const SalBitmap &rAlphaBitmap) override
void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY, tools::Long nSrcWidth, tools::Long nSrcHeight, bool bWindowInvalidate) override
bool drawPolygonBezier(sal_uInt32 nPoints, const Point *pPointArray, const PolyFlags *pFlagArray) override
void setQImage(QImage *pQImage)
void SetFillColor(Color nColor) override
void invert(sal_uInt32 nPoints, const Point *pPtAry, SalInvert nFlags) override
bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32 *pPoints, const Point *const *pPointArray, const PolyFlags *const *pFlagArray) override
bool blendAlphaBitmap(const SalTwoRect &, const SalBitmap &rSrcBitmap, const SalBitmap &rMaskBitmap, const SalBitmap &rAlphaBitmap) override
void SetROPFillColor(SalROPColor nROPColor) override
bool drawPolyPolygon(const basegfx::B2DHomMatrix &rObjectToDevice, const basegfx::B2DPolyPolygon &, double fTransparency) override
void drawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap) override
void drawPixel(tools::Long nX, tools::Long nY, Color nColor) override
sal_uInt16 GetBitCount() const override
QPainter::CompositionMode m_eCompositionMode
QPainterPath m_aClipPath
void drawBitmap(const SalTwoRect &rPosAry, const SalBitmap &rSalBitmap, const SalBitmap &rMaskBitmap) override
virtual OUString getRenderBackendName() const override
virtual void GetFontMetric(ImplFontMetricDataRef &, int nFallbackLevel) override
virtual void GetGlyphWidths(const vcl::font::PhysicalFontFace *, bool bVertical, std::vector< sal_Int32 > &rWidths, Ucs2UIntMap &rUnicodeEnc) override
virtual SystemGraphicsData GetGraphicsData() const override
virtual const void * GetEmbedFontData(const vcl::font::PhysicalFontFace *, tools::Long *pDataLen) override
virtual void SetTextColor(Color nColor) override
void ChangeQImage(QImage *pImage)
virtual bool AddTempDevFont(vcl::font::PhysicalFontCollection *, const OUString &rFileURL, const OUString &rFontName) override
rtl::Reference< QtFont > m_pTextStyle[MAX_FALLBACK]
virtual void ClearDevFontCache() override
std::unique_ptr< QtGraphicsBackend > m_pBackend
QtGraphics(QtFrame *pFrame)
void drawScaledImage(const SalTwoRect &rPosAry, const QImage &rImage)
virtual ~QtGraphics() override
void handleDamage(const tools::Rectangle &) override
Handle damage done by drawing with a widget draw override.
QtGraphics(QtFrame *pFrame, QImage *pQImage)
virtual void GetResolution(sal_Int32 &rDPIX, sal_Int32 &rDPIY) override
QtFrame * m_pFrame
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const override
QImage * getQImage()
virtual void FreeEmbedFontData(const void *pData, tools::Long nDataLen) override
virtual void SetFont(LogicalFontInstance *, int nFallbackLevel) override
virtual void DrawTextLayout(const GenericSalLayout &) override
QtGraphics(QImage *pQImage)
virtual SalGraphicsImpl * GetImpl() const override
virtual std::unique_ptr< GenericSalLayout > GetTextLayout(int nFallbackLevel) override
virtual bool CreateFontSubset(const OUString &rToFile, const vcl::font::PhysicalFontFace *pFont, const sal_GlyphId *pGlyphIds, const sal_uInt8 *pEncoding, sal_Int32 *pWidths, int nGlyphs, FontSubsetInfo &rInfo) override
virtual void GetDevFontList(vcl::font::PhysicalFontCollection *) override
virtual FontCharMapRef GetFontCharMap() const override
Implementation class for SalGraphics.
Definition: salgdiimpl.hxx:51
abstract base class for physical font faces
sal_uInt16 sal_GlyphId
Definition: glyphid.hxx:24
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:36
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:34
long Long
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
PolyFlags
std::map< sal_Ucs, sal_uInt32 > Ucs2UIntMap
Definition: salgdi.hxx:66
SalROPColor
Definition: salgtype.hxx:70
SalInvert
Definition: salgtype.hxx:74
#define MAX_FALLBACK
Definition: sallayout.hxx:46
unsigned char sal_uInt8
OutDevSupportType
Definition: vclenum.hxx:174