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#include <optional>
28
29#include <QtGui/QPainter>
30#include <QtGui/QPainterPath>
31#include <QtGui/QRegion>
32
33#include "QtGraphicsBase.hxx"
34
35namespace vcl::font
36{
37class PhysicalFontCollection;
38}
39class QImage;
40class QPushButton;
41class QtFont;
42class QtFontFace;
43class QtFrame;
44class QtPainter;
45
47{
48 friend class QtPainter;
49
51 QImage* m_pQImage;
53 QPainterPath m_aClipPath;
54 std::optional<Color> m_oLineColor;
55 std::optional<Color> m_oFillColor;
56 QPainter::CompositionMode m_eCompositionMode;
57
58public:
59 QtGraphicsBackend(QtFrame* pFrame, QImage* pQImage);
61
62 void Init() override {}
63
64 QImage* getQImage() { return m_pQImage; }
65
66 void setQImage(QImage* pQImage) { m_pQImage = pQImage; }
67
68 void freeResources() override {}
69
70 OUString getRenderBackendName() const override { return "qt5"; }
71
72 void setClipRegion(vcl::Region const& rRegion) override;
73 void ResetClipRegion() override;
74
75 sal_uInt16 GetBitCount() const override;
76
77 tools::Long GetGraphicsWidth() const override;
78
79 void SetLineColor() override;
80 void SetLineColor(Color nColor) override;
81 void SetFillColor() override;
82 void SetFillColor(Color nColor) override;
83 void SetXORMode(bool bSet, bool bInvertOnly) override;
84 void SetROPLineColor(SalROPColor nROPColor) override;
85 void SetROPFillColor(SalROPColor nROPColor) override;
86
87 void drawPixel(tools::Long nX, tools::Long nY) override;
88 void drawPixel(tools::Long nX, tools::Long nY, Color nColor) override;
89
90 void drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2, tools::Long nY2) override;
91 void drawRect(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override;
92 void drawPolyLine(sal_uInt32 nPoints, const Point* pPointArray) override;
93 void drawPolygon(sal_uInt32 nPoints, const Point* pPointArray) override;
94 void drawPolyPolygon(sal_uInt32 nPoly, const sal_uInt32* pPoints,
95 const Point** pPointArray) override;
96
97 bool drawPolyPolygon(const basegfx::B2DHomMatrix& rObjectToDevice,
98 const basegfx::B2DPolyPolygon&, double fTransparency) override;
99
100 bool drawPolyLine(const basegfx::B2DHomMatrix& rObjectToDevice, const basegfx::B2DPolygon&,
101 double fTransparency, double fLineWidth, const std::vector<double>* pStroke,
102 basegfx::B2DLineJoin, css::drawing::LineCap, double fMiterMinimumAngle,
103 bool bPixelSnapHairline) override;
104
105 bool drawPolyLineBezier(sal_uInt32 nPoints, const Point* pPointArray,
106 const PolyFlags* pFlagArray) override;
107
108 bool drawPolygonBezier(sal_uInt32 nPoints, const Point* pPointArray,
109 const PolyFlags* pFlagArray) override;
110
111 bool drawPolyPolygonBezier(sal_uInt32 nPoly, const sal_uInt32* pPoints,
112 const Point* const* pPointArray,
113 const PolyFlags* const* pFlagArray) override;
114
115 void copyArea(tools::Long nDestX, tools::Long nDestY, tools::Long nSrcX, tools::Long nSrcY,
116 tools::Long nSrcWidth, tools::Long nSrcHeight, bool bWindowInvalidate) override;
117
118 void copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) override;
119
120 void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) override;
121
122 void drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
123 const SalBitmap& rMaskBitmap) override;
124
125 void drawMask(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap,
126 Color nMaskColor) override;
127
128 std::shared_ptr<SalBitmap> getBitmap(tools::Long nX, tools::Long nY, tools::Long nWidth,
129 tools::Long nHeight) override;
130
132
134 SalInvert nFlags) override;
135
136 void invert(sal_uInt32 nPoints, const Point* pPtAry, SalInvert nFlags) override;
137
139 void* pPtr, sal_uInt32 nSize) override;
140
141 bool blendBitmap(const SalTwoRect&, const SalBitmap& rBitmap) override;
142
143 bool blendAlphaBitmap(const SalTwoRect&, const SalBitmap& rSrcBitmap,
144 const SalBitmap& rMaskBitmap, const SalBitmap& rAlphaBitmap) override;
145
146 bool drawAlphaBitmap(const SalTwoRect&, const SalBitmap& rSourceBitmap,
147 const SalBitmap& rAlphaBitmap) override;
148
150 const basegfx::B2DPoint& rY, const SalBitmap& rSourceBitmap,
151 const SalBitmap* pAlphaBitmap, double fAlpha) override;
152
153 bool hasFastDrawTransformedBitmap() const override;
154
156 sal_uInt8 nTransparency) override;
157
158 bool drawGradient(const tools::PolyPolygon& rPolygon, const Gradient& rGradient) override;
160 SalGradient const& rGradient) override;
161
162 bool supportsOperation(OutDevSupportType eType) const override;
163
164private:
165 void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
166};
167
169{
170 friend class QtBitmap;
171
172 std::unique_ptr<QtGraphicsBackend> m_pBackend;
173
175
178
179 QtGraphics(QtFrame* pFrame, QImage* pQImage);
180
181 void drawScaledImage(const SalTwoRect& rPosAry, const QImage& rImage);
182
183 void handleDamage(const tools::Rectangle&) override;
184
185public:
187 : QtGraphics(pFrame, nullptr)
188 {
189 }
190 QtGraphics(QImage* pQImage)
191 : QtGraphics(nullptr, pQImage)
192 {
193 }
194 virtual ~QtGraphics() override;
195
196 QImage* getQImage() { return m_pBackend->getQImage(); }
197
198 void ChangeQImage(QImage* pImage);
199
200 virtual SalGraphicsImpl* GetImpl() const override;
201 virtual SystemGraphicsData GetGraphicsData() const override;
202 virtual OUString getRenderBackendName() const override
203 {
204 return m_pBackend->getRenderBackendName();
205 }
206
207#if ENABLE_CAIRO_CANVAS
208 virtual bool SupportsCairo() const override;
210 CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
211 virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y,
212 int width, int height) const override;
213 virtual cairo::SurfaceSharedPtr CreateBitmapSurface(const OutputDevice& rRefDevice,
214 const BitmapSystemData& rData,
215 const Size& rSize) const override;
216 virtual css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface,
217 const basegfx::B2ISize& rSize) const override;
218#endif // ENABLE_CAIRO_CANVAS
219
220 // GDI
221
222 virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override;
223
224 // Text rendering + font support
225
226 virtual void SetTextColor(Color nColor) override;
227 virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
228 virtual void GetFontMetric(FontMetricDataRef&, int nFallbackLevel) override;
229 virtual FontCharMapRef GetFontCharMap() const override;
230 virtual bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const override;
232 virtual void ClearDevFontCache() override;
233 virtual bool AddTempDevFont(vcl::font::PhysicalFontCollection*, const OUString& rFileURL,
234 const OUString& rFontName) override;
235
236 virtual std::unique_ptr<GenericSalLayout> GetTextLayout(int nFallbackLevel) override;
237 virtual void DrawTextLayout(const GenericSalLayout&) override;
238};
239
240/* 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:170
void drawPixel(tools::Long nX, tools::Long nY) 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
std::optional< Color > m_oLineColor
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
std::optional< Color > m_oFillColor
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 setClipRegion(vcl::Region const &rRegion) 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 SystemGraphicsData GetGraphicsData() const 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 SetFont(LogicalFontInstance *, int nFallbackLevel) override
virtual void GetFontMetric(FontMetricDataRef &, 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 void GetDevFontList(vcl::font::PhysicalFontCollection *) override
virtual FontCharMapRef GetFontCharMap() const override
Implementation class for SalGraphics.
Definition: salgdiimpl.hxx:51
std::shared_ptr< Surface > SurfaceSharedPtr
Definition: cairo.hxx:72
std::shared_ptr< cairo_surface_t > CairoSurfaceSharedPtr
Definition: cairo.hxx:70
long Long
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
PolyFlags
SalROPColor
Definition: salgtype.hxx:69
SalInvert
Definition: salgtype.hxx:73
#define MAX_FALLBACK
Definition: sallayout.hxx:46
unsigned char sal_uInt8
OutDevSupportType
Definition: vclenum.hxx:163