| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | static inline QVector4D qsg_premultiply(const QVector4D &c, float globalOpacity) | - | ||||||||||||||||||
| 8 | { | - | ||||||||||||||||||
| 9 | float o = c.w() * globalOpacity; | - | ||||||||||||||||||
| 10 | return executed 216 times by 1 test: QVector4D(c.x() * o, c.y() * o, c.z() * o, o);return QVector4D(c.x() * o, c.y() * o, c.z() * o, o);Executed by:
executed 216 times by 1 test: return QVector4D(c.x() * o, c.y() * o, c.z() * o, o);Executed by:
| 216 | ||||||||||||||||||
| 11 | } | - | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | static inline qreal qsg_device_pixel_ratio(QOpenGLContext *ctx) | - | ||||||||||||||||||
| 14 | { | - | ||||||||||||||||||
| 15 | qreal devicePixelRatio = 1; | - | ||||||||||||||||||
| 16 | if (ctx->surface()->surfaceClass() == QSurface::Window
| 0-304 | ||||||||||||||||||
| 17 | QWindow *w = static_cast<QWindow *>(ctx->surface()); | - | ||||||||||||||||||
| 18 | if (QQuickWindow *qw = qobject_cast<QQuickWindow *>(w)
| 0-304 | ||||||||||||||||||
| 19 | devicePixelRatio = qw->effectiveDevicePixelRatio(); executed 304 times by 1 test: devicePixelRatio = qw->effectiveDevicePixelRatio();Executed by:
| 304 | ||||||||||||||||||
| 20 | else | - | ||||||||||||||||||
| 21 | devicePixelRatio = w->devicePixelRatio(); never executed: devicePixelRatio = w->devicePixelRatio(); | 0 | ||||||||||||||||||
| 22 | } else { | - | ||||||||||||||||||
| 23 | devicePixelRatio = ctx->screen()
| 0 | ||||||||||||||||||
| 24 | } never executed: end of block | 0 | ||||||||||||||||||
| 25 | return executed 304 times by 1 test: devicePixelRatio;return devicePixelRatio;Executed by:
executed 304 times by 1 test: return devicePixelRatio;Executed by:
| 304 | ||||||||||||||||||
| 26 | } | - | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | class QSGTextMaskShader : public QSGMaterialShader | - | ||||||||||||||||||
| 29 | { | - | ||||||||||||||||||
| 30 | public: | - | ||||||||||||||||||
| 31 | QSGTextMaskShader(QFontEngine::GlyphFormat glyphFormat); | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; | - | ||||||||||||||||||
| 34 | char const *const *attributeNames() const override; | - | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | protected: | - | ||||||||||||||||||
| 37 | void initialize() override; | - | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | int m_matrix_id; | - | ||||||||||||||||||
| 40 | int m_color_id; | - | ||||||||||||||||||
| 41 | int m_textureScale_id; | - | ||||||||||||||||||
| 42 | float m_devicePixelRatio; | - | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | QFontEngine::GlyphFormat m_glyphFormat; | - | ||||||||||||||||||
| 45 | }; | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | char const *const *QSGTextMaskShader::attributeNames() const | - | ||||||||||||||||||
| 48 | { | - | ||||||||||||||||||
| 49 | static char const *const attr[] = { "vCoord", "tCoord", nullptr }; | - | ||||||||||||||||||
| 50 | return executed 664 times by 1 test: attr;return attr;Executed by:
executed 664 times by 1 test: return attr;Executed by:
| 664 | ||||||||||||||||||
| 51 | } | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | QSGTextMaskShader::QSGTextMaskShader(QFontEngine::GlyphFormat glyphFormat) | - | ||||||||||||||||||
| 54 | : QSGMaterialShader(*new QSGMaterialShaderPrivate) | - | ||||||||||||||||||
| 55 | , m_matrix_id(-1) | - | ||||||||||||||||||
| 56 | , m_color_id(-1) | - | ||||||||||||||||||
| 57 | , m_textureScale_id(-1) | - | ||||||||||||||||||
| 58 | , m_glyphFormat(glyphFormat) | - | ||||||||||||||||||
| 59 | { | - | ||||||||||||||||||
| 60 | setShaderSourceFile(QOpenGLShader::Vertex, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/textmask.vert")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/textmask.vert" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 16 times by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 16 times by 1 test: }()));return qstring_literal_temp;Executed by:
| 16 | ||||||||||||||||||
| 61 | setShaderSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/textmask.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/textmask.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 16 times by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 16 times by 1 test: }()));return qstring_literal_temp;Executed by:
| 16 | ||||||||||||||||||
| 62 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | static inline qreal fontSmoothingGamma() | - | ||||||||||||||||||
| 65 | { | - | ||||||||||||||||||
| 66 | static qreal fontSmoothingGamma = QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal(); | - | ||||||||||||||||||
| 67 | return never executed: fontSmoothingGamma;return fontSmoothingGamma;never executed: return fontSmoothingGamma; | 0 | ||||||||||||||||||
| 68 | } | - | ||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | void QSGTextMaskShader::initialize() | - | ||||||||||||||||||
| 71 | { | - | ||||||||||||||||||
| 72 | m_matrix_id = program()->uniformLocation("matrix"); | - | ||||||||||||||||||
| 73 | m_color_id = program()->uniformLocation("color"); | - | ||||||||||||||||||
| 74 | m_textureScale_id = program()->uniformLocation("textureScale"); | - | ||||||||||||||||||
| 75 | m_devicePixelRatio = (float) qsg_device_pixel_ratio(QOpenGLContext::currentContext()); | - | ||||||||||||||||||
| 76 | program()->setUniformValue("dpr", m_devicePixelRatio); | - | ||||||||||||||||||
| 77 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | void QSGTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) | - | ||||||||||||||||||
| 80 | { | - | ||||||||||||||||||
| 81 | QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect); | - | ||||||||||||||||||
| 82 | QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect); | - | ||||||||||||||||||
| 83 | ((oldEffect == nullptr || newEffect->type() == oldEffect->type()) ? static_cast<void>(0) : qt_assert("oldEffect == nullptr || newEffect->type() == oldEffect->type()", __FILE__, 144)); | - | ||||||||||||||||||
| 84 | bool updated = material->ensureUpToDate(); | - | ||||||||||||||||||
| 85 | ((material->texture()) ? static_cast<void>(0) : qt_assert("material->texture()", __FILE__, 146)); | - | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | ((oldMaterial == nullptr || oldMaterial->texture()) ? static_cast<void>(0) : qt_assert("oldMaterial == nullptr || oldMaterial->texture()", __FILE__, 148)); | - | ||||||||||||||||||
| 88 | if (updated
| 72-144 | ||||||||||||||||||
| 89 | || oldMaterial == nullptr
| 0-144 | ||||||||||||||||||
| 90 | || oldMaterial->texture()->textureId() != material->texture()->textureId()
| 0 | ||||||||||||||||||
| 91 | program()->setUniformValue(m_textureScale_id, QVector2D(1.0 / material->cacheTextureWidth(), | - | ||||||||||||||||||
| 92 | 1.0 / material->cacheTextureHeight())); | - | ||||||||||||||||||
| 93 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
| 94 | funcs->glBindTexture( | - | ||||||||||||||||||
| 95 | 0x0DE1 | - | ||||||||||||||||||
| 96 | , material->texture()->textureId()); | - | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | if (updated
| 72-144 | ||||||||||||||||||
| 101 | funcs->glTexParameteri( | - | ||||||||||||||||||
| 102 | 0x0DE1 | - | ||||||||||||||||||
| 103 | , | - | ||||||||||||||||||
| 104 | 0x2800 | - | ||||||||||||||||||
| 105 | , | - | ||||||||||||||||||
| 106 | 0x2600 | - | ||||||||||||||||||
| 107 | ); | - | ||||||||||||||||||
| 108 | funcs->glTexParameteri( | - | ||||||||||||||||||
| 109 | 0x0DE1 | - | ||||||||||||||||||
| 110 | , | - | ||||||||||||||||||
| 111 | 0x2801 | - | ||||||||||||||||||
| 112 | , | - | ||||||||||||||||||
| 113 | 0x2600 | - | ||||||||||||||||||
| 114 | ); | - | ||||||||||||||||||
| 115 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 116 | } executed 216 times by 1 test: end of blockExecuted by:
| 216 | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | float devicePixelRatio = (float) qsg_device_pixel_ratio(QOpenGLContext::currentContext()); | - | ||||||||||||||||||
| 119 | if (m_devicePixelRatio != devicePixelRatio
| 0-216 | ||||||||||||||||||
| 120 | m_devicePixelRatio = devicePixelRatio; | - | ||||||||||||||||||
| 121 | program()->setUniformValue("dpr", m_devicePixelRatio); | - | ||||||||||||||||||
| 122 | } never executed: end of block | 0 | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | if (state.isMatrixDirty()
| 0-216 | ||||||||||||||||||
| 125 | program()->setUniformValue(m_matrix_id, state.combinedMatrix()); executed 216 times by 1 test: program()->setUniformValue(m_matrix_id, state.combinedMatrix());Executed by:
| 216 | ||||||||||||||||||
| 126 | } executed 216 times by 1 test: end of blockExecuted by:
| 216 | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | class QSG8BitTextMaskShader : public QSGTextMaskShader | - | ||||||||||||||||||
| 129 | { | - | ||||||||||||||||||
| 130 | public: | - | ||||||||||||||||||
| 131 | QSG8BitTextMaskShader(QFontEngine::GlyphFormat glyphFormat) | - | ||||||||||||||||||
| 132 | : QSGTextMaskShader(glyphFormat) | - | ||||||||||||||||||
| 133 | { | - | ||||||||||||||||||
| 134 | setShaderSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/8bittextmask.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/8bittextmask.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 16 times by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 16 times by 1 test: }()));return qstring_literal_temp;Executed by:
| 16 | ||||||||||||||||||
| 135 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; | - | ||||||||||||||||||
| 138 | }; | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | void QSG8BitTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) | - | ||||||||||||||||||
| 141 | { | - | ||||||||||||||||||
| 142 | QSGTextMaskShader::updateState(state, newEffect, oldEffect); | - | ||||||||||||||||||
| 143 | QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect); | - | ||||||||||||||||||
| 144 | QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect); | - | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | if (oldMaterial == nullptr
| 0-216 | ||||||||||||||||||
| 147 | QVector4D color = qsg_premultiply(material->color(), state.opacity()); | - | ||||||||||||||||||
| 148 | program()->setUniformValue(m_color_id, color); | - | ||||||||||||||||||
| 149 | } executed 216 times by 1 test: end of blockExecuted by:
| 216 | ||||||||||||||||||
| 150 | } executed 216 times by 1 test: end of blockExecuted by:
| 216 | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | class QSG24BitTextMaskShader : public QSGTextMaskShader | - | ||||||||||||||||||
| 153 | { | - | ||||||||||||||||||
| 154 | public: | - | ||||||||||||||||||
| 155 | QSG24BitTextMaskShader(QFontEngine::GlyphFormat glyphFormat) | - | ||||||||||||||||||
| 156 | : QSGTextMaskShader(glyphFormat) | - | ||||||||||||||||||
| 157 | , m_useSRGB(false) | - | ||||||||||||||||||
| 158 | { | - | ||||||||||||||||||
| 159 | setShaderSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/24bittextmask.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/24bittextmask.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; | - | ||||||||||||||||||
| 163 | void initialize() override; | - | ||||||||||||||||||
| 164 | void activate() override; | - | ||||||||||||||||||
| 165 | void deactivate() override; | - | ||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | bool useSRGB() const; | - | ||||||||||||||||||
| 168 | uint m_useSRGB : 1; | - | ||||||||||||||||||
| 169 | }; | - | ||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | void QSG24BitTextMaskShader::initialize() | - | ||||||||||||||||||
| 172 | { | - | ||||||||||||||||||
| 173 | QSGTextMaskShader::initialize(); | - | ||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | if (QOpenGLContext::currentContext()->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_framebuffer_sRGB") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_framebuffer_sRGB" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
| 0 | ||||||||||||||||||
| 177 | && m_glyphFormat == QFontEngine::Format_A32
| 0 | ||||||||||||||||||
| 178 | && qAbs(fontSmoothingGamma() - 2.2) < 0.25
| 0 | ||||||||||||||||||
| 179 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
| 180 | GLint srgbCapable = 0; | - | ||||||||||||||||||
| 181 | funcs->glGetIntegerv(0x8DBA, &srgbCapable); | - | ||||||||||||||||||
| 182 | if (srgbCapable
| 0 | ||||||||||||||||||
| 183 | m_useSRGB = true; never executed: m_useSRGB = true; | 0 | ||||||||||||||||||
| 184 | } never executed: end of block | 0 | ||||||||||||||||||
| 185 | } never executed: end of block | 0 | ||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | bool QSG24BitTextMaskShader::useSRGB() const | - | ||||||||||||||||||
| 188 | { | - | ||||||||||||||||||
| 189 | return never executed: m_useSRGB;return m_useSRGB;never executed: return m_useSRGB; | 0 | ||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | } | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | void QSG24BitTextMaskShader::activate() | - | ||||||||||||||||||
| 194 | { | - | ||||||||||||||||||
| 195 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
| 196 | funcs->glBlendFunc(0x8001, | - | ||||||||||||||||||
| 197 | 0x0301 | - | ||||||||||||||||||
| 198 | ); | - | ||||||||||||||||||
| 199 | if (useSRGB()
| 0 | ||||||||||||||||||
| 200 | funcs->glEnable(0x8DB9); never executed: funcs->glEnable(0x8DB9); | 0 | ||||||||||||||||||
| 201 | } never executed: end of block | 0 | ||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 | void QSG24BitTextMaskShader::deactivate() | - | ||||||||||||||||||
| 204 | { | - | ||||||||||||||||||
| 205 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
| 206 | funcs->glBlendFunc( | - | ||||||||||||||||||
| 207 | 1 | - | ||||||||||||||||||
| 208 | , | - | ||||||||||||||||||
| 209 | 0x0303 | - | ||||||||||||||||||
| 210 | ); | - | ||||||||||||||||||
| 211 | if (useSRGB()
| 0 | ||||||||||||||||||
| 212 | funcs->glDisable(0x8DB9); never executed: funcs->glDisable(0x8DB9); | 0 | ||||||||||||||||||
| 213 | } never executed: end of block | 0 | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | static inline qreal qt_sRGB_to_linear_RGB(qreal f) | - | ||||||||||||||||||
| 216 | { | - | ||||||||||||||||||
| 217 | return never executed: f > 0.04045 ? qPow((f + 0.055) / 1.055, 2.4) : f / 12.92;return f > 0.04045 ? qPow((f + 0.055) / 1.055, 2.4) : f / 12.92;never executed: return f > 0.04045 ? qPow((f + 0.055) / 1.055, 2.4) : f / 12.92; | 0 | ||||||||||||||||||
| 218 | } | - | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | static inline QVector4D qt_sRGB_to_linear_RGB(const QVector4D &color) | - | ||||||||||||||||||
| 221 | { | - | ||||||||||||||||||
| 222 | return never executed: QVector4D(qt_sRGB_to_linear_RGB(color.x()),return QVector4D(qt_sRGB_to_linear_RGB(color.x()), qt_sRGB_to_linear_RGB(color.y()), qt_sRGB_to_linear_RGB(color.z()), color.w());never executed: return QVector4D(qt_sRGB_to_linear_RGB(color.x()), qt_sRGB_to_linear_RGB(color.y()), qt_sRGB_to_linear_RGB(color.z()), color.w()); | 0 | ||||||||||||||||||
| 223 | qt_sRGB_to_linear_RGB(color.y()), never executed: return QVector4D(qt_sRGB_to_linear_RGB(color.x()), qt_sRGB_to_linear_RGB(color.y()), qt_sRGB_to_linear_RGB(color.z()), color.w()); | 0 | ||||||||||||||||||
| 224 | qt_sRGB_to_linear_RGB(color.z()), never executed: return QVector4D(qt_sRGB_to_linear_RGB(color.x()), qt_sRGB_to_linear_RGB(color.y()), qt_sRGB_to_linear_RGB(color.z()), color.w()); | 0 | ||||||||||||||||||
| 225 | color.w()); never executed: return QVector4D(qt_sRGB_to_linear_RGB(color.x()), qt_sRGB_to_linear_RGB(color.y()), qt_sRGB_to_linear_RGB(color.z()), color.w()); | 0 | ||||||||||||||||||
| 226 | } | - | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | void QSG24BitTextMaskShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) | - | ||||||||||||||||||
| 229 | { | - | ||||||||||||||||||
| 230 | QSGTextMaskShader::updateState(state, newEffect, oldEffect); | - | ||||||||||||||||||
| 231 | QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect); | - | ||||||||||||||||||
| 232 | QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect); | - | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | if (oldMaterial == nullptr
| 0 | ||||||||||||||||||
| 235 | QVector4D color = material->color(); | - | ||||||||||||||||||
| 236 | if (useSRGB()
| 0 | ||||||||||||||||||
| 237 | color = qt_sRGB_to_linear_RGB(color); never executed: color = qt_sRGB_to_linear_RGB(color); | 0 | ||||||||||||||||||
| 238 | QOpenGLContext::currentContext()->functions()->glBlendColor(color.x(), color.y(), color.z(), color.w()); | - | ||||||||||||||||||
| 239 | color = qsg_premultiply(color, state.opacity()); | - | ||||||||||||||||||
| 240 | program()->setUniformValue(m_color_id, color.w()); | - | ||||||||||||||||||
| 241 | } never executed: end of block | 0 | ||||||||||||||||||
| 242 | } never executed: end of block | 0 | ||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | class QSG32BitColorTextShader : public QSGTextMaskShader | - | ||||||||||||||||||
| 245 | { | - | ||||||||||||||||||
| 246 | public: | - | ||||||||||||||||||
| 247 | QSG32BitColorTextShader(QFontEngine::GlyphFormat glyphFormat) | - | ||||||||||||||||||
| 248 | : QSGTextMaskShader(glyphFormat) | - | ||||||||||||||||||
| 249 | { | - | ||||||||||||||||||
| 250 | setShaderSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/32bitcolortext.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/32bitcolortext.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 251 | } never executed: end of block | 0 | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; | - | ||||||||||||||||||
| 254 | }; | - | ||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | void QSG32BitColorTextShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) | - | ||||||||||||||||||
| 257 | { | - | ||||||||||||||||||
| 258 | QSGTextMaskShader::updateState(state, newEffect, oldEffect); | - | ||||||||||||||||||
| 259 | QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect); | - | ||||||||||||||||||
| 260 | QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect); | - | ||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | if (oldMaterial == nullptr
| 0 | ||||||||||||||||||
| 263 | float opacity = material->color().w() * state.opacity(); | - | ||||||||||||||||||
| 264 | program()->setUniformValue(m_color_id, opacity); | - | ||||||||||||||||||
| 265 | } never executed: end of block | 0 | ||||||||||||||||||
| 266 | } never executed: end of block | 0 | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | class QSGStyledTextShader : public QSG8BitTextMaskShader | - | ||||||||||||||||||
| 269 | { | - | ||||||||||||||||||
| 270 | public: | - | ||||||||||||||||||
| 271 | QSGStyledTextShader(QFontEngine::GlyphFormat glyphFormat) | - | ||||||||||||||||||
| 272 | : QSG8BitTextMaskShader(glyphFormat) | - | ||||||||||||||||||
| 273 | { | - | ||||||||||||||||||
| 274 | setShaderSourceFile(QOpenGLShader::Vertex, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/styledtext.vert")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/styledtext.vert" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 275 | setShaderSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/styledtext.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/styledtext.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 276 | } never executed: end of block | 0 | ||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; | - | ||||||||||||||||||
| 279 | - | |||||||||||||||||||
| 280 | private: | - | ||||||||||||||||||
| 281 | void initialize() override; | - | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | int m_shift_id; | - | ||||||||||||||||||
| 284 | int m_styleColor_id; | - | ||||||||||||||||||
| 285 | }; | - | ||||||||||||||||||
| 286 | - | |||||||||||||||||||
| 287 | void QSGStyledTextShader::initialize() | - | ||||||||||||||||||
| 288 | { | - | ||||||||||||||||||
| 289 | QSG8BitTextMaskShader::initialize(); | - | ||||||||||||||||||
| 290 | m_shift_id = program()->uniformLocation("shift"); | - | ||||||||||||||||||
| 291 | m_styleColor_id = program()->uniformLocation("styleColor"); | - | ||||||||||||||||||
| 292 | } never executed: end of block | 0 | ||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | void QSGStyledTextShader::updateState(const RenderState &state, | - | ||||||||||||||||||
| 295 | QSGMaterial *newEffect, | - | ||||||||||||||||||
| 296 | QSGMaterial *oldEffect) | - | ||||||||||||||||||
| 297 | { | - | ||||||||||||||||||
| 298 | ((oldEffect == nullptr || newEffect->type() == oldEffect->type()) ? static_cast<void>(0) : qt_assert("oldEffect == nullptr || newEffect->type() == oldEffect->type()", __FILE__, 349)); | - | ||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | QSGStyledTextMaterial *material = static_cast<QSGStyledTextMaterial *>(newEffect); | - | ||||||||||||||||||
| 301 | QSGStyledTextMaterial *oldMaterial = static_cast<QSGStyledTextMaterial *>(oldEffect); | - | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | if (oldMaterial == nullptr
| 0 | ||||||||||||||||||
| 304 | program()->setUniformValue(m_shift_id, material->styleShift()); never executed: program()->setUniformValue(m_shift_id, material->styleShift()); | 0 | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | if (oldMaterial == nullptr
| 0 | ||||||||||||||||||
| 307 | QVector4D color = qsg_premultiply(material->color(), state.opacity()); | - | ||||||||||||||||||
| 308 | program()->setUniformValue(m_color_id, color); | - | ||||||||||||||||||
| 309 | } never executed: end of block | 0 | ||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | if (oldMaterial == nullptr
| 0 | ||||||||||||||||||
| 312 | QVector4D styleColor = qsg_premultiply(material->styleColor(), state.opacity()); | - | ||||||||||||||||||
| 313 | program()->setUniformValue(m_styleColor_id, styleColor); | - | ||||||||||||||||||
| 314 | } never executed: end of block | 0 | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | bool updated = material->ensureUpToDate(); | - | ||||||||||||||||||
| 317 | ((material->texture()) ? static_cast<void>(0) : qt_assert("material->texture()", __FILE__, 368)); | - | ||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | ((oldMaterial == nullptr || oldMaterial->texture()) ? static_cast<void>(0) : qt_assert("oldMaterial == nullptr || oldMaterial->texture()", __FILE__, 370)); | - | ||||||||||||||||||
| 320 | if (updated
| 0 | ||||||||||||||||||
| 321 | || oldMaterial == nullptr
| 0 | ||||||||||||||||||
| 322 | || oldMaterial->texture()->textureId() != material->texture()->textureId()
| 0 | ||||||||||||||||||
| 323 | program()->setUniformValue(m_textureScale_id, QVector2D(1.0 / material->cacheTextureWidth(), | - | ||||||||||||||||||
| 324 | 1.0 / material->cacheTextureHeight())); | - | ||||||||||||||||||
| 325 | QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); | - | ||||||||||||||||||
| 326 | funcs->glBindTexture( | - | ||||||||||||||||||
| 327 | 0x0DE1 | - | ||||||||||||||||||
| 328 | , material->texture()->textureId()); | - | ||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | if (updated
| 0 | ||||||||||||||||||
| 333 | funcs->glTexParameteri( | - | ||||||||||||||||||
| 334 | 0x0DE1 | - | ||||||||||||||||||
| 335 | , | - | ||||||||||||||||||
| 336 | 0x2800 | - | ||||||||||||||||||
| 337 | , | - | ||||||||||||||||||
| 338 | 0x2600 | - | ||||||||||||||||||
| 339 | ); | - | ||||||||||||||||||
| 340 | funcs->glTexParameteri( | - | ||||||||||||||||||
| 341 | 0x0DE1 | - | ||||||||||||||||||
| 342 | , | - | ||||||||||||||||||
| 343 | 0x2801 | - | ||||||||||||||||||
| 344 | , | - | ||||||||||||||||||
| 345 | 0x2600 | - | ||||||||||||||||||
| 346 | ); | - | ||||||||||||||||||
| 347 | } never executed: end of block | 0 | ||||||||||||||||||
| 348 | } never executed: end of block | 0 | ||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | if (state.isMatrixDirty()
| 0 | ||||||||||||||||||
| 351 | program()->setUniformValue(m_matrix_id, state.combinedMatrix()); never executed: program()->setUniformValue(m_matrix_id, state.combinedMatrix()); | 0 | ||||||||||||||||||
| 352 | } never executed: end of block | 0 | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | class QSGOutlinedTextShader : public QSGStyledTextShader | - | ||||||||||||||||||
| 355 | { | - | ||||||||||||||||||
| 356 | public: | - | ||||||||||||||||||
| 357 | QSGOutlinedTextShader(QFontEngine::GlyphFormat glyphFormat) | - | ||||||||||||||||||
| 358 | : QSGStyledTextShader(glyphFormat) | - | ||||||||||||||||||
| 359 | { | - | ||||||||||||||||||
| 360 | setShaderSourceFile(QOpenGLShader::Vertex, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/outlinedtext.vert")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/outlinedtext.vert" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 361 | setShaderSourceFile(QOpenGLShader::Fragment, ([]() noexcept -> QString { enum { Size = sizeof(u"" ":/qt-project.org/scenegraph/shaders/outlinedtext.frag")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" ":/qt-project.org/scenegraph/shaders/outlinedtext.frag" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||
| 362 | } never executed: end of block | 0 | ||||||||||||||||||
| 363 | }; | - | ||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | QSGTextMaskMaterial::QSGTextMaskMaterial(const QRawFont &font, QFontEngine::GlyphFormat glyphFormat) | - | ||||||||||||||||||
| 366 | : m_texture(nullptr) | - | ||||||||||||||||||
| 367 | , m_glyphCache(nullptr) | - | ||||||||||||||||||
| 368 | , m_font(font) | - | ||||||||||||||||||
| 369 | { | - | ||||||||||||||||||
| 370 | init(glyphFormat); | - | ||||||||||||||||||
| 371 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | QSGTextMaskMaterial::~QSGTextMaskMaterial() | - | ||||||||||||||||||
| 374 | { | - | ||||||||||||||||||
| 375 | delete m_texture; | - | ||||||||||||||||||
| 376 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat) | - | ||||||||||||||||||
| 379 | { | - | ||||||||||||||||||
| 380 | ((m_font.isValid()) ? static_cast<void>(0) : qt_assert("m_font.isValid()", __FILE__, 417)); | - | ||||||||||||||||||
| 381 | - | |||||||||||||||||||
| 382 | setFlag(Blending, true); | - | ||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext()); | - | ||||||||||||||||||
| 385 | ((ctx != nullptr) ? static_cast<void>(0) : qt_assert("ctx != nullptr", __FILE__, 422)); | - | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | - | |||||||||||||||||||
| 389 | - | |||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | - | |||||||||||||||||||
| 393 | QRawFontPrivate *fontD = QRawFontPrivate::get(m_font); | - | ||||||||||||||||||
| 394 | if (QFontEngine *fontEngine = fontD->fontEngine
| 0-72 | ||||||||||||||||||
| 395 | if (glyphFormat == QFontEngine::Format_None
| 0-72 | ||||||||||||||||||
| 396 | glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None
| 0-72 | ||||||||||||||||||
| 397 | ? fontEngine->glyphFormat | - | ||||||||||||||||||
| 398 | : QFontEngine::Format_A32; | - | ||||||||||||||||||
| 399 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 400 | - | |||||||||||||||||||
| 401 | qreal devicePixelRatio = qsg_device_pixel_ratio(ctx); | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | - | |||||||||||||||||||
| 404 | QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio); | - | ||||||||||||||||||
| 405 | if (!fontEngine->supportsTransformation(glyphCacheTransform)
| 0-72 | ||||||||||||||||||
| 406 | glyphCacheTransform = QTransform(); never executed: glyphCacheTransform = QTransform(); | 0 | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | m_glyphCache = fontEngine->glyphCache(ctx, glyphFormat, glyphCacheTransform); | - | ||||||||||||||||||
| 409 | if (!m_glyphCache
| 0-56 | ||||||||||||||||||
| 410 | m_glyphCache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform); | - | ||||||||||||||||||
| 411 | fontEngine->setGlyphCache(ctx, m_glyphCache.data()); | - | ||||||||||||||||||
| 412 | auto sg = QSGDefaultRenderContext::from(ctx); | - | ||||||||||||||||||
| 413 | ((sg) ? static_cast<void>(0) : qt_assert("sg", __FILE__, 450)); | - | ||||||||||||||||||
| 414 | sg->registerFontengineForCleanup(fontEngine); | - | ||||||||||||||||||
| 415 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||||||||
| 416 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 417 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | void QSGTextMaskMaterial::populate(const QPointF &p, | - | ||||||||||||||||||
| 420 | const QVector<quint32> &glyphIndexes, | - | ||||||||||||||||||
| 421 | const QVector<QPointF> &glyphPositions, | - | ||||||||||||||||||
| 422 | QSGGeometry *geometry, | - | ||||||||||||||||||
| 423 | QRectF *boundingRect, | - | ||||||||||||||||||
| 424 | QPointF *baseLine, | - | ||||||||||||||||||
| 425 | const QMargins &margins) | - | ||||||||||||||||||
| 426 | { | - | ||||||||||||||||||
| 427 | ((m_font.isValid()) ? static_cast<void>(0) : qt_assert("m_font.isValid()", __FILE__, 464)); | - | ||||||||||||||||||
| 428 | QVector<QFixedPoint> fixedPointPositions; | - | ||||||||||||||||||
| 429 | const int glyphPositionsSize = glyphPositions.size(); | - | ||||||||||||||||||
| 430 | fixedPointPositions.reserve(glyphPositionsSize); | - | ||||||||||||||||||
| 431 | for (int i=0; i < glyphPositionsSize
| 72-4968 | ||||||||||||||||||
| 432 | fixedPointPositions.append(QFixedPoint::fromPointF(glyphPositions.at(i))); executed 4968 times by 1 test: fixedPointPositions.append(QFixedPoint::fromPointF(glyphPositions.at(i)));Executed by:
| 4968 | ||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | QTextureGlyphCache *cache = glyphCache(); | - | ||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | QRawFontPrivate *fontD = QRawFontPrivate::get(m_font); | - | ||||||||||||||||||
| 437 | cache->populate(fontD->fontEngine, glyphIndexes.size(), glyphIndexes.constData(), | - | ||||||||||||||||||
| 438 | fixedPointPositions.data()); | - | ||||||||||||||||||
| 439 | cache->fillInPendingGlyphs(); | - | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | int margin = fontD->fontEngine->glyphMargin(cache->glyphFormat()); | - | ||||||||||||||||||
| 442 | - | |||||||||||||||||||
| 443 | qreal glyphCacheScaleX = cache->transform().m11(); | - | ||||||||||||||||||
| 444 | qreal glyphCacheScaleY = cache->transform().m22(); | - | ||||||||||||||||||
| 445 | qreal glyphCacheInverseScaleX = 1.0 / glyphCacheScaleX; | - | ||||||||||||||||||
| 446 | qreal glyphCacheInverseScaleY = 1.0 / glyphCacheScaleY; | - | ||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | ((geometry->indexType() == | - | ||||||||||||||||||
| 449 | 0x1403 | - | ||||||||||||||||||
| 450 | ) ? static_cast<void>(0) : qt_assert("geometry->indexType() == GL_UNSIGNED_SHORT", __FILE__, 485)); | - | ||||||||||||||||||
| 451 | geometry->allocate(glyphIndexes.size() * 4, glyphIndexes.size() * 6); | - | ||||||||||||||||||
| 452 | QVector4D *vp = (QVector4D *)geometry->vertexDataAsTexturedPoint2D(); | - | ||||||||||||||||||
| 453 | ((geometry->sizeOfVertex() == sizeof(QVector4D)) ? static_cast<void>(0) : qt_assert("geometry->sizeOfVertex() == sizeof(QVector4D)", __FILE__, 488)); | - | ||||||||||||||||||
| 454 | ushort *ip = geometry->indexDataAsUShort(); | - | ||||||||||||||||||
| 455 | - | |||||||||||||||||||
| 456 | QPointF position(p.x(), p.y() - m_font.ascent()); | - | ||||||||||||||||||
| 457 | bool supportsSubPixelPositions = fontD->fontEngine->supportsSubPixelPositions(); | - | ||||||||||||||||||
| 458 | for (int i=0; i<glyphIndexes.size()
| 72-4968 | ||||||||||||||||||
| 459 | QFixed subPixelPosition; | - | ||||||||||||||||||
| 460 | if (supportsSubPixelPositions
| 0-4968 | ||||||||||||||||||
| 461 | subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(glyphPositions.at(i).x())); never executed: subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(glyphPositions.at(i).x())); | 0 | ||||||||||||||||||
| 462 | - | |||||||||||||||||||
| 463 | QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphIndexes.at(i), subPixelPosition); | - | ||||||||||||||||||
| 464 | const QTextureGlyphCache::Coord &c = cache->coords.value(glyph); | - | ||||||||||||||||||
| 465 | - | |||||||||||||||||||
| 466 | QPointF glyphPosition = glyphPositions.at(i) + position; | - | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | - | |||||||||||||||||||
| 469 | - | |||||||||||||||||||
| 470 | - | |||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 | - | |||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | qreal x = (qFloor(glyphPosition.x() * glyphCacheScaleX) * glyphCacheInverseScaleX) + | - | ||||||||||||||||||
| 475 | (c.baseLineX * glyphCacheInverseScaleX) - margin; | - | ||||||||||||||||||
| 476 | qreal y = (qRound(glyphPosition.y() * glyphCacheScaleY) * glyphCacheInverseScaleY) - | - | ||||||||||||||||||
| 477 | (c.baseLineY * glyphCacheInverseScaleY) - margin; | - | ||||||||||||||||||
| 478 | - | |||||||||||||||||||
| 479 | qreal w = c.w * glyphCacheInverseScaleX; | - | ||||||||||||||||||
| 480 | qreal h = c.h * glyphCacheInverseScaleY; | - | ||||||||||||||||||
| 481 | - | |||||||||||||||||||
| 482 | *boundingRect |= QRectF(x + margin, y + margin, w, h); | - | ||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | float cx1 = x - margins.left(); | - | ||||||||||||||||||
| 485 | float cx2 = x + w + margins.right(); | - | ||||||||||||||||||
| 486 | float cy1 = y - margins.top(); | - | ||||||||||||||||||
| 487 | float cy2 = y + h + margins.bottom(); | - | ||||||||||||||||||
| 488 | - | |||||||||||||||||||
| 489 | float tx1 = c.x - margins.left(); | - | ||||||||||||||||||
| 490 | float tx2 = c.x + c.w + margins.right(); | - | ||||||||||||||||||
| 491 | float ty1 = c.y - margins.top(); | - | ||||||||||||||||||
| 492 | float ty2 = c.y + c.h + margins.bottom(); | - | ||||||||||||||||||
| 493 | - | |||||||||||||||||||
| 494 | if (baseLine->isNull()
| 72-4896 | ||||||||||||||||||
| 495 | * executed 72 times by 1 test: baseLine = glyphPosition;*baseLine = glyphPosition;Executed by:
executed 72 times by 1 test: *baseLine = glyphPosition;Executed by:
| 72 | ||||||||||||||||||
| 496 | - | |||||||||||||||||||
| 497 | vp[4 * i + 0] = QVector4D(cx1, cy1, tx1, ty1); | - | ||||||||||||||||||
| 498 | vp[4 * i + 1] = QVector4D(cx2, cy1, tx2, ty1); | - | ||||||||||||||||||
| 499 | vp[4 * i + 2] = QVector4D(cx1, cy2, tx1, ty2); | - | ||||||||||||||||||
| 500 | vp[4 * i + 3] = QVector4D(cx2, cy2, tx2, ty2); | - | ||||||||||||||||||
| 501 | - | |||||||||||||||||||
| 502 | int o = i * 4; | - | ||||||||||||||||||
| 503 | ip[6 * i + 0] = o + 0; | - | ||||||||||||||||||
| 504 | ip[6 * i + 1] = o + 2; | - | ||||||||||||||||||
| 505 | ip[6 * i + 2] = o + 3; | - | ||||||||||||||||||
| 506 | ip[6 * i + 3] = o + 3; | - | ||||||||||||||||||
| 507 | ip[6 * i + 4] = o + 1; | - | ||||||||||||||||||
| 508 | ip[6 * i + 5] = o + 0; | - | ||||||||||||||||||
| 509 | } executed 4968 times by 1 test: end of blockExecuted by:
| 4968 | ||||||||||||||||||
| 510 | } executed 72 times by 1 test: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | QSGMaterialType *QSGTextMaskMaterial::type() const | - | ||||||||||||||||||
| 513 | { | - | ||||||||||||||||||
| 514 | static QSGMaterialType argb, rgb, gray; | - | ||||||||||||||||||
| 515 | switch (glyphCache()->glyphFormat()) { | - | ||||||||||||||||||
| 516 | case never executed: QFontEngine::Format_ARGB:case QFontEngine::Format_ARGB:never executed: case QFontEngine::Format_ARGB: | 0 | ||||||||||||||||||
| 517 | return never executed: &argb;return &argb;never executed: return &argb; | 0 | ||||||||||||||||||
| 518 | case never executed: QFontEngine::Format_A32:case QFontEngine::Format_A32:never executed: case QFontEngine::Format_A32: | 0 | ||||||||||||||||||
| 519 | return never executed: &rgb;return &rgb;never executed: return &rgb; | 0 | ||||||||||||||||||
| 520 | case executed 216 times by 1 test: QFontEngine::Format_A8:case QFontEngine::Format_A8:Executed by:
executed 216 times by 1 test: case QFontEngine::Format_A8:Executed by:
| 216 | ||||||||||||||||||
| 521 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 522 | return executed 216 times by 1 test: &gray;return &gray;Executed by:
executed 216 times by 1 test: return &gray;Executed by:
| 216 | ||||||||||||||||||
| 523 | } | - | ||||||||||||||||||
| 524 | } | - | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | QOpenGLTextureGlyphCache *QSGTextMaskMaterial::glyphCache() const | - | ||||||||||||||||||
| 527 | { | - | ||||||||||||||||||
| 528 | return executed 1384 times by 1 test: static_cast<QOpenGLTextureGlyphCache*>(m_glyphCache.data());return static_cast<QOpenGLTextureGlyphCache*>(m_glyphCache.data());Executed by:
executed 1384 times by 1 test: return static_cast<QOpenGLTextureGlyphCache*>(m_glyphCache.data());Executed by:
| 1384 | ||||||||||||||||||
| 529 | } | - | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | QSGMaterialShader *QSGTextMaskMaterial::createShader() const | - | ||||||||||||||||||
| 532 | { | - | ||||||||||||||||||
| 533 | switch (QFontEngine::GlyphFormat glyphFormat = glyphCache()->glyphFormat()) { | - | ||||||||||||||||||
| 534 | case never executed: QFontEngine::Format_ARGB:case QFontEngine::Format_ARGB:never executed: case QFontEngine::Format_ARGB: | 0 | ||||||||||||||||||
| 535 | return never executed: new QSG32BitColorTextShader(glyphFormat);return new QSG32BitColorTextShader(glyphFormat);never executed: return new QSG32BitColorTextShader(glyphFormat); | 0 | ||||||||||||||||||
| 536 | case never executed: QFontEngine::Format_A32:case QFontEngine::Format_A32:never executed: case QFontEngine::Format_A32: | 0 | ||||||||||||||||||
| 537 | return never executed: new QSG24BitTextMaskShader(glyphFormat);return new QSG24BitTextMaskShader(glyphFormat);never executed: return new QSG24BitTextMaskShader(glyphFormat); | 0 | ||||||||||||||||||
| 538 | case executed 16 times by 1 test: QFontEngine::Format_A8:case QFontEngine::Format_A8:Executed by:
executed 16 times by 1 test: case QFontEngine::Format_A8:Executed by:
| 16 | ||||||||||||||||||
| 539 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 540 | return executed 16 times by 1 test: new QSG8BitTextMaskShader(glyphFormat);return new QSG8BitTextMaskShader(glyphFormat);Executed by:
executed 16 times by 1 test: return new QSG8BitTextMaskShader(glyphFormat);Executed by:
| 16 | ||||||||||||||||||
| 541 | } | - | ||||||||||||||||||
| 542 | } | - | ||||||||||||||||||
| 543 | - | |||||||||||||||||||
| 544 | static inline int qsg_colorDiff(const QVector4D &a, const QVector4D &b) | - | ||||||||||||||||||
| 545 | { | - | ||||||||||||||||||
| 546 | if (a.x() != b.x()
| 0 | ||||||||||||||||||
| 547 | return never executed: a.x() > b.x() ? 1 : -1;return a.x() > b.x() ? 1 : -1;never executed: return a.x() > b.x() ? 1 : -1; | 0 | ||||||||||||||||||
| 548 | if (a.y() != b.y()
| 0 | ||||||||||||||||||
| 549 | return never executed: a.y() > b.y() ? 1 : -1;return a.y() > b.y() ? 1 : -1;never executed: return a.y() > b.y() ? 1 : -1; | 0 | ||||||||||||||||||
| 550 | if (a.z() != b.z()
| 0 | ||||||||||||||||||
| 551 | return never executed: a.z() > b.z() ? 1 : -1;return a.z() > b.z() ? 1 : -1;never executed: return a.z() > b.z() ? 1 : -1; | 0 | ||||||||||||||||||
| 552 | if (a.w() != b.w()
| 0 | ||||||||||||||||||
| 553 | return never executed: a.w() > b.w() ? 1 : -1;return a.w() > b.w() ? 1 : -1;never executed: return a.w() > b.w() ? 1 : -1; | 0 | ||||||||||||||||||
| 554 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 555 | } | - | ||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | int QSGTextMaskMaterial::compare(const QSGMaterial *o) const | - | ||||||||||||||||||
| 558 | { | - | ||||||||||||||||||
| 559 | ((o && type() == o->type()) ? static_cast<void>(0) : qt_assert("o && type() == o->type()", __FILE__, 594)); | - | ||||||||||||||||||
| 560 | const QSGTextMaskMaterial *other = static_cast<const QSGTextMaskMaterial *>(o); | - | ||||||||||||||||||
| 561 | if (m_glyphCache != other->m_glyphCache
| 0 | ||||||||||||||||||
| 562 | return never executed: m_glyphCache.data() < other->m_glyphCache.data() ? -1 : 1;return m_glyphCache.data() < other->m_glyphCache.data() ? -1 : 1;never executed: return m_glyphCache.data() < other->m_glyphCache.data() ? -1 : 1; | 0 | ||||||||||||||||||
| 563 | return never executed: qsg_colorDiff(m_color, other->m_color);return qsg_colorDiff(m_color, other->m_color);never executed: return qsg_colorDiff(m_color, other->m_color); | 0 | ||||||||||||||||||
| 564 | } | - | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | bool QSGTextMaskMaterial::ensureUpToDate() | - | ||||||||||||||||||
| 567 | { | - | ||||||||||||||||||
| 568 | QSize glyphCacheSize(glyphCache()->width(), glyphCache()->height()); | - | ||||||||||||||||||
| 569 | if (glyphCacheSize != m_size
| 72-144 | ||||||||||||||||||
| 570 | if (m_texture
| 0-72 | ||||||||||||||||||
| 571 | delete m_texture; never executed: delete m_texture; | 0 | ||||||||||||||||||
| 572 | m_texture = new QSGPlainTexture(); | - | ||||||||||||||||||
| 573 | m_texture->setTextureId(glyphCache()->texture()); | - | ||||||||||||||||||
| 574 | m_texture->setTextureSize(QSize(glyphCache()->width(), glyphCache()->height())); | - | ||||||||||||||||||
| 575 | m_texture->setOwnsTexture(false); | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | m_size = glyphCacheSize; | - | ||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | return executed 72 times by 1 test: true;return true;Executed by:
executed 72 times by 1 test: return true;Executed by:
| 72 | ||||||||||||||||||
| 580 | } else { | - | ||||||||||||||||||
| 581 | return executed 144 times by 1 test: false;return false;Executed by:
executed 144 times by 1 test: return false;Executed by:
| 144 | ||||||||||||||||||
| 582 | } | - | ||||||||||||||||||
| 583 | } | - | ||||||||||||||||||
| 584 | - | |||||||||||||||||||
| 585 | int QSGTextMaskMaterial::cacheTextureWidth() const | - | ||||||||||||||||||
| 586 | { | - | ||||||||||||||||||
| 587 | return executed 216 times by 1 test: glyphCache()->width();return glyphCache()->width();Executed by:
executed 216 times by 1 test: return glyphCache()->width();Executed by:
| 216 | ||||||||||||||||||
| 588 | } | - | ||||||||||||||||||
| 589 | - | |||||||||||||||||||
| 590 | int QSGTextMaskMaterial::cacheTextureHeight() const | - | ||||||||||||||||||
| 591 | { | - | ||||||||||||||||||
| 592 | return executed 216 times by 1 test: glyphCache()->height();return glyphCache()->height();Executed by:
executed 216 times by 1 test: return glyphCache()->height();Executed by:
| 216 | ||||||||||||||||||
| 593 | } | - | ||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | - | |||||||||||||||||||
| 596 | QSGStyledTextMaterial::QSGStyledTextMaterial(const QRawFont &font) | - | ||||||||||||||||||
| 597 | : QSGTextMaskMaterial(font, QFontEngine::Format_A8) | - | ||||||||||||||||||
| 598 | { | - | ||||||||||||||||||
| 599 | } never executed: end of block | 0 | ||||||||||||||||||
| 600 | - | |||||||||||||||||||
| 601 | QSGMaterialType *QSGStyledTextMaterial::type() const | - | ||||||||||||||||||
| 602 | { | - | ||||||||||||||||||
| 603 | static QSGMaterialType type; | - | ||||||||||||||||||
| 604 | return never executed: &type;return &type;never executed: return &type; | 0 | ||||||||||||||||||
| 605 | } | - | ||||||||||||||||||
| 606 | - | |||||||||||||||||||
| 607 | QSGMaterialShader *QSGStyledTextMaterial::createShader() const | - | ||||||||||||||||||
| 608 | { | - | ||||||||||||||||||
| 609 | return never executed: new QSGStyledTextShader(glyphCache()->glyphFormat());return new QSGStyledTextShader(glyphCache()->glyphFormat());never executed: return new QSGStyledTextShader(glyphCache()->glyphFormat()); | 0 | ||||||||||||||||||
| 610 | } | - | ||||||||||||||||||
| 611 | - | |||||||||||||||||||
| 612 | int QSGStyledTextMaterial::compare(const QSGMaterial *o) const | - | ||||||||||||||||||
| 613 | { | - | ||||||||||||||||||
| 614 | const QSGStyledTextMaterial *other = static_cast<const QSGStyledTextMaterial *>(o); | - | ||||||||||||||||||
| 615 | - | |||||||||||||||||||
| 616 | if (m_styleShift != other->m_styleShift
| 0 | ||||||||||||||||||
| 617 | return never executed: m_styleShift.y() - other->m_styleShift.y();return m_styleShift.y() - other->m_styleShift.y();never executed: return m_styleShift.y() - other->m_styleShift.y(); | 0 | ||||||||||||||||||
| 618 | - | |||||||||||||||||||
| 619 | int diff = qsg_colorDiff(m_styleColor, other->m_styleColor); | - | ||||||||||||||||||
| 620 | if (diff == 0
| 0 | ||||||||||||||||||
| 621 | return never executed: QSGTextMaskMaterial::compare(o);return QSGTextMaskMaterial::compare(o);never executed: return QSGTextMaskMaterial::compare(o); | 0 | ||||||||||||||||||
| 622 | return never executed: diff;return diff;never executed: return diff; | 0 | ||||||||||||||||||
| 623 | } | - | ||||||||||||||||||
| 624 | - | |||||||||||||||||||
| 625 | - | |||||||||||||||||||
| 626 | QSGOutlinedTextMaterial::QSGOutlinedTextMaterial(const QRawFont &font) | - | ||||||||||||||||||
| 627 | : QSGStyledTextMaterial(font) | - | ||||||||||||||||||
| 628 | { | - | ||||||||||||||||||
| 629 | } never executed: end of block | 0 | ||||||||||||||||||
| 630 | - | |||||||||||||||||||
| 631 | QSGMaterialType *QSGOutlinedTextMaterial::type() const | - | ||||||||||||||||||
| 632 | { | - | ||||||||||||||||||
| 633 | static QSGMaterialType type; | - | ||||||||||||||||||
| 634 | return never executed: &type;return &type;never executed: return &type; | 0 | ||||||||||||||||||
| 635 | } | - | ||||||||||||||||||
| 636 | - | |||||||||||||||||||
| 637 | QSGMaterialShader *QSGOutlinedTextMaterial::createShader() const | - | ||||||||||||||||||
| 638 | { | - | ||||||||||||||||||
| 639 | return never executed: new QSGOutlinedTextShader(glyphCache()->glyphFormat());return new QSGOutlinedTextShader(glyphCache()->glyphFormat());never executed: return new QSGOutlinedTextShader(glyphCache()->glyphFormat()); | 0 | ||||||||||||||||||
| 640 | } | - | ||||||||||||||||||
| 641 | - | |||||||||||||||||||
| 642 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |