1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPAINTENGINE_ALPHA_P_H
5#define QPAINTENGINE_ALPHA_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
19
20#ifndef QT_NO_PRINTER
21#include "private/qpaintengine_p.h"
22#include <QtPrintSupport/qtprintsupportglobal.h>
23
24QT_BEGIN_NAMESPACE
25
26class QAlphaPaintEnginePrivate;
27
28class Q_PRINTSUPPORT_EXPORT QAlphaPaintEngine : public QPaintEngine
29{
30 Q_DECLARE_PRIVATE(QAlphaPaintEngine)
31public:
32 ~QAlphaPaintEngine();
33
34 bool begin(QPaintDevice *pdev) override;
35 bool end() override;
36
37 void updateState(const QPaintEngineState &state) override;
38
39 void drawPath(const QPainterPath &path) override;
40
41 void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
42
43 void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override;
44 void drawTextItem(const QPointF &p, const QTextItem &textItem) override;
45 void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override;
46
47protected:
48 QAlphaPaintEngine(QAlphaPaintEnginePrivate &data, PaintEngineFeatures devcaps = { });
49 QRegion alphaClipping() const;
50 bool continueCall() const;
51 void flushAndInit(bool init = true);
52 void cleanUp();
53};
54
55class QAlphaPaintEnginePrivate : public QPaintEnginePrivate
56{
57 Q_DECLARE_PUBLIC(QAlphaPaintEngine)
58public:
59 QAlphaPaintEnginePrivate();
60 ~QAlphaPaintEnginePrivate();
61
62 int m_pass;
63 QPicture *m_pic;
64 QPaintEngine *m_picengine;
65 QPainter *m_picpainter;
66
67 QPaintEngine::PaintEngineFeatures m_savedcaps;
68 QPaintDevice *m_pdev;
69
70 QRegion m_alphargn;
71 QRegion m_cliprgn;
72 mutable QRegion m_cachedDirtyRgn;
73 mutable int m_numberOfCachedRects;
74 QList<QRect> m_dirtyRects;
75
76 bool m_hasalpha;
77 bool m_alphaPen;
78 bool m_alphaBrush;
79 bool m_alphaOpacity;
80 bool m_advancedPen;
81 bool m_advancedBrush;
82 bool m_complexTransform;
83 bool m_emulateProjectiveTransforms;
84 bool m_continueCall;
85
86 QTransform m_transform;
87 QPen m_pen;
88
89 void addAlphaRect(const QRectF &rect);
90 void addDirtyRect(const QRectF &rect) { m_dirtyRects.append(t: rect.toAlignedRect()); }
91 bool canSeeTroughBackground(bool somethingInRectHasAlpha, const QRectF &rect) const;
92
93 QRectF addPenWidth(const QPainterPath &path);
94 void drawAlphaImage(const QRectF &rect);
95 QRect toRect(const QRectF &rect) const;
96 bool fullyContained(const QRectF &rect) const;
97
98 void resetState(QPainter *p);
99};
100
101QT_END_NAMESPACE
102
103#endif // QT_NO_PRINTER
104
105#endif // QPAINTENGINE_ALPHA_P_H
106

source code of qtbase/src/printsupport/kernel/qpaintengine_alpha_p.h