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 QPIXMAP_BLITTER_P_H |
5 | #define QPIXMAP_BLITTER_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 purely as an |
12 | // implementation detail. 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 <QtGui/private/qtguiglobal_p.h> |
19 | #include <qpa/qplatformpixmap.h> |
20 | #include <private/qpaintengine_blitter_p.h> |
21 | |
22 | #ifndef QT_NO_BLITTABLE |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class Q_GUI_EXPORT QBlittablePlatformPixmap : public QPlatformPixmap |
26 | { |
27 | // Q_DECLARE_PRIVATE(QBlittablePlatformPixmap) |
28 | public: |
29 | QBlittablePlatformPixmap(); |
30 | ~QBlittablePlatformPixmap(); |
31 | |
32 | virtual QBlittable *createBlittable(const QSize &size, bool alpha) const = 0; |
33 | QBlittable *blittable() const; |
34 | void setBlittable(QBlittable *blittable); |
35 | |
36 | void resize(int width, int height) override; |
37 | int metric(QPaintDevice::PaintDeviceMetric metric) const override; |
38 | void fill(const QColor &color) override; |
39 | QImage *buffer() override; |
40 | QImage toImage() const override; |
41 | bool hasAlphaChannel() const override; |
42 | void fromImage(const QImage &image, Qt::ImageConversionFlags flags) override; |
43 | qreal devicePixelRatio() const override; |
44 | void setDevicePixelRatio(qreal scaleFactor) override; |
45 | |
46 | QPaintEngine *paintEngine() const override; |
47 | |
48 | void markRasterOverlay(const QRectF &); |
49 | void markRasterOverlay(const QPointF &, const QTextItem &); |
50 | void markRasterOverlay(const QVectorPath &); |
51 | void markRasterOverlay(const QPainterPath &); |
52 | void markRasterOverlay(const QRect *rects, int rectCount); |
53 | void markRasterOverlay(const QRectF *rects, int rectCount); |
54 | void markRasterOverlay(const QPointF *points, int pointCount); |
55 | void markRasterOverlay(const QPoint *points, int pointCount); |
56 | void unmarkRasterOverlay(const QRectF &); |
57 | |
58 | #ifdef QT_BLITTER_RASTEROVERLAY |
59 | void mergeOverlay(); |
60 | void unmergeOverlay(); |
61 | QImage *overlay(); |
62 | |
63 | #endif //QT_BLITTER_RASTEROVERLAY |
64 | protected: |
65 | QScopedPointer<QBlitterPaintEngine> m_engine; |
66 | QScopedPointer<QBlittable> m_blittable; |
67 | bool m_alpha; |
68 | qreal m_devicePixelRatio; |
69 | |
70 | #ifdef QT_BLITTER_RASTEROVERLAY |
71 | QImage *m_rasterOverlay; |
72 | QImage *m_unmergedCopy; |
73 | QColor m_overlayColor; |
74 | |
75 | void markRasterOverlayImpl(const QRectF &); |
76 | void unmarkRasterOverlayImpl(const QRectF &); |
77 | QRectF clipAndTransformRect(const QRectF &) const; |
78 | #endif //QT_BLITTER_RASTEROVERLAY |
79 | |
80 | }; |
81 | |
82 | inline void QBlittablePlatformPixmap::markRasterOverlay(const QRectF &rect) |
83 | { |
84 | #ifdef QT_BLITTER_RASTEROVERLAY |
85 | markRasterOverlayImpl(rect); |
86 | #else |
87 | Q_UNUSED(rect); |
88 | #endif |
89 | } |
90 | |
91 | inline void QBlittablePlatformPixmap::markRasterOverlay(const QVectorPath &path) |
92 | { |
93 | #ifdef QT_BLITTER_RASTEROVERLAY |
94 | markRasterOverlayImpl(path.convertToPainterPath().boundingRect()); |
95 | #else |
96 | Q_UNUSED(path); |
97 | #endif |
98 | } |
99 | |
100 | inline void QBlittablePlatformPixmap::markRasterOverlay(const QPointF &pos, const QTextItem &ti) |
101 | { |
102 | #ifdef QT_BLITTER_RASTEROVERLAY |
103 | QFontMetricsF fm(ti.font()); |
104 | QRectF rect = fm.tightBoundingRect(ti.text()); |
105 | rect.moveBottomLeft(pos); |
106 | markRasterOverlay(rect); |
107 | #else |
108 | Q_UNUSED(pos); |
109 | Q_UNUSED(ti); |
110 | #endif |
111 | } |
112 | |
113 | inline void QBlittablePlatformPixmap::markRasterOverlay(const QRect *rects, int rectCount) |
114 | { |
115 | #ifdef QT_BLITTER_RASTEROVERLAY |
116 | for (int i = 0; i < rectCount; i++) { |
117 | markRasterOverlay(rects[i]); |
118 | } |
119 | #else |
120 | Q_UNUSED(rects); |
121 | Q_UNUSED(rectCount); |
122 | #endif |
123 | } |
124 | inline void QBlittablePlatformPixmap::markRasterOverlay(const QRectF *rects, int rectCount) |
125 | { |
126 | #ifdef QT_BLITTER_RASTEROVERLAY |
127 | for (int i = 0; i < rectCount; i++) { |
128 | markRasterOverlay(rects[i]); |
129 | } |
130 | #else |
131 | Q_UNUSED(rects); |
132 | Q_UNUSED(rectCount); |
133 | #endif |
134 | } |
135 | |
136 | inline void QBlittablePlatformPixmap::markRasterOverlay(const QPointF *points, int pointCount) |
137 | { |
138 | #ifdef QT_BLITTER_RASTEROVERLAY |
139 | #error "not ported yet" |
140 | #else |
141 | Q_UNUSED(points); |
142 | Q_UNUSED(pointCount); |
143 | #endif |
144 | } |
145 | |
146 | inline void QBlittablePlatformPixmap::markRasterOverlay(const QPoint *points, int pointCount) |
147 | { |
148 | #ifdef QT_BLITTER_RASTEROVERLAY |
149 | #error "not ported yet" |
150 | #else |
151 | Q_UNUSED(points); |
152 | Q_UNUSED(pointCount); |
153 | #endif |
154 | } |
155 | |
156 | inline void QBlittablePlatformPixmap::markRasterOverlay(const QPainterPath& path) |
157 | { |
158 | #ifdef QT_BLITTER_RASTEROVERLAY |
159 | #error "not ported yet" |
160 | #else |
161 | Q_UNUSED(path); |
162 | #endif |
163 | } |
164 | |
165 | inline void QBlittablePlatformPixmap::unmarkRasterOverlay(const QRectF &rect) |
166 | { |
167 | #ifdef QT_BLITTER_RASTEROVERLAY |
168 | unmarkRasterOverlayImpl(rect); |
169 | #else |
170 | Q_UNUSED(rect); |
171 | #endif |
172 | } |
173 | |
174 | QT_END_NAMESPACE |
175 | #endif // QT_NO_BLITTABLE |
176 | #endif // QPIXMAP_BLITTER_P_H |
177 | |