| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quickshapes/qquickshape_p_p.h | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 QQUICKSHAPE_P_P_H | - | ||||||||||||
| 41 | #define QQUICKSHAPE_P_P_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 <QtQuickShapes/private/qquickshapesglobal_p.h> | - | ||||||||||||
| 55 | #include <QtQuickShapes/private/qquickshape_p.h> | - | ||||||||||||
| 56 | #include <QtQuick/private/qquickitem_p.h> | - | ||||||||||||
| 57 | #include <QPainterPath> | - | ||||||||||||
| 58 | #include <QColor> | - | ||||||||||||
| 59 | #include <QBrush> | - | ||||||||||||
| 60 | #include <QElapsedTimer> | - | ||||||||||||
| 61 | #include <private/qopenglcontext_p.h> | - | ||||||||||||
| 62 | - | |||||||||||||
| 63 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | class QSGPlainTexture; | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | class QQuickAbstractPathRenderer | - | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 | public: | - | ||||||||||||
| 70 | enum Flag { | - | ||||||||||||
| 71 | SupportsAsync = 0x01 | - | ||||||||||||
| 72 | }; | - | ||||||||||||
| 73 | Q_DECLARE_FLAGS(Flags, Flag) | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | enum FillGradientType { NoGradient = 0, LinearGradient, RadialGradient, ConicalGradient }; | - | ||||||||||||
| 76 | struct GradientDesc { // can fully describe a linear/radial/conical gradient | - | ||||||||||||
| 77 | QGradientStops stops; | - | ||||||||||||
| 78 | QQuickShapeGradient::SpreadMode spread; | - | ||||||||||||
| 79 | QPointF a; // start (L) or center point (R/C) | - | ||||||||||||
| 80 | QPointF b; // end (L) or focal point (R) | - | ||||||||||||
| 81 | qreal v0; // center radius (R) or start angle (C) | - | ||||||||||||
| 82 | qreal v1; // focal radius (R) | - | ||||||||||||
| 83 | }; | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | virtual ~QQuickAbstractPathRenderer() { } | - | ||||||||||||
| 86 | - | |||||||||||||
| 87 | // Gui thread | - | ||||||||||||
| 88 | virtual void beginSync(int totalCount) = 0; | - | ||||||||||||
| 89 | virtual void endSync(bool async) = 0; | - | ||||||||||||
| 90 | virtual void setAsyncCallback(void (*)(void *), void *) { } | - | ||||||||||||
| 91 | virtual Flags flags() const { return 0; } never executed:  return 0; | 0 | ||||||||||||
| 92 | virtual void setPath(int index, const QQuickPath *path) = 0; | - | ||||||||||||
| 93 | virtual void setStrokeColor(int index, const QColor &color) = 0; | - | ||||||||||||
| 94 | virtual void setStrokeWidth(int index, qreal w) = 0; | - | ||||||||||||
| 95 | virtual void setFillColor(int index, const QColor &color) = 0; | - | ||||||||||||
| 96 | virtual void setFillRule(int index, QQuickShapePath::FillRule fillRule) = 0; | - | ||||||||||||
| 97 | virtual void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) = 0; | - | ||||||||||||
| 98 | virtual void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) = 0; | - | ||||||||||||
| 99 | virtual void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, | - | ||||||||||||
| 100 | qreal dashOffset, const QVector<qreal> &dashPattern) = 0; | - | ||||||||||||
| 101 | virtual void setFillGradient(int index, QQuickShapeGradient *gradient) = 0; | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | // Render thread, with gui blocked | - | ||||||||||||
| 104 | virtual void updateNode() = 0; | - | ||||||||||||
| 105 | }; | - | ||||||||||||
| 106 | - | |||||||||||||
| 107 | Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickAbstractPathRenderer::Flags) | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | struct QQuickShapeStrokeFillParams | - | ||||||||||||
| 110 | { | - | ||||||||||||
| 111 | QQuickShapeStrokeFillParams(); | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | QColor strokeColor; | - | ||||||||||||
| 114 | qreal strokeWidth; | - | ||||||||||||
| 115 | QColor fillColor; | - | ||||||||||||
| 116 | QQuickShapePath::FillRule fillRule; | - | ||||||||||||
| 117 | QQuickShapePath::JoinStyle joinStyle; | - | ||||||||||||
| 118 | int miterLimit; | - | ||||||||||||
| 119 | QQuickShapePath::CapStyle capStyle; | - | ||||||||||||
| 120 | QQuickShapePath::StrokeStyle strokeStyle; | - | ||||||||||||
| 121 | qreal dashOffset; | - | ||||||||||||
| 122 | QVector<qreal> dashPattern; | - | ||||||||||||
| 123 | QQuickShapeGradient *fillGradient; | - | ||||||||||||
| 124 | }; | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapePathPrivate : public QQuickPathPrivate | - | ||||||||||||
| 127 | { | - | ||||||||||||
| 128 | Q_DECLARE_PUBLIC(QQuickShapePath) | - | ||||||||||||
| 129 | - | |||||||||||||
| 130 | public: | - | ||||||||||||
| 131 | enum Dirty { | - | ||||||||||||
| 132 | DirtyPath = 0x01, | - | ||||||||||||
| 133 | DirtyStrokeColor = 0x02, | - | ||||||||||||
| 134 | DirtyStrokeWidth = 0x04, | - | ||||||||||||
| 135 | DirtyFillColor = 0x08, | - | ||||||||||||
| 136 | DirtyFillRule = 0x10, | - | ||||||||||||
| 137 | DirtyStyle = 0x20, | - | ||||||||||||
| 138 | DirtyDash = 0x40, | - | ||||||||||||
| 139 | DirtyFillGradient = 0x80, | - | ||||||||||||
| 140 | - | |||||||||||||
| 141 | DirtyAll = 0xFF | - | ||||||||||||
| 142 | }; | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | QQuickShapePathPrivate(); | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | void _q_pathChanged(); | - | ||||||||||||
| 147 | void _q_fillGradientChanged(); | - | ||||||||||||
| 148 | - | |||||||||||||
| 149 | static QQuickShapePathPrivate *get(QQuickShapePath *p) { return p->d_func(); } executed 1051 times by 2 tests:  return p->d_func();Executed by: 
 | 1051 | ||||||||||||
| 150 | - | |||||||||||||
| 151 | int dirty; | - | ||||||||||||
| 152 | QQuickShapeStrokeFillParams sfp; | - | ||||||||||||
| 153 | }; | - | ||||||||||||
| 154 | - | |||||||||||||
| 155 | class QQuickShapePrivate : public QQuickItemPrivate | - | ||||||||||||
| 156 | { | - | ||||||||||||
| 157 | Q_DECLARE_PUBLIC(QQuickShape) | - | ||||||||||||
| 158 | - | |||||||||||||
| 159 | public: | - | ||||||||||||
| 160 | QQuickShapePrivate(); | - | ||||||||||||
| 161 | ~QQuickShapePrivate(); | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 | void createRenderer(); | - | ||||||||||||
| 164 | QSGNode *createNode(); | - | ||||||||||||
| 165 | void sync(); | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | void _q_shapePathChanged(); | - | ||||||||||||
| 168 | void setStatus(QQuickShape::Status newStatus); | - | ||||||||||||
| 169 | - | |||||||||||||
| 170 | static QQuickShapePrivate *get(QQuickShape *item) { return item->d_func(); } executed 1088 times by 2 tests:  return item->d_func();Executed by: 
 | 1088 | ||||||||||||
| 171 | - | |||||||||||||
| 172 | static void asyncShapeReady(void *data); | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | int effectRefCount; | - | ||||||||||||
| 175 | QVector<QQuickShapePath *> sp; | - | ||||||||||||
| 176 | QElapsedTimer syncTimer; | - | ||||||||||||
| 177 | QQuickAbstractPathRenderer *renderer = nullptr; | - | ||||||||||||
| 178 | int syncTimingTotalDirty = 0; | - | ||||||||||||
| 179 | int syncTimeCounter = 0; | - | ||||||||||||
| 180 | QQuickShape::Status status = QQuickShape::Null; | - | ||||||||||||
| 181 | QQuickShape::RendererType rendererType = QQuickShape::UnknownRenderer; | - | ||||||||||||
| 182 | QQuickShape::ContainsMode containsMode = QQuickShape::BoundingRectContains; | - | ||||||||||||
| 183 | bool spChanged = false; | - | ||||||||||||
| 184 | bool async = false; | - | ||||||||||||
| 185 | bool enableVendorExts = true; | - | ||||||||||||
| 186 | bool syncTimingActive = false; | - | ||||||||||||
| 187 | }; | - | ||||||||||||
| 188 | - | |||||||||||||
| 189 | #if QT_CONFIG(opengl) | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | class QQuickShapeGradientCache : public QOpenGLSharedResource | - | ||||||||||||
| 192 | { | - | ||||||||||||
| 193 | public: | - | ||||||||||||
| 194 | struct Key { | - | ||||||||||||
| 195 | Key(const QGradientStops &stops, QQuickShapeGradient::SpreadMode spread) | - | ||||||||||||
| 196 | : stops(stops), spread(spread) | - | ||||||||||||
| 197 | { } executed 15 times by 1 test:  end of blockExecuted by: 
 | 15 | ||||||||||||
| 198 | QGradientStops stops; | - | ||||||||||||
| 199 | QQuickShapeGradient::SpreadMode spread; | - | ||||||||||||
| 200 | bool operator==(const Key &other) const | - | ||||||||||||
| 201 | { | - | ||||||||||||
| 202 | return spread == other.spread && stops == other.stops; executed 15 times by 1 test:  return spread == other.spread && stops == other.stops;Executed by: 
 | 15 | ||||||||||||
| 203 | } | - | ||||||||||||
| 204 | }; | - | ||||||||||||
| 205 | - | |||||||||||||
| 206 | QQuickShapeGradientCache(QOpenGLContext *context) : QOpenGLSharedResource(context->shareGroup()) { } executed 11 times by 1 test:  end of blockExecuted by: 
 | 11 | ||||||||||||
| 207 | ~QQuickShapeGradientCache(); | - | ||||||||||||
| 208 | - | |||||||||||||
| 209 | void invalidateResource() override; | - | ||||||||||||
| 210 | void freeResource(QOpenGLContext *) override; | - | ||||||||||||
| 211 | - | |||||||||||||
| 212 | QSGTexture *get(const Key &grad); | - | ||||||||||||
| 213 | - | |||||||||||||
| 214 | static QQuickShapeGradientCache *currentCache(); | - | ||||||||||||
| 215 | - | |||||||||||||
| 216 | private: | - | ||||||||||||
| 217 | QHash<Key, QSGPlainTexture *> m_cache; | - | ||||||||||||
| 218 | }; | - | ||||||||||||
| 219 | - | |||||||||||||
| 220 | inline uint qHash(const QQuickShapeGradientCache::Key &v, uint seed = 0) | - | ||||||||||||
| 221 | { | - | ||||||||||||
| 222 | uint h = seed + v.spread; | - | ||||||||||||
| 223 | for (int i = 0; i < 3 && i < v.stops.count(); ++i) 
 
 | 8-90 | ||||||||||||
| 224 | h += v.stops[i].second.rgba(); executed 82 times by 1 test:  h += v.stops[i].second.rgba();Executed by: 
 | 82 | ||||||||||||
| 225 | return h; executed 30 times by 1 test:  return h;Executed by: 
 | 30 | ||||||||||||
| 226 | } | - | ||||||||||||
| 227 | - | |||||||||||||
| 228 | #endif // QT_CONFIG(opengl) | - | ||||||||||||
| 229 | - | |||||||||||||
| 230 | QT_END_NAMESPACE | - | ||||||||||||
| 231 | - | |||||||||||||
| 232 | #endif | - | ||||||||||||
| Source code | Switch to Preprocessed file |