1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKSHAPESOFTWARERENDERER_P_H
5#define QQUICKSHAPESOFTWARERENDERER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of a number of Qt sources files. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuickShapes/private/qquickshapesglobal_p.h>
19#include <QtQuickShapes/private/qquickshape_p_p.h>
20#include <qsgrendernode.h>
21#include <QPen>
22#include <QBrush>
23
24QT_BEGIN_NAMESPACE
25
26class QQuickShapeSoftwareRenderNode;
27
28class QQuickShapeSoftwareRenderer : public QQuickAbstractPathRenderer
29{
30public:
31 enum Dirty {
32 DirtyPath = 0x01,
33 DirtyPen = 0x02,
34 DirtyFillRule = 0x04,
35 DirtyBrush = 0x08,
36 DirtyList = 0x10
37 };
38
39 void beginSync(int totalCount, bool *countChanged) override;
40 void setPath(int index, const QPainterPath &path, QQuickShapePath::PathHints pathHints = {}) override;
41 void setStrokeColor(int index, const QColor &color) override;
42 void setStrokeWidth(int index, qreal w) override;
43 void setFillColor(int index, const QColor &color) override;
44 void setFillRule(int index, QQuickShapePath::FillRule fillRule) override;
45 void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override;
46 void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override;
47 void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,
48 qreal dashOffset, const QVector<qreal> &dashPattern) override;
49 void setFillGradient(int index, QQuickShapeGradient *gradient) override;
50 void setFillTextureProvider(int index, QQuickItem *textureProviderItem) override;
51 void setFillTransform(int index, const QSGTransform &transform) override;
52 void endSync(bool async) override;
53 void handleSceneChange(QQuickWindow *window) override;
54
55 void updateNode() override;
56
57 void setNode(QQuickShapeSoftwareRenderNode *node);
58
59private:
60 QQuickShapeSoftwareRenderNode *m_node = nullptr;
61 int m_accDirty = 0;
62 struct ShapePathGuiData {
63 int dirty = 0;
64 QPainterPath path;
65 QPen pen;
66 float strokeWidth;
67 QColor fillColor;
68 QBrush brush;
69 Qt::FillRule fillRule;
70 };
71 QVector<ShapePathGuiData> m_sp;
72};
73
74class QQuickShapeSoftwareRenderNode : public QSGRenderNode
75{
76public:
77 QQuickShapeSoftwareRenderNode(QQuickShape *item);
78 ~QQuickShapeSoftwareRenderNode();
79
80 void render(const RenderState *state) override;
81 void releaseResources() override;
82 StateFlags changedStates() const override;
83 RenderingFlags flags() const override;
84 QRectF rect() const override;
85
86private:
87 QQuickShape *m_item;
88
89 struct ShapePathRenderData {
90 QPainterPath path;
91 QPen pen;
92 float strokeWidth;
93 QBrush brush;
94 };
95 QVector<ShapePathRenderData> m_sp;
96 QRectF m_boundingRect;
97
98 friend class QQuickShapeSoftwareRenderer;
99};
100
101QT_END_NAMESPACE
102
103#endif // QQUICKSHAPESOFTWARERENDERER_P_H
104

source code of qtdeclarative/src/quickshapes/qquickshapesoftwarerenderer_p.h