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 QQuickPath *path) override;
41 void setPath(int index, const QPainterPath &path, QQuickShapePath::PathHints pathHints = {}) override;
42 void setStrokeColor(int index, const QColor &color) override;
43 void setStrokeWidth(int index, qreal w) override;
44 void setFillColor(int index, const QColor &color) override;
45 void setFillRule(int index, QQuickShapePath::FillRule fillRule) override;
46 void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override;
47 void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override;
48 void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle,
49 qreal dashOffset, const QVector<qreal> &dashPattern) override;
50 void setFillGradient(int index, QQuickShapeGradient *gradient) override;
51 void setFillTextureProvider(int index, QQuickItem *textureProviderItem) override;
52 void setFillTransform(int index, const QSGTransform &transform) override;
53 void endSync(bool async) override;
54 void handleSceneChange(QQuickWindow *window) override;
55
56 void updateNode() override;
57
58 void setNode(QQuickShapeSoftwareRenderNode *node);
59
60private:
61 QQuickShapeSoftwareRenderNode *m_node = nullptr;
62 int m_accDirty = 0;
63 struct ShapePathGuiData {
64 int dirty = 0;
65 QPainterPath path;
66 QPen pen;
67 float strokeWidth;
68 QColor fillColor;
69 QBrush brush;
70 Qt::FillRule fillRule;
71 };
72 QVector<ShapePathGuiData> m_sp;
73};
74
75class QQuickShapeSoftwareRenderNode : public QSGRenderNode
76{
77public:
78 QQuickShapeSoftwareRenderNode(QQuickShape *item);
79 ~QQuickShapeSoftwareRenderNode();
80
81 void render(const RenderState *state) override;
82 void releaseResources() override;
83 StateFlags changedStates() const override;
84 RenderingFlags flags() const override;
85 QRectF rect() const override;
86
87private:
88 QQuickShape *m_item;
89
90 struct ShapePathRenderData {
91 QPainterPath path;
92 QPen pen;
93 float strokeWidth;
94 QBrush brush;
95 };
96 QVector<ShapePathRenderData> m_sp;
97 QRectF m_boundingRect;
98
99 friend class QQuickShapeSoftwareRenderer;
100};
101
102QT_END_NAMESPACE
103
104#endif // QQUICKSHAPESOFTWARERENDERER_P_H
105

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

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