1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QPAINTENGINE_X11_H
41 #define QPAINTENGINE_X11_H
42 
43 #include <QtGui/QPaintEngine>
44 
45 typedef unsigned long XID;
46 typedef XID Drawable;
47 typedef struct _XGC *GC;
48 
49 QT_BEGIN_NAMESPACE
50 
51 extern "C" {
52 Drawable qt_x11Handle(const QPaintDevice *pd);
53 GC qt_x11_get_pen_gc(QPainter *);
54 GC qt_x11_get_brush_gc(QPainter *);
55 }
56 
57 class QX11PaintEnginePrivate;
58 class QX11PaintEngine : public QPaintEngine
59 {
60     Q_DECLARE_PRIVATE(QX11PaintEngine)
61 public:
62     QX11PaintEngine();
63     ~QX11PaintEngine();
64 
65     bool begin(QPaintDevice *pdev) override;
66     bool end() override;
67 
68     void updateState(const QPaintEngineState &state) override;
69 
70     void updatePen(const QPen &pen);
71     void updateBrush(const QBrush &brush, const QPointF &pt);
72     void updateRenderHints(QPainter::RenderHints hints);
73     void updateFont(const QFont &font);
74     void updateMatrix(const QTransform &matrix);
75     void updateClipRegion_dev(const QRegion &region, Qt::ClipOperation op);
76 
77     void drawLines(const QLine *lines, int lineCount) override;
78     void drawLines(const QLineF *lines, int lineCount) override;
79 
80     void drawRects(const QRect *rects, int rectCount) override;
81     void drawRects(const QRectF *rects, int rectCount) override;
82 
83     void drawPoints(const QPoint *points, int pointCount) override;
84     void drawPoints(const QPointF *points, int pointCount) override;
85 
86     void drawEllipse(const QRect &r) override;
87     void drawEllipse(const QRectF &r) override;
88 
89     virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
drawPolygon(const QPoint * points,int pointCount,PolygonDrawMode mode)90     inline void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) override
91         { QPaintEngine::drawPolygon(points, pointCount, mode); }
92 
93     void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override;
94     void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s) override;
95     void drawPath(const QPainterPath &path) override;
96     void drawTextItem(const QPointF &p, const QTextItem &textItem) override;
97     void drawImage(const QRectF &r, const QImage &img, const QRectF &sr,
98                    Qt::ImageConversionFlags flags = Qt::AutoColor) override;
99 
100     virtual Drawable handle() const;
type()101     inline Type type() const override { return QPaintEngine::X11; }
102 
103     QPainter::RenderHints supportedRenderHints() const;
104 
105 protected:
106     QX11PaintEngine(QX11PaintEnginePrivate &dptr);
107 
108 #if QT_CONFIG(fontconfig)
109     void drawFreetype(const QPointF &p, const QTextItemInt &ti);
110     bool drawCachedGlyphs(const QTransform &transform, const QTextItemInt &ti);
111 #endif // QT_CONFIG(fontconfig)
112 
113     friend class QPixmap;
114     friend class QFontEngineBox;
115     friend GC qt_x11_get_pen_gc(QPainter *);
116     friend GC qt_x11_get_brush_gc(QPainter *);
117 
118 private:
119     Q_DISABLE_COPY_MOVE(QX11PaintEngine)
120 };
121 
122 QT_END_NAMESPACE
123 
124 #endif // QPAINTENGINE_X11_H
125