| 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 QtQuick module 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 QSGSOFTWAREINTERNALIMAGENODE_H |
| 41 | #define QSGSOFTWAREINTERNALIMAGENODE_H |
| 42 | |
| 43 | // |
| 44 | // W A R N I N G |
| 45 | // ------------- |
| 46 | // |
| 47 | // This file is not part of the Qt API. It exists purely as an |
| 48 | // implementation detail. This header file may change from version to |
| 49 | // version without notice, or even be removed. |
| 50 | // |
| 51 | // We mean it. |
| 52 | // |
| 53 | |
| 54 | #include <private/qsgadaptationlayer_p.h> |
| 55 | #include <private/qsgtexturematerial_p.h> |
| 56 | |
| 57 | #include <QtCore/QPointer> |
| 58 | |
| 59 | QT_BEGIN_NAMESPACE |
| 60 | |
| 61 | namespace QSGSoftwareHelpers { |
| 62 | |
| 63 | typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray; |
| 64 | |
| 65 | struct QTileRules |
| 66 | { |
| 67 | inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule) |
| 68 | : horizontal(horizontalRule), vertical(verticalRule) {} |
| 69 | inline QTileRules(Qt::TileRule rule = Qt::StretchTile) |
| 70 | : horizontal(rule), vertical(rule) {} |
| 71 | Qt::TileRule horizontal; |
| 72 | Qt::TileRule vertical; |
| 73 | }; |
| 74 | |
| 75 | #ifndef Q_QDOC |
| 76 | // For internal use only. |
| 77 | namespace QDrawBorderPixmap |
| 78 | { |
| 79 | enum DrawingHint |
| 80 | { |
| 81 | OpaqueTopLeft = 0x0001, |
| 82 | OpaqueTop = 0x0002, |
| 83 | OpaqueTopRight = 0x0004, |
| 84 | OpaqueLeft = 0x0008, |
| 85 | OpaqueCenter = 0x0010, |
| 86 | OpaqueRight = 0x0020, |
| 87 | OpaqueBottomLeft = 0x0040, |
| 88 | OpaqueBottom = 0x0080, |
| 89 | OpaqueBottomRight = 0x0100, |
| 90 | OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight, |
| 91 | OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom, |
| 92 | OpaqueFrame = OpaqueCorners | OpaqueEdges, |
| 93 | OpaqueAll = OpaqueCenter | OpaqueFrame |
| 94 | }; |
| 95 | |
| 96 | Q_DECLARE_FLAGS(DrawingHints, DrawingHint) |
| 97 | } |
| 98 | #endif |
| 99 | |
| 100 | void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins, |
| 101 | const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins, |
| 102 | const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints); |
| 103 | |
| 104 | } // QSGSoftwareHelpers namespace |
| 105 | |
| 106 | class QSGSoftwareInternalImageNode : public QSGInternalImageNode |
| 107 | { |
| 108 | public: |
| 109 | QSGSoftwareInternalImageNode(); |
| 110 | |
| 111 | void setTargetRect(const QRectF &rect) override; |
| 112 | void setInnerTargetRect(const QRectF &rect) override; |
| 113 | void setInnerSourceRect(const QRectF &rect) override; |
| 114 | void setSubSourceRect(const QRectF &rect) override; |
| 115 | void setTexture(QSGTexture *texture) override; |
| 116 | void setMirror(bool mirror) override; |
| 117 | void setMipmapFiltering(QSGTexture::Filtering filtering) override; |
| 118 | void setFiltering(QSGTexture::Filtering filtering) override; |
| 119 | void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) override; |
| 120 | void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) override; |
| 121 | void update() override; |
| 122 | |
| 123 | void preprocess() override; |
| 124 | |
| 125 | void paint(QPainter *painter); |
| 126 | |
| 127 | QRectF rect() const; |
| 128 | |
| 129 | const QPixmap &pixmap() const; |
| 130 | private: |
| 131 | |
| 132 | QRectF m_targetRect; |
| 133 | QRectF m_innerTargetRect; |
| 134 | QRectF m_innerSourceRect; |
| 135 | QRectF m_subSourceRect; |
| 136 | |
| 137 | QPointer<QSGTexture> m_texture; |
| 138 | QPixmap m_cachedMirroredPixmap; |
| 139 | |
| 140 | bool m_mirror; |
| 141 | bool m_textureIsLayer; |
| 142 | bool m_smooth; |
| 143 | bool m_tileHorizontal; |
| 144 | bool m_tileVertical; |
| 145 | bool m_cachedMirroredPixmapIsDirty; |
| 146 | }; |
| 147 | |
| 148 | QT_END_NAMESPACE |
| 149 | |
| 150 | #endif // QSGSOFTWAREINTERNALIMAGENODE_H |
| 151 | |