| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/qsgadaptationlayer_p.h |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
| 9 | ** Commercial License Usage | - | ||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
| 16 | ** | - | ||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
| 24 | ** | - | ||||||
| 25 | ** GNU General Public License Usage | - | ||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
| 35 | ** | - | ||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||
| 37 | ** | - | ||||||
| 38 | ****************************************************************************/ | - | ||||||
| 39 | - | |||||||
| 40 | #ifndef QSGADAPTATIONLAYER_P_H | - | ||||||
| 41 | #define QSGADAPTATIONLAYER_P_H | - | ||||||
| 42 | - | |||||||
| 43 | // | - | ||||||
| 44 | // W A R N I N G | - | ||||||
| 45 | // ------------- | - | ||||||
| 46 | // | - | ||||||
| 47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
| 48 | // implementation detail. This header file may change from version to | - | ||||||
| 49 | // version without notice, or even be removed. | - | ||||||
| 50 | // | - | ||||||
| 51 | // We mean it. | - | ||||||
| 52 | // | - | ||||||
| 53 | - | |||||||
| 54 | #include <QtQuick/qsgnode.h> | - | ||||||
| 55 | #include <QtQuick/qsgtexture.h> | - | ||||||
| 56 | #include <QtCore/qobject.h> | - | ||||||
| 57 | #include <QtCore/qrect.h> | - | ||||||
| 58 | #include <QtGui/qbrush.h> | - | ||||||
| 59 | #include <QtGui/qcolor.h> | - | ||||||
| 60 | #include <QtCore/qsharedpointer.h> | - | ||||||
| 61 | #include <QtGui/qglyphrun.h> | - | ||||||
| 62 | #include <QtCore/qurl.h> | - | ||||||
| 63 | #include <private/qfontengine_p.h> | - | ||||||
| 64 | #include <QtGui/private/qdatabuffer_p.h> | - | ||||||
| 65 | #include <private/qopenglcontext_p.h> | - | ||||||
| 66 | #include <private/qdistancefield_p.h> | - | ||||||
| 67 | #include <private/qintrusivelist_p.h> | - | ||||||
| 68 | - | |||||||
| 69 | // ### remove | - | ||||||
| 70 | #include <QtQuick/private/qquicktext_p.h> | - | ||||||
| 71 | - | |||||||
| 72 | QT_BEGIN_NAMESPACE | - | ||||||
| 73 | - | |||||||
| 74 | class QSGNode; | - | ||||||
| 75 | class QImage; | - | ||||||
| 76 | class TextureReference; | - | ||||||
| 77 | class QSGDistanceFieldGlyphNode; | - | ||||||
| 78 | class QOpenGLContext; | - | ||||||
| 79 | class QSGInternalImageNode; | - | ||||||
| 80 | class QSGPainterNode; | - | ||||||
| 81 | class QSGInternalRectangleNode; | - | ||||||
| 82 | class QSGGlyphNode; | - | ||||||
| 83 | class QSGRootNode; | - | ||||||
| 84 | class QSGSpriteNode; | - | ||||||
| 85 | class QSGRenderNode; | - | ||||||
| 86 | - | |||||||
| 87 | class Q_QUICK_PRIVATE_EXPORT QSGNodeVisitorEx | - | ||||||
| 88 | { | - | ||||||
| 89 | public: | - | ||||||
| 90 | virtual ~QSGNodeVisitorEx() {} | - | ||||||
| 91 | - | |||||||
| 92 | // visit(...) returns true if the children are supposed to be | - | ||||||
| 93 | // visisted and false if they're supposed to be skipped by the visitor. | - | ||||||
| 94 | - | |||||||
| 95 | virtual bool visit(QSGTransformNode *) = 0; | - | ||||||
| 96 | virtual void endVisit(QSGTransformNode *) = 0; | - | ||||||
| 97 | virtual bool visit(QSGClipNode *) = 0; | - | ||||||
| 98 | virtual void endVisit(QSGClipNode *) = 0; | - | ||||||
| 99 | virtual bool visit(QSGGeometryNode *) = 0; | - | ||||||
| 100 | virtual void endVisit(QSGGeometryNode *) = 0; | - | ||||||
| 101 | virtual bool visit(QSGOpacityNode *) = 0; | - | ||||||
| 102 | virtual void endVisit(QSGOpacityNode *) = 0; | - | ||||||
| 103 | virtual bool visit(QSGInternalImageNode *) = 0; | - | ||||||
| 104 | virtual void endVisit(QSGInternalImageNode *) = 0; | - | ||||||
| 105 | virtual bool visit(QSGPainterNode *) = 0; | - | ||||||
| 106 | virtual void endVisit(QSGPainterNode *) = 0; | - | ||||||
| 107 | virtual bool visit(QSGInternalRectangleNode *) = 0; | - | ||||||
| 108 | virtual void endVisit(QSGInternalRectangleNode *) = 0; | - | ||||||
| 109 | virtual bool visit(QSGGlyphNode *) = 0; | - | ||||||
| 110 | virtual void endVisit(QSGGlyphNode *) = 0; | - | ||||||
| 111 | virtual bool visit(QSGRootNode *) = 0; | - | ||||||
| 112 | virtual void endVisit(QSGRootNode *) = 0; | - | ||||||
| 113 | #if QT_CONFIG(quick_sprite) | - | ||||||
| 114 | virtual bool visit(QSGSpriteNode *) = 0; | - | ||||||
| 115 | virtual void endVisit(QSGSpriteNode *) = 0; | - | ||||||
| 116 | #endif | - | ||||||
| 117 | virtual bool visit(QSGRenderNode *) = 0; | - | ||||||
| 118 | virtual void endVisit(QSGRenderNode *) = 0; | - | ||||||
| 119 | - | |||||||
| 120 | void visitChildren(QSGNode *node); | - | ||||||
| 121 | }; | - | ||||||
| 122 | - | |||||||
| 123 | - | |||||||
| 124 | class Q_QUICK_PRIVATE_EXPORT QSGVisitableNode : public QSGGeometryNode | - | ||||||
| 125 | { | - | ||||||
| 126 | public: | - | ||||||
| 127 | QSGVisitableNode() { setFlag(IsVisitableNode); } executed 326527 times by 70 tests: end of blockExecuted by:
| 326527 | ||||||
| 128 | - | |||||||
| 129 | virtual void accept(QSGNodeVisitorEx *) = 0; | - | ||||||
| 130 | }; | - | ||||||
| 131 | - | |||||||
| 132 | class Q_QUICK_PRIVATE_EXPORT QSGInternalRectangleNode : public QSGVisitableNode | - | ||||||
| 133 | { | - | ||||||
| 134 | public: | - | ||||||
| 135 | virtual void setRect(const QRectF &rect) = 0; | - | ||||||
| 136 | virtual void setColor(const QColor &color) = 0; | - | ||||||
| 137 | virtual void setPenColor(const QColor &color) = 0; | - | ||||||
| 138 | virtual void setPenWidth(qreal width) = 0; | - | ||||||
| 139 | virtual void setGradientStops(const QGradientStops &stops) = 0; | - | ||||||
| 140 | virtual void setGradientVertical(bool vertical) = 0; | - | ||||||
| 141 | virtual void setRadius(qreal radius) = 0; | - | ||||||
| 142 | virtual void setAntialiasing(bool antialiasing) { Q_UNUSED(antialiasing) } never executed: end of block | 0 | ||||||
| 143 | virtual void setAligned(bool aligned) = 0; | - | ||||||
| 144 | - | |||||||
| 145 | virtual void update() = 0; | - | ||||||
| 146 | - | |||||||
| 147 | void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } never executed: end of blocknever executed: visitor->visitChildren(this);
| 0 | ||||||
| 148 | }; | - | ||||||
| 149 | - | |||||||
| 150 | - | |||||||
| 151 | class Q_QUICK_PRIVATE_EXPORT QSGInternalImageNode : public QSGVisitableNode | - | ||||||
| 152 | { | - | ||||||
| 153 | public: | - | ||||||
| 154 | virtual void setTargetRect(const QRectF &rect) = 0; | - | ||||||
| 155 | virtual void setInnerTargetRect(const QRectF &rect) = 0; | - | ||||||
| 156 | virtual void setInnerSourceRect(const QRectF &rect) = 0; | - | ||||||
| 157 | // The sub-source rect's width and height specify the number of times the inner source rect | - | ||||||
| 158 | // is repeated inside the inner target rect. The x and y specify which (normalized) location | - | ||||||
| 159 | // in the inner source rect maps to the upper-left corner of the inner target rect. | - | ||||||
| 160 | virtual void setSubSourceRect(const QRectF &rect) = 0; | - | ||||||
| 161 | virtual void setTexture(QSGTexture *texture) = 0; | - | ||||||
| 162 | virtual void setAntialiasing(bool antialiasing) { Q_UNUSED(antialiasing) } never executed: end of block | 0 | ||||||
| 163 | virtual void setMirror(bool mirror) = 0; | - | ||||||
| 164 | virtual void setMipmapFiltering(QSGTexture::Filtering filtering) = 0; | - | ||||||
| 165 | virtual void setFiltering(QSGTexture::Filtering filtering) = 0; | - | ||||||
| 166 | virtual void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) = 0; | - | ||||||
| 167 | virtual void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) = 0; | - | ||||||
| 168 | - | |||||||
| 169 | virtual void update() = 0; | - | ||||||
| 170 | - | |||||||
| 171 | void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } never executed: end of blocknever executed: visitor->visitChildren(this);
| 0 | ||||||
| 172 | }; | - | ||||||
| 173 | - | |||||||
| 174 | class Q_QUICK_PRIVATE_EXPORT QSGPainterNode : public QSGVisitableNode | - | ||||||
| 175 | { | - | ||||||
| 176 | public: | - | ||||||
| 177 | - | |||||||
| 178 | virtual void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) = 0; | - | ||||||
| 179 | virtual void setSize(const QSize &size) = 0; | - | ||||||
| 180 | virtual void setDirty(const QRect &dirtyRect = QRect()) = 0; | - | ||||||
| 181 | virtual void setOpaquePainting(bool opaque) = 0; | - | ||||||
| 182 | virtual void setLinearFiltering(bool linearFiltering) = 0; | - | ||||||
| 183 | virtual void setMipmapping(bool mipmapping) = 0; | - | ||||||
| 184 | virtual void setSmoothPainting(bool s) = 0; | - | ||||||
| 185 | virtual void setFillColor(const QColor &c) = 0; | - | ||||||
| 186 | virtual void setContentsScale(qreal s) = 0; | - | ||||||
| 187 | virtual void setFastFBOResizing(bool dynamic) = 0; | - | ||||||
| 188 | virtual void setTextureSize(const QSize &size) = 0; | - | ||||||
| 189 | - | |||||||
| 190 | virtual QImage toImage() const = 0; | - | ||||||
| 191 | virtual void update() = 0; | - | ||||||
| 192 | virtual QSGTexture *texture() const = 0; | - | ||||||
| 193 | - | |||||||
| 194 | void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } never executed: end of blocknever executed: visitor->visitChildren(this);
| 0 | ||||||
| 195 | }; | - | ||||||
| 196 | - | |||||||
| 197 | class Q_QUICK_EXPORT QSGLayer : public QSGDynamicTexture | - | ||||||
| 198 | { | - | ||||||
| 199 | Q_OBJECT | - | ||||||
| 200 | public: | - | ||||||
| 201 | virtual void setItem(QSGNode *item) = 0; | - | ||||||
| 202 | virtual void setRect(const QRectF &rect) = 0; | - | ||||||
| 203 | virtual void setSize(const QSize &size) = 0; | - | ||||||
| 204 | virtual void scheduleUpdate() = 0; | - | ||||||
| 205 | virtual QImage toImage() const = 0; | - | ||||||
| 206 | virtual void setLive(bool live) = 0; | - | ||||||
| 207 | virtual void setRecursive(bool recursive) = 0; | - | ||||||
| 208 | virtual void setFormat(uint format) = 0; | - | ||||||
| 209 | virtual void setHasMipmaps(bool mipmap) = 0; | - | ||||||
| 210 | virtual void setDevicePixelRatio(qreal ratio) = 0; | - | ||||||
| 211 | virtual void setMirrorHorizontal(bool mirror) = 0; | - | ||||||
| 212 | virtual void setMirrorVertical(bool mirror) = 0; | - | ||||||
| 213 | virtual void setSamples(int samples) = 0; | - | ||||||
| 214 | Q_SLOT virtual void markDirtyTexture() = 0; | - | ||||||
| 215 | Q_SLOT virtual void invalidated() = 0; | - | ||||||
| 216 | - | |||||||
| 217 | Q_SIGNALS: | - | ||||||
| 218 | void updateRequested(); | - | ||||||
| 219 | void scheduledUpdateCompleted(); | - | ||||||
| 220 | }; | - | ||||||
| 221 | - | |||||||
| 222 | #if QT_CONFIG(quick_sprite) | - | ||||||
| 223 | - | |||||||
| 224 | class Q_QUICK_PRIVATE_EXPORT QSGSpriteNode : public QSGVisitableNode | - | ||||||
| 225 | { | - | ||||||
| 226 | public: | - | ||||||
| 227 | virtual void setTexture(QSGTexture *texture) = 0; | - | ||||||
| 228 | virtual void setTime(float time) = 0; | - | ||||||
| 229 | virtual void setSourceA(const QPoint &source) = 0; | - | ||||||
| 230 | virtual void setSourceB(const QPoint &source) = 0; | - | ||||||
| 231 | virtual void setSpriteSize(const QSize &size) = 0; | - | ||||||
| 232 | virtual void setSheetSize(const QSize &size) = 0; | - | ||||||
| 233 | virtual void setSize(const QSizeF &size) = 0; | - | ||||||
| 234 | virtual void setFiltering(QSGTexture::Filtering filtering) = 0; | - | ||||||
| 235 | - | |||||||
| 236 | virtual void update() = 0; | - | ||||||
| 237 | - | |||||||
| 238 | void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } never executed: end of blocknever executed: visitor->visitChildren(this);
| 0 | ||||||
| 239 | }; | - | ||||||
| 240 | - | |||||||
| 241 | #endif | - | ||||||
| 242 | - | |||||||
| 243 | class Q_QUICK_PRIVATE_EXPORT QSGGuiThreadShaderEffectManager : public QObject | - | ||||||
| 244 | { | - | ||||||
| 245 | Q_OBJECT | - | ||||||
| 246 | - | |||||||
| 247 | public: | - | ||||||
| 248 | enum Status { | - | ||||||
| 249 | Compiled, | - | ||||||
| 250 | Uncompiled, | - | ||||||
| 251 | Error | - | ||||||
| 252 | }; | - | ||||||
| 253 | - | |||||||
| 254 | virtual bool hasSeparateSamplerAndTextureObjects() const = 0; | - | ||||||
| 255 | - | |||||||
| 256 | virtual QString log() const = 0; | - | ||||||
| 257 | virtual Status status() const = 0; | - | ||||||
| 258 | - | |||||||
| 259 | struct ShaderInfo { | - | ||||||
| 260 | enum Type { | - | ||||||
| 261 | TypeVertex, | - | ||||||
| 262 | TypeFragment, | - | ||||||
| 263 | TypeOther | - | ||||||
| 264 | }; | - | ||||||
| 265 | enum VariableType { | - | ||||||
| 266 | Constant, // cbuffer members or uniforms | - | ||||||
| 267 | Sampler, | - | ||||||
| 268 | Texture // for APIs with separate texture and sampler objects | - | ||||||
| 269 | }; | - | ||||||
| 270 | struct InputParameter { | - | ||||||
| 271 | InputParameter() {} | - | ||||||
| 272 | // Semantics use the D3D keys (POSITION, TEXCOORD). | - | ||||||
| 273 | // Attribute name based APIs can map based on pre-defined names. | - | ||||||
| 274 | QByteArray semanticName; | - | ||||||
| 275 | int semanticIndex = 0; | - | ||||||
| 276 | }; | - | ||||||
| 277 | struct Variable { | - | ||||||
| 278 | Variable() {} | - | ||||||
| 279 | VariableType type = Constant; | - | ||||||
| 280 | QByteArray name; | - | ||||||
| 281 | uint offset = 0; // for cbuffer members | - | ||||||
| 282 | uint size = 0; // for cbuffer members | - | ||||||
| 283 | int bindPoint = 0; // for textures and samplers; for register-based APIs | - | ||||||
| 284 | }; | - | ||||||
| 285 | - | |||||||
| 286 | QByteArray blob; // source or bytecode | - | ||||||
| 287 | Type type; | - | ||||||
| 288 | QVector<InputParameter> inputParameters; | - | ||||||
| 289 | QVector<Variable> variables; | - | ||||||
| 290 | uint constantDataSize; | - | ||||||
| 291 | }; | - | ||||||
| 292 | - | |||||||
| 293 | virtual void prepareShaderCode(ShaderInfo::Type typeHint, const QByteArray &src, ShaderInfo *result) = 0; | - | ||||||
| 294 | - | |||||||
| 295 | Q_SIGNALS: | - | ||||||
| 296 | void shaderCodePrepared(bool ok, ShaderInfo::Type typeHint, const QByteArray &src, ShaderInfo *result); | - | ||||||
| 297 | void textureChanged(); | - | ||||||
| 298 | void logAndStatusChanged(); | - | ||||||
| 299 | }; | - | ||||||
| 300 | - | |||||||
| 301 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||
| 302 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug debug, const QSGGuiThreadShaderEffectManager::ShaderInfo::InputParameter &p); | - | ||||||
| 303 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug debug, const QSGGuiThreadShaderEffectManager::ShaderInfo::Variable &v); | - | ||||||
| 304 | #endif | - | ||||||
| 305 | - | |||||||
| 306 | class Q_QUICK_PRIVATE_EXPORT QSGShaderEffectNode : public QSGVisitableNode | - | ||||||
| 307 | { | - | ||||||
| 308 | public: | - | ||||||
| 309 | enum DirtyShaderFlag { | - | ||||||
| 310 | DirtyShaders = 0x01, | - | ||||||
| 311 | DirtyShaderConstant = 0x02, | - | ||||||
| 312 | DirtyShaderTexture = 0x04, | - | ||||||
| 313 | DirtyShaderGeometry = 0x08, | - | ||||||
| 314 | DirtyShaderMesh = 0x10, | - | ||||||
| 315 | - | |||||||
| 316 | DirtyShaderAll = 0xFF | - | ||||||
| 317 | }; | - | ||||||
| 318 | Q_DECLARE_FLAGS(DirtyShaderFlags, DirtyShaderFlag) | - | ||||||
| 319 | - | |||||||
| 320 | enum CullMode { // must match ShaderEffect | - | ||||||
| 321 | NoCulling, | - | ||||||
| 322 | BackFaceCulling, | - | ||||||
| 323 | FrontFaceCulling | - | ||||||
| 324 | }; | - | ||||||
| 325 | - | |||||||
| 326 | struct VariableData { | - | ||||||
| 327 | enum SpecialType { None, Unused, Source, SubRect, Opacity, Matrix }; | - | ||||||
| 328 | - | |||||||
| 329 | QVariant value; | - | ||||||
| 330 | SpecialType specialType; | - | ||||||
| 331 | }; | - | ||||||
| 332 | - | |||||||
| 333 | struct ShaderData { | - | ||||||
| 334 | ShaderData() {} | - | ||||||
| 335 | bool hasShaderCode = false; | - | ||||||
| 336 | QSGGuiThreadShaderEffectManager::ShaderInfo shaderInfo; | - | ||||||
| 337 | QVector<VariableData> varData; | - | ||||||
| 338 | }; | - | ||||||
| 339 | - | |||||||
| 340 | struct SyncData { | - | ||||||
| 341 | DirtyShaderFlags dirty; | - | ||||||
| 342 | CullMode cullMode; | - | ||||||
| 343 | bool blending; | - | ||||||
| 344 | struct ShaderSyncData { | - | ||||||
| 345 | const ShaderData *shader; | - | ||||||
| 346 | const QSet<int> *dirtyConstants; | - | ||||||
| 347 | const QSet<int> *dirtyTextures; | - | ||||||
| 348 | }; | - | ||||||
| 349 | ShaderSyncData vertex; | - | ||||||
| 350 | ShaderSyncData fragment; | - | ||||||
| 351 | }; | - | ||||||
| 352 | - | |||||||
| 353 | // Each ShaderEffect item has one node (render thread) and one manager (gui thread). | - | ||||||
| 354 | QSGShaderEffectNode(QSGGuiThreadShaderEffectManager *) { } | - | ||||||
| 355 | - | |||||||
| 356 | virtual QRectF updateNormalizedTextureSubRect(bool supportsAtlasTextures) = 0; | - | ||||||
| 357 | virtual void syncMaterial(SyncData *syncData) = 0; | - | ||||||
| 358 | - | |||||||
| 359 | void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } never executed: end of blocknever executed: visitor->visitChildren(this);
| 0 | ||||||
| 360 | }; | - | ||||||
| 361 | - | |||||||
| 362 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSGShaderEffectNode::DirtyShaderFlags) | - | ||||||
| 363 | - | |||||||
| 364 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||
| 365 | Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug debug, const QSGShaderEffectNode::VariableData &vd); | - | ||||||
| 366 | #endif | - | ||||||
| 367 | - | |||||||
| 368 | class Q_QUICK_PRIVATE_EXPORT QSGGlyphNode : public QSGVisitableNode | - | ||||||
| 369 | { | - | ||||||
| 370 | public: | - | ||||||
| 371 | enum AntialiasingMode | - | ||||||
| 372 | { | - | ||||||
| 373 | GrayAntialiasing, | - | ||||||
| 374 | LowQualitySubPixelAntialiasing, | - | ||||||
| 375 | HighQualitySubPixelAntialiasing | - | ||||||
| 376 | }; | - | ||||||
| 377 | - | |||||||
| 378 | QSGGlyphNode() {} | - | ||||||
| 379 | - | |||||||
| 380 | virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) = 0; | - | ||||||
| 381 | virtual void setColor(const QColor &color) = 0; | - | ||||||
| 382 | virtual void setStyle(QQuickText::TextStyle style) = 0; | - | ||||||
| 383 | virtual void setStyleColor(const QColor &color) = 0; | - | ||||||
| 384 | virtual QPointF baseLine() const = 0; | - | ||||||
| 385 | - | |||||||
| 386 | virtual QRectF boundingRect() const { return m_bounding_rect; } never executed: return m_bounding_rect; | 0 | ||||||
| 387 | virtual void setBoundingRect(const QRectF &bounds) { m_bounding_rect = bounds; } executed 240986 times by 25 tests: end of blockExecuted by:
| 240986 | ||||||
| 388 | - | |||||||
| 389 | virtual void setPreferredAntialiasingMode(AntialiasingMode) = 0; | - | ||||||
| 390 | - | |||||||
| 391 | virtual void update() = 0; | - | ||||||
| 392 | - | |||||||
| 393 | void setOwnerElement(QQuickItem *ownerElement) { m_ownerElement = ownerElement; } executed 249213 times by 25 tests: end of blockExecuted by:
| 249213 | ||||||
| 394 | QQuickItem *ownerElement() const { return m_ownerElement; } executed 747423 times by 25 tests: return m_ownerElement;Executed by:
| 747423 | ||||||
| 395 | - | |||||||
| 396 | void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } never executed: end of blocknever executed: visitor->visitChildren(this);
| 0 | ||||||
| 397 | protected: | - | ||||||
| 398 | QRectF m_bounding_rect; | - | ||||||
| 399 | QQuickItem *m_ownerElement = nullptr; | - | ||||||
| 400 | }; | - | ||||||
| 401 | - | |||||||
| 402 | class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldGlyphConsumer | - | ||||||
| 403 | { | - | ||||||
| 404 | public: | - | ||||||
| 405 | virtual ~QSGDistanceFieldGlyphConsumer() {} | - | ||||||
| 406 | - | |||||||
| 407 | virtual void invalidateGlyphs(const QVector<quint32> &glyphs) = 0; | - | ||||||
| 408 | QIntrusiveListNode node; | - | ||||||
| 409 | }; | - | ||||||
| 410 | typedef QIntrusiveList<QSGDistanceFieldGlyphConsumer, &QSGDistanceFieldGlyphConsumer::node> QSGDistanceFieldGlyphConsumerList; | - | ||||||
| 411 | - | |||||||
| 412 | class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldGlyphCache | - | ||||||
| 413 | { | - | ||||||
| 414 | public: | - | ||||||
| 415 | QSGDistanceFieldGlyphCache(QOpenGLContext *c, const QRawFont &font); | - | ||||||
| 416 | virtual ~QSGDistanceFieldGlyphCache(); | - | ||||||
| 417 | - | |||||||
| 418 | struct Metrics { | - | ||||||
| 419 | qreal width; | - | ||||||
| 420 | qreal height; | - | ||||||
| 421 | qreal baselineX; | - | ||||||
| 422 | qreal baselineY; | - | ||||||
| 423 | - | |||||||
| 424 | bool isNull() const { return width == 0 || height == 0; } executed 1248303 times by 25 tests: return width == 0 || height == 0;Executed by:
| 1248303 | ||||||
| 425 | }; | - | ||||||
| 426 | - | |||||||
| 427 | struct TexCoord { | - | ||||||
| 428 | qreal x = 0; | - | ||||||
| 429 | qreal y = 0; | - | ||||||
| 430 | qreal width = -1; | - | ||||||
| 431 | qreal height = -1; | - | ||||||
| 432 | qreal xMargin = 0; | - | ||||||
| 433 | qreal yMargin = 0; | - | ||||||
| 434 | - | |||||||
| 435 | TexCoord() {} | - | ||||||
| 436 | - | |||||||
| 437 | bool isNull() const { return width <= 0 || height <= 0; } executed 2714686 times by 25 tests: return width <= 0 || height <= 0;Executed by:
| 2714686 | ||||||
| 438 | bool isValid() const { return width >= 0 && height >= 0; } executed 1380073 times by 25 tests: return width >= 0 && height >= 0;Executed by:
| 1380073 | ||||||
| 439 | }; | - | ||||||
| 440 | - | |||||||
| 441 | struct Texture { | - | ||||||
| 442 | uint textureId = 0; | - | ||||||
| 443 | QSize size; | - | ||||||
| 444 | - | |||||||
| 445 | Texture() : size(QSize()) { } executed 2669 times by 146 tests: end of blockExecuted by:
| 2669 | ||||||
| 446 | bool operator == (const Texture &other) const { return textureId == other.textureId; } executed 739 times by 11 tests: return textureId == other.textureId;Executed by:
| 739 | ||||||
| 447 | }; | - | ||||||
| 448 | - | |||||||
| 449 | const QRawFont &referenceFont() const { return m_referenceFont; } never executed: return m_referenceFont; | 0 | ||||||
| 450 | - | |||||||
| 451 | qreal fontScale(qreal pixelSize) const | - | ||||||
| 452 | { | - | ||||||
| 453 | return pixelSize / QT_DISTANCEFIELD_BASEFONTSIZE(m_doubleGlyphResolution); executed 1738358 times by 25 tests: return pixelSize / QT_DISTANCEFIELD_BASEFONTSIZE(m_doubleGlyphResolution);Executed by:
| 1738358 | ||||||
| 454 | } | - | ||||||
| 455 | int distanceFieldRadius() const | - | ||||||
| 456 | { | - | ||||||
| 457 | return QT_DISTANCEFIELD_RADIUS(m_doubleGlyphResolution) / QT_DISTANCEFIELD_SCALE(m_doubleGlyphResolution); executed 298708 times by 25 tests: return QT_DISTANCEFIELD_RADIUS(m_doubleGlyphResolution) / QT_DISTANCEFIELD_SCALE(m_doubleGlyphResolution);Executed by:
| 298708 | ||||||
| 458 | } | - | ||||||
| 459 | int glyphCount() const { return m_glyphCount; } executed 1380073 times by 25 tests: return m_glyphCount;Executed by:
| 1380073 | ||||||
| 460 | bool doubleGlyphResolution() const { return m_doubleGlyphResolution; } never executed: return m_doubleGlyphResolution; | 0 | ||||||
| 461 | - | |||||||
| 462 | Metrics glyphMetrics(glyph_t glyph, qreal pixelSize); | - | ||||||
| 463 | inline TexCoord glyphTexCoord(glyph_t glyph); | - | ||||||
| 464 | inline const Texture *glyphTexture(glyph_t glyph); | - | ||||||
| 465 | - | |||||||
| 466 | void populate(const QVector<glyph_t> &glyphs); | - | ||||||
| 467 | void release(const QVector<glyph_t> &glyphs); | - | ||||||
| 468 | - | |||||||
| 469 | void update(); | - | ||||||
| 470 | - | |||||||
| 471 | void registerGlyphNode(QSGDistanceFieldGlyphConsumer *node) { m_registeredNodes.insert(node); } executed 249141 times by 25 tests: end of blockExecuted by:
| 249141 | ||||||
| 472 | void unregisterGlyphNode(QSGDistanceFieldGlyphConsumer *node) { m_registeredNodes.remove(node); } executed 249141 times by 25 tests: end of blockExecuted by:
| 249141 | ||||||
| 473 | - | |||||||
| 474 | virtual void registerOwnerElement(QQuickItem *ownerElement); | - | ||||||
| 475 | virtual void unregisterOwnerElement(QQuickItem *ownerElement); | - | ||||||
| 476 | virtual void processPendingGlyphs(); | - | ||||||
| 477 | - | |||||||
| 478 | protected: | - | ||||||
| 479 | struct GlyphPosition { | - | ||||||
| 480 | glyph_t glyph; | - | ||||||
| 481 | QPointF position; | - | ||||||
| 482 | }; | - | ||||||
| 483 | - | |||||||
| 484 | struct GlyphData { | - | ||||||
| 485 | Texture *texture = nullptr; | - | ||||||
| 486 | TexCoord texCoord; | - | ||||||
| 487 | QRectF boundingRect; | - | ||||||
| 488 | QPainterPath path; | - | ||||||
| 489 | quint32 ref = 0; | - | ||||||
| 490 | - | |||||||
| 491 | GlyphData() {} | - | ||||||
| 492 | }; | - | ||||||
| 493 | - | |||||||
| 494 | virtual void requestGlyphs(const QSet<glyph_t> &glyphs) = 0; | - | ||||||
| 495 | virtual void storeGlyphs(const QList<QDistanceField> &glyphs) = 0; | - | ||||||
| 496 | virtual void referenceGlyphs(const QSet<glyph_t> &glyphs) = 0; | - | ||||||
| 497 | virtual void releaseGlyphs(const QSet<glyph_t> &glyphs) = 0; | - | ||||||
| 498 | - | |||||||
| 499 | void setGlyphsPosition(const QList<GlyphPosition> &glyphs); | - | ||||||
| 500 | void setGlyphsTexture(const QVector<glyph_t> &glyphs, const Texture &tex); | - | ||||||
| 501 | void markGlyphsToRender(const QVector<glyph_t> &glyphs); | - | ||||||
| 502 | inline void removeGlyph(glyph_t glyph); | - | ||||||
| 503 | - | |||||||
| 504 | void updateTexture(uint oldTex, uint newTex, const QSize &newTexSize); | - | ||||||
| 505 | - | |||||||
| 506 | inline bool containsGlyph(glyph_t glyph); | - | ||||||
| 507 | uint textureIdForGlyph(glyph_t glyph) const; | - | ||||||
| 508 | - | |||||||
| 509 | GlyphData &glyphData(glyph_t glyph); | - | ||||||
| 510 | - | |||||||
| 511 | #if defined(QSG_DISTANCEFIELD_CACHE_DEBUG) | - | ||||||
| 512 | void saveTexture(GLuint textureId, int width, int height) const; | - | ||||||
| 513 | #endif | - | ||||||
| 514 | - | |||||||
| 515 | inline bool isCoreProfile() const { return m_coreProfile; } executed 34825 times by 25 tests: return m_coreProfile;Executed by:
| 34825 | ||||||
| 516 | - | |||||||
| 517 | private: | - | ||||||
| 518 | QRawFont m_referenceFont; | - | ||||||
| 519 | int m_glyphCount; | - | ||||||
| 520 | - | |||||||
| 521 | bool m_doubleGlyphResolution; | - | ||||||
| 522 | bool m_coreProfile; | - | ||||||
| 523 | - | |||||||
| 524 | QList<Texture> m_textures; | - | ||||||
| 525 | QHash<glyph_t, GlyphData> m_glyphsData; | - | ||||||
| 526 | QDataBuffer<glyph_t> m_pendingGlyphs; | - | ||||||
| 527 | QSet<glyph_t> m_populatingGlyphs; | - | ||||||
| 528 | QSGDistanceFieldGlyphConsumerList m_registeredNodes; | - | ||||||
| 529 | - | |||||||
| 530 | static Texture s_emptyTexture; | - | ||||||
| 531 | }; | - | ||||||
| 532 | - | |||||||
| 533 | inline QSGDistanceFieldGlyphCache::TexCoord QSGDistanceFieldGlyphCache::glyphTexCoord(glyph_t glyph) | - | ||||||
| 534 | { | - | ||||||
| 535 | return glyphData(glyph).texCoord; executed 1360824 times by 25 tests: return glyphData(glyph).texCoord;Executed by:
| 1360824 | ||||||
| 536 | } | - | ||||||
| 537 | - | |||||||
| 538 | inline const QSGDistanceFieldGlyphCache::Texture *QSGDistanceFieldGlyphCache::glyphTexture(glyph_t glyph) | - | ||||||
| 539 | { | - | ||||||
| 540 | return glyphData(glyph).texture; executed 1248303 times by 25 tests: return glyphData(glyph).texture;Executed by:
| 1248303 | ||||||
| 541 | } | - | ||||||
| 542 | - | |||||||
| 543 | inline void QSGDistanceFieldGlyphCache::removeGlyph(glyph_t glyph) | - | ||||||
| 544 | { | - | ||||||
| 545 | GlyphData &gd = glyphData(glyph); | - | ||||||
| 546 | gd.texCoord = TexCoord(); | - | ||||||
| 547 | gd.texture = &s_emptyTexture; | - | ||||||
| 548 | } never executed: end of block | 0 | ||||||
| 549 | - | |||||||
| 550 | inline bool QSGDistanceFieldGlyphCache::containsGlyph(glyph_t glyph) | - | ||||||
| 551 | { | - | ||||||
| 552 | return glyphData(glyph).texCoord.isValid(); never executed: return glyphData(glyph).texCoord.isValid(); | 0 | ||||||
| 553 | } | - | ||||||
| 554 | - | |||||||
| 555 | QT_END_NAMESPACE | - | ||||||
| 556 | - | |||||||
| 557 | Q_DECLARE_METATYPE(QSGGuiThreadShaderEffectManager::ShaderInfo::Type) | - | ||||||
| 558 | - | |||||||
| 559 | #endif | - | ||||||
| Source code | Switch to Preprocessed file |