diff options
Diffstat (limited to 'src/quickshapes/qquickshape_p_p.h')
-rw-r--r-- | src/quickshapes/qquickshape_p_p.h | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/src/quickshapes/qquickshape_p_p.h b/src/quickshapes/qquickshape_p_p.h index 245ba659b2..ffa1068de9 100644 --- a/src/quickshapes/qquickshape_p_p.h +++ b/src/quickshapes/qquickshape_p_p.h @@ -17,7 +17,8 @@ #include <QtQuickShapes/private/qquickshapesglobal_p.h> #include <QtQuickShapes/private/qquickshape_p.h> -#include <QtQuick/private/qquickitem_p.h> +#include <private/qquickitem_p.h> +#include <private/qsgtransform_p.h> #include <QPainterPath> #include <QColor> #include <QBrush> @@ -37,16 +38,7 @@ public: SupportsAsync = 0x01 }; Q_DECLARE_FLAGS(Flags, Flag) - enum FillGradientType { NoGradient = 0, LinearGradient, RadialGradient, ConicalGradient }; - struct GradientDesc { // can fully describe a linear/radial/conical gradient - QGradientStops stops; - QQuickShapeGradient::SpreadMode spread; - QPointF a; // start (L) or center point (R/C) - QPointF b; // end (L) or focal point (R) - qreal v0; // center radius (R) or start angle (C) - qreal v1; // focal radius (R) - }; virtual ~QQuickAbstractPathRenderer() { } @@ -65,6 +57,7 @@ public: virtual void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, qreal dashOffset, const QVector<qreal> &dashPattern) = 0; virtual void setFillGradient(int index, QQuickShapeGradient *gradient) = 0; + virtual void setFillTransform(int index, const QSGTransform &transform) = 0; virtual void setTriangulationScale(qreal) { } // Render thread, with gui blocked @@ -88,9 +81,10 @@ struct QQuickShapeStrokeFillParams qreal dashOffset; QVector<qreal> dashPattern; QQuickShapeGradient *fillGradient; + QSGTransform fillTransform; }; -class Q_QUICKSHAPES_PRIVATE_EXPORT QQuickShapePathPrivate : public QQuickPathPrivate +class Q_QUICKSHAPES_EXPORT QQuickShapePathPrivate : public QQuickPathPrivate { Q_DECLARE_PUBLIC(QQuickShapePath) @@ -104,8 +98,9 @@ public: DirtyStyle = 0x20, DirtyDash = 0x40, DirtyFillGradient = 0x80, + DirtyFillTransform = 0x100, - DirtyAll = 0xFF + DirtyAll = 0x1FF }; QQuickShapePathPrivate(); @@ -117,6 +112,7 @@ public: int dirty; QQuickShapeStrokeFillParams sfp; + QQuickShapePath::PathHints pathHints; }; class QQuickShapePrivate : public QQuickItemPrivate @@ -127,6 +123,7 @@ public: QQuickShapePrivate(); ~QQuickShapePrivate(); + QQuickShape::RendererType selectRendererType(); void createRenderer(); QSGNode *createNode(); void sync(); @@ -138,6 +135,9 @@ public: static void asyncShapeReady(void *data); + qreal getImplicitWidth() const override; + qreal getImplicitHeight() const override; + int effectRefCount; QVector<QQuickShapePath *> sp; QElapsedTimer syncTimer; @@ -146,46 +146,20 @@ public: int syncTimeCounter = 0; QQuickShape::Status status = QQuickShape::Null; QQuickShape::RendererType rendererType = QQuickShape::UnknownRenderer; + QQuickShape::RendererType preferredType = QQuickShape::UnknownRenderer; QQuickShape::ContainsMode containsMode = QQuickShape::BoundingRectContains; + QQuickShape::FillMode fillMode = QQuickShape::NoResize; + QQuickShape::HAlignment horizontalAlignment = QQuickShape::AlignLeft; + QQuickShape::VAlignment verticalAlignment = QQuickShape::AlignTop; + bool spChanged = false; + bool rendererChanged = false; bool async = false; bool enableVendorExts = false; bool syncTimingActive = false; qreal triangulationScale = 1.0; }; -struct QQuickShapeGradientCacheKey -{ - QQuickShapeGradientCacheKey(const QGradientStops &stops, QQuickShapeGradient::SpreadMode spread) - : stops(stops), spread(spread) - { } - QGradientStops stops; - QQuickShapeGradient::SpreadMode spread; - bool operator==(const QQuickShapeGradientCacheKey &other) const - { - return spread == other.spread && stops == other.stops; - } -}; - -inline size_t qHash(const QQuickShapeGradientCacheKey &v, size_t seed = 0) -{ - size_t h = seed + v.spread; - for (int i = 0; i < 3 && i < v.stops.size(); ++i) - h += v.stops[i].second.rgba(); - return h; -} - -class QQuickShapeGradientCache -{ -public: - ~QQuickShapeGradientCache(); - static QQuickShapeGradientCache *cacheForRhi(QRhi *rhi); - QSGTexture *get(const QQuickShapeGradientCacheKey &grad); - -private: - QHash<QQuickShapeGradientCacheKey, QSGPlainTexture *> m_textures; -}; - QT_END_NAMESPACE #endif |