1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 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 QWINDOWSDIRECT2DPAINTENGINE_H 41 #define QWINDOWSDIRECT2DPAINTENGINE_H 42 43 #include <QtCore/qscopedpointer.h> 44 #include <QtGui/private/qpaintengineex_p.h> 45 46 struct ID2D1Geometry; 47 48 QT_BEGIN_NAMESPACE 49 50 class QWindowsDirect2DPaintEnginePrivate; 51 class QWindowsDirect2DBitmap; 52 53 class QWindowsDirect2DPaintEngine : public QPaintEngineEx 54 { 55 Q_DECLARE_PRIVATE(QWindowsDirect2DPaintEngine) 56 friend class QWindowsDirect2DPaintEngineSuspenderImpl; 57 friend class QWindowsDirect2DPaintEngineSuspenderPrivate; 58 public: 59 enum Flag { 60 NoFlag = 0, 61 TranslucentTopLevelWindow = 1, 62 EmulateComposition = 2, 63 }; 64 Q_DECLARE_FLAGS(Flags, Flag) 65 66 QWindowsDirect2DPaintEngine(QWindowsDirect2DBitmap *bitmap, Flags flags); 67 68 bool begin(QPaintDevice *pdev) override; 69 bool end() override; 70 71 Type type() const override; 72 73 void setState(QPainterState *s) override; 74 75 void draw(const QVectorPath &path) override; 76 77 void fill(const QVectorPath &path, const QBrush &brush) override; 78 void fill(ID2D1Geometry *geometry, const QBrush &brush); 79 80 void stroke(const QVectorPath &path, const QPen &pen) override; 81 void stroke(ID2D1Geometry *geometry, const QPen &pen); 82 83 void clip(const QVectorPath &path, Qt::ClipOperation op) override; 84 85 void clipEnabledChanged() override; 86 void penChanged() override; 87 void brushChanged() override; 88 void brushOriginChanged() override; 89 void opacityChanged() override; 90 void compositionModeChanged() override; 91 void renderHintsChanged() override; 92 void transformChanged() override; 93 94 void fillRect(const QRectF &rect, const QBrush &brush) override; 95 96 void drawRects(const QRect *rects, int rectCount) override; 97 void drawRects(const QRectF *rects, int rectCount) override; 98 99 void drawEllipse(const QRectF &r) override; 100 void drawEllipse(const QRect &r) override; 101 102 void drawImage(const QRectF &rectangle, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags = Qt::AutoColor) override; 103 void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override; 104 105 void drawStaticTextItem(QStaticTextItem *staticTextItem) override; 106 void drawTextItem(const QPointF &p, const QTextItem &textItem) override; 107 108 private: 109 void ensureBrush(); 110 void ensureBrush(const QBrush &brush); 111 void ensurePen(); 112 void ensurePen(const QPen &pen); 113 114 void rasterFill(const QVectorPath &path, const QBrush &brush); 115 116 enum EmulationType { PenEmulation, BrushEmulation }; 117 bool emulationRequired(EmulationType type) const; 118 119 bool antiAliasingEnabled() const; 120 void adjustForAliasing(QRectF *rect); 121 void adjustForAliasing(QPointF *point); 122 123 void suspend(); 124 void resume(); 125 }; 126 Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsDirect2DPaintEngine::Flags) 127 128 class QWindowsDirect2DPaintEngineSuspenderPrivate; 129 class QWindowsDirect2DPaintEngineSuspender 130 { 131 Q_DISABLE_COPY_MOVE(QWindowsDirect2DPaintEngineSuspender) 132 Q_DECLARE_PRIVATE(QWindowsDirect2DPaintEngineSuspender) 133 QScopedPointer<QWindowsDirect2DPaintEngineSuspenderPrivate> d_ptr; 134 public: 135 QWindowsDirect2DPaintEngineSuspender(QWindowsDirect2DPaintEngine *engine); 136 ~QWindowsDirect2DPaintEngineSuspender(); 137 void resume(); 138 }; 139 140 QT_END_NAMESPACE 141 142 #endif // QWINDOWSDIRECT2DPAINTENGINE_H 143