| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | #ifndef QQUICKSHAPENVPRRENDERER_P_H | - |
| 41 | #define QQUICKSHAPENVPRRENDERER_P_H | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | | - |
| 50 | | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | #include <QtQuickShapes/private/qquickshapesglobal_p.h> | - |
| 55 | #include <QtQuickShapes/private/qquickshape_p_p.h> | - |
| 56 | #include <QtQuickShapes/private/qquicknvprfunctions_p.h> | - |
| 57 | #include <qsgrendernode.h> | - |
| 58 | #include <QColor> | - |
| 59 | #include <QVector4D> | - |
| 60 | #include <QDebug> | - |
| 61 | | - |
| 62 | #if QT_CONFIG(opengl) | - |
| 63 | | - |
| 64 | QT_BEGIN_NAMESPACE | - |
| 65 | | - |
| 66 | class QQuickShapeNvprRenderNode; | - |
| 67 | class QOpenGLFramebufferObject; | - |
| 68 | class QOpenGLBuffer; | - |
| 69 | class QOpenGLExtraFunctions; | - |
| 70 | | - |
| 71 | class QQuickShapeNvprRenderer : public QQuickAbstractPathRenderer | - |
| 72 | { | - |
| 73 | public: | - |
| 74 | enum Dirty { | - |
| 75 | DirtyPath = 0x01, | - |
| 76 | DirtyStyle = 0x02, | - |
| 77 | DirtyFillRule = 0x04, | - |
| 78 | DirtyDash = 0x08, | - |
| 79 | DirtyFillGradient = 0x10, | - |
| 80 | DirtyList = 0x20 | - |
| 81 | }; | - |
| 82 | | - |
| 83 | void beginSync(int totalCount) override; | - |
| 84 | void setPath(int index, const QQuickPath *path) override; | - |
| 85 | void setStrokeColor(int index, const QColor &color) override; | - |
| 86 | void setStrokeWidth(int index, qreal w) override; | - |
| 87 | void setFillColor(int index, const QColor &color) override; | - |
| 88 | void setFillRule(int index, QQuickShapePath::FillRule fillRule) override; | - |
| 89 | void setJoinStyle(int index, QQuickShapePath::JoinStyle joinStyle, int miterLimit) override; | - |
| 90 | void setCapStyle(int index, QQuickShapePath::CapStyle capStyle) override; | - |
| 91 | void setStrokeStyle(int index, QQuickShapePath::StrokeStyle strokeStyle, | - |
| 92 | qreal dashOffset, const QVector<qreal> &dashPattern) override; | - |
| 93 | void setFillGradient(int index, QQuickShapeGradient *gradient) override; | - |
| 94 | void endSync(bool async) override; | - |
| 95 | | - |
| 96 | void updateNode() override; | - |
| 97 | | - |
| 98 | void setNode(QQuickShapeNvprRenderNode *node); | - |
| 99 | | - |
| 100 | struct NvprPath { | - |
| 101 | QVector<GLubyte> cmd; | - |
| 102 | QVector<GLfloat> coord; | - |
| 103 | QByteArray str; | - |
| 104 | }; | - |
| 105 | | - |
| 106 | private: | - |
| 107 | struct ShapePathGuiData { | - |
| 108 | int dirty = 0; | - |
| 109 | NvprPath path; | - |
| 110 | qreal strokeWidth; | - |
| 111 | QColor strokeColor; | - |
| 112 | QColor fillColor; | - |
| 113 | QQuickShapePath::JoinStyle joinStyle; | - |
| 114 | int miterLimit; | - |
| 115 | QQuickShapePath::CapStyle capStyle; | - |
| 116 | QQuickShapePath::FillRule fillRule; | - |
| 117 | bool dashActive; | - |
| 118 | qreal dashOffset; | - |
| 119 | QVector<qreal> dashPattern; | - |
| 120 | FillGradientType fillGradientActive; | - |
| 121 | GradientDesc fillGradient; | - |
| 122 | }; | - |
| 123 | | - |
| 124 | void convertPath(const QQuickPath *path, ShapePathGuiData *d); | - |
| 125 | | - |
| 126 | QQuickShapeNvprRenderNode *m_node = nullptr; | - |
| 127 | int m_accDirty = 0; | - |
| 128 | | - |
| 129 | QVector<ShapePathGuiData> m_sp; | - |
| 130 | }; | - |
| 131 | | - |
| 132 | QDebug operator<<(QDebug debug, const QQuickShapeNvprRenderer::NvprPath &path); | - |
| 133 | | - |
| 134 | class QQuickNvprMaterialManager | - |
| 135 | { | - |
| 136 | public: | - |
| 137 | enum Material { | - |
| 138 | MatSolid, | - |
| 139 | MatLinearGradient, | - |
| 140 | MatRadialGradient, | - |
| 141 | MatConicalGradient, | - |
| 142 | | - |
| 143 | NMaterials | - |
| 144 | }; | - |
| 145 | | - |
| 146 | struct MaterialDesc { | - |
| 147 | GLuint ppl = 0; | - |
| 148 | GLuint prg = 0; | - |
| 149 | int uniLoc[8]; | - |
| 150 | }; | - |
| 151 | | - |
| 152 | void create(QQuickNvprFunctions *nvpr); | - |
| 153 | MaterialDesc *activateMaterial(Material m); | - |
| 154 | void releaseResources(); | - |
| 155 | | - |
| 156 | private: | - |
| 157 | QQuickNvprFunctions *m_nvpr = nullptr; | - |
| 158 | MaterialDesc m_materials[NMaterials]; | - |
| 159 | }; | - |
| 160 | | - |
| 161 | class QQuickNvprBlitter | - |
| 162 | { | - |
| 163 | public: | - |
| 164 | bool create(); | - |
| 165 | void destroy(); | - |
| 166 | bool isCreated() const { return m_program != nullptr; } never executed: return m_program != nullptr; | 0 |
| 167 | void texturedQuad(GLuint textureId, const QSize &size, | - |
| 168 | const QMatrix4x4 &proj, const QMatrix4x4 &modelview, | - |
| 169 | float opacity); | - |
| 170 | | - |
| 171 | private: | - |
| 172 | QOpenGLShaderProgram *m_program = nullptr; | - |
| 173 | QOpenGLBuffer *m_buffer = nullptr; | - |
| 174 | int m_matrixLoc = -1; | - |
| 175 | int m_opacityLoc = -1; | - |
| 176 | QSize m_prevSize; | - |
| 177 | }; | - |
| 178 | | - |
| 179 | class QQuickShapeNvprRenderNode : public QSGRenderNode | - |
| 180 | { | - |
| 181 | public: | - |
| 182 | ~QQuickShapeNvprRenderNode(); | - |
| 183 | | - |
| 184 | void render(const RenderState *state) override; | - |
| 185 | void releaseResources() override; | - |
| 186 | StateFlags changedStates() const override; | - |
| 187 | RenderingFlags flags() const override; | - |
| 188 | | - |
| 189 | static bool isSupported(); | - |
| 190 | | - |
| 191 | private: | - |
| 192 | struct ShapePathRenderData { | - |
| 193 | GLuint path = 0; | - |
| 194 | int dirty = 0; | - |
| 195 | QQuickShapeNvprRenderer::NvprPath source; | - |
| 196 | GLfloat strokeWidth; | - |
| 197 | QVector4D strokeColor; | - |
| 198 | QVector4D fillColor; | - |
| 199 | GLenum joinStyle; | - |
| 200 | GLint miterLimit; | - |
| 201 | GLenum capStyle; | - |
| 202 | GLenum fillRule; | - |
| 203 | GLfloat dashOffset; | - |
| 204 | QVector<GLfloat> dashPattern; | - |
| 205 | QQuickAbstractPathRenderer::FillGradientType fillGradientActive; | - |
| 206 | QQuickAbstractPathRenderer::GradientDesc fillGradient; | - |
| 207 | QOpenGLFramebufferObject *fallbackFbo = nullptr; | - |
| 208 | bool fallbackValid = false; | - |
| 209 | QSize fallbackSize; | - |
| 210 | QPointF fallbackTopLeft; | - |
| 211 | | - |
| 212 | bool hasFill() const { return !qFuzzyIsNull(fillColor.w()) || fillGradientActive; } never executed: return !qFuzzyIsNull(fillColor.w()) || fillGradientActive; | 0 |
| 213 | bool hasStroke() const { return strokeWidth >= 0.0f && !qFuzzyIsNull(strokeColor.w()); } never executed: return strokeWidth >= 0.0f && !qFuzzyIsNull(strokeColor.w()); | 0 |
| 214 | }; | - |
| 215 | | - |
| 216 | void updatePath(ShapePathRenderData *d); | - |
| 217 | void renderStroke(ShapePathRenderData *d, int strokeStencilValue, int writeMask); | - |
| 218 | void renderFill(ShapePathRenderData *d); | - |
| 219 | void renderOffscreenFill(ShapePathRenderData *d); | - |
| 220 | void setupStencilForCover(bool stencilClip, int sv); | - |
| 221 | | - |
| 222 | static bool nvprInited; | - |
| 223 | static QQuickNvprFunctions nvpr; | - |
| 224 | static QQuickNvprMaterialManager mtlmgr; | - |
| 225 | | - |
| 226 | QQuickNvprBlitter m_fallbackBlitter; | - |
| 227 | QOpenGLExtraFunctions *f = nullptr; | - |
| 228 | | - |
| 229 | QVector<ShapePathRenderData> m_sp; | - |
| 230 | | - |
| 231 | friend class QQuickShapeNvprRenderer; | - |
| 232 | }; | - |
| 233 | | - |
| 234 | QT_END_NAMESPACE | - |
| 235 | | - |
| 236 | #endif // QT_CONFIG(opengl) | - |
| 237 | | - |
| 238 | #endif // QQUICKSHAPENVPRRENDERER_P_H | - |
| | |