| 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 QSGSOFTWARERENDERABLENODE_H |
| 5 | #define QSGSOFTWARERENDERABLENODE_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 purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtQuick/private/qtquickglobal_p.h> |
| 19 | |
| 20 | #include <QtGui/QRegion> |
| 21 | #include <QtCore/QRect> |
| 22 | #include <QtGui/QTransform> |
| 23 | #include <QtQuick/qsgrectanglenode.h> |
| 24 | #include <QtQuick/qsgimagenode.h> |
| 25 | #include <QtQuick/qsgninepatchnode.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | class QSGSimpleRectNode; |
| 30 | class QSGSimpleTextureNode; |
| 31 | class QSGSoftwareInternalImageNode; |
| 32 | class QSGSoftwarePainterNode; |
| 33 | class QSGSoftwareInternalRectangleNode; |
| 34 | class QSGSoftwareGlyphNode; |
| 35 | class QSGSoftwareNinePatchNode; |
| 36 | class QSGSoftwareSpriteNode; |
| 37 | class QSGRenderNode; |
| 38 | |
| 39 | class Q_QUICK_EXPORT QSGSoftwareRenderableNode |
| 40 | { |
| 41 | public: |
| 42 | enum NodeType { |
| 43 | Invalid = -1, |
| 44 | SimpleRect, |
| 45 | SimpleTexture, |
| 46 | Image, |
| 47 | Painter, |
| 48 | Rectangle, |
| 49 | Glyph, |
| 50 | NinePatch, |
| 51 | SimpleRectangle, |
| 52 | SimpleImage, |
| 53 | #if QT_CONFIG(quick_sprite) |
| 54 | SpriteNode, |
| 55 | #endif |
| 56 | RenderNode |
| 57 | }; |
| 58 | |
| 59 | QSGSoftwareRenderableNode(NodeType type, QSGNode *node); |
| 60 | ~QSGSoftwareRenderableNode(); |
| 61 | |
| 62 | void update(); |
| 63 | |
| 64 | QRegion renderNode(QPainter *painter, bool forceOpaquePainting = false); |
| 65 | QRect boundingRectMin() const { return m_boundingRectMin; } |
| 66 | QRect boundingRectMax() const { return m_boundingRectMax; } |
| 67 | NodeType type() const { return m_nodeType; } |
| 68 | bool isOpaque() const { return m_isOpaque; } |
| 69 | bool isDirty() const { return m_isDirty; } |
| 70 | bool isDirtyRegionEmpty() const; |
| 71 | QSGNode *handle() const { return m_handle.node; } |
| 72 | |
| 73 | void setTransform(const QTransform &transform); |
| 74 | void setClipRegion(const QRegion &clipRegion, bool hasClipRegion = true); |
| 75 | void setOpacity(float opacity); |
| 76 | QTransform transform() const { return m_transform; } |
| 77 | QRegion clipRegion() const { return m_clipRegion; } |
| 78 | float opacity() const { return m_opacity; } |
| 79 | |
| 80 | void markGeometryDirty(); |
| 81 | void markMaterialDirty(); |
| 82 | |
| 83 | void addDirtyRegion(const QRegion &dirtyRegion, bool forceDirty = true); |
| 84 | void subtractDirtyRegion(const QRegion &dirtyRegion); |
| 85 | |
| 86 | QRegion previousDirtyRegion(bool wasRemoved = false) const; |
| 87 | QRegion dirtyRegion() const; |
| 88 | |
| 89 | private: |
| 90 | union RenderableNodeHandle { |
| 91 | QSGNode *node; |
| 92 | QSGSimpleRectNode *simpleRectNode; |
| 93 | QSGSimpleTextureNode *simpleTextureNode; |
| 94 | QSGSoftwareInternalImageNode *imageNode; |
| 95 | QSGSoftwarePainterNode *painterNode; |
| 96 | QSGSoftwareInternalRectangleNode *rectangleNode; |
| 97 | QSGSoftwareGlyphNode *glpyhNode; |
| 98 | QSGSoftwareNinePatchNode *ninePatchNode; |
| 99 | QSGRectangleNode *simpleRectangleNode; |
| 100 | QSGImageNode *simpleImageNode; |
| 101 | QSGSoftwareSpriteNode *spriteNode; |
| 102 | QSGRenderNode *renderNode; |
| 103 | }; |
| 104 | |
| 105 | const NodeType m_nodeType; |
| 106 | RenderableNodeHandle m_handle; |
| 107 | |
| 108 | bool m_isOpaque; |
| 109 | |
| 110 | bool m_isDirty; |
| 111 | QRegion m_dirtyRegion; |
| 112 | QRegion m_previousDirtyRegion; |
| 113 | |
| 114 | QTransform m_transform; |
| 115 | QRegion m_clipRegion; |
| 116 | bool m_hasClipRegion; |
| 117 | float m_opacity; |
| 118 | |
| 119 | QRect m_boundingRectMin; |
| 120 | QRect m_boundingRectMax; |
| 121 | }; |
| 122 | |
| 123 | QT_END_NAMESPACE |
| 124 | |
| 125 | #endif // QSGSOFTWARERENDERABLENODE_H |
| 126 | |