6#include <QtGui/qsurface.h>
7#include <QtGui/qwindow.h>
18 return ok ?
value : defaultValue;
24 static const float baseDev =
qt_sg_envFloat(
"QT_DF_BASEDEVIATION", 0.065f);
25 static const float devScaleMin =
qt_sg_envFloat(
"QT_DF_SCALEFORMAXDEV", 0.15f);
26 static const float devScaleMax =
qt_sg_envFloat(
"QT_DF_SCALEFORNODEV", 0.3f);
27 return base - ((
qBound(devScaleMin, glyphScale, devScaleMax) - devScaleMin) / (devScaleMax - devScaleMin) * -baseDev + baseDev);
33 return range / glyphScale;
55 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldtext.vert.qsb"));
59 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldtext_a.frag.qsb"));
62 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldtext.frag.qsb"));
68 Q_ASSERT(oldMaterial ==
nullptr || newMaterial->
type() == oldMaterial->
type());
82 bool updateRange =
false;
87 if (
state.isMatrixDirty()) {
89 memcpy(
buf->data(),
m.constData(), 64);
97 memcpy(
buf->data() + 64, &ts, 8);
100 if (!oldMat || mat->
color() != oldMat->
color() ||
state.isOpacityDirty()) {
103 memcpy(
buf->data() + 80, &
color, 16);
111 memcpy(
buf->data() + 96, &alphaMinMax, 8);
144 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldtext.vert.qsb"));
147 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldtext_a_fwidth.frag.qsb"));
150 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldtext_fwidth.frag.qsb"));
232 return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
259 styleColor *=
state.opacity();
260 memcpy(
buf->data() + 112, &styleColor, 16);
304 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb"));
308 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldoutlinetext_a.frag.qsb"));
311 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb"));
324 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldoutlinetext.vert.qsb"));
327 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldoutlinetext_a_fwidth.frag.qsb"));
330 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldoutlinetext_fwidth.frag.qsb"));
350 float styleAlphaMin0 =
qMax(0.0f, outlineLimit -
range);
351 float styleAlphaMin1 =
qMin(outlineLimit +
range, alphaMin);
352 memcpy(
buf->data() + 128, &styleAlphaMin0, 4);
353 memcpy(
buf->data() + 132, &styleAlphaMin1, 4);
395 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb"));
398 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldshiftedtext_a.frag.qsb"));
401 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb"));
419 memcpy(
buf->data() + 128, &
shift, 8);
436 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldshiftedtext.vert.qsb"));
439 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldshiftedtext_a_fwidth.frag.qsb"));
442 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/distancefieldshiftedtext_fwidth.frag.qsb"));
492 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.vert.qsb"));
495 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext_a.frag.qsb"));
498 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb"));
513 memcpy(
buf->data() + 104, &fontScale, 4);
517 if (!oldMat ||
state.isMatrixDirty()) {
518 int viewportWidth =
state.viewportRect().width();
521 memcpy(
buf->data() + 112, &vecDelta, 16);
535 ps->
srcColor = GraphicsPipelineState::ConstantColor;
536 ps->
dstColor = GraphicsPipelineState::OneMinusSrcColor;
569 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.vert.qsb"));
572 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/loqsubpixeldistancefieldtext_a.frag.qsb"));
575 QStringLiteral(
":/qt-project.org/scenegraph/shaders_ng/loqsubpixeldistancefieldtext.frag.qsb"));
DistanceFieldAnisotropicOutlineTextMaterialRhiShader(bool alphaTexture)
DistanceFieldAnisotropicShiftedTextMaterialRhiShader(bool alphaTexture)
DistanceFieldAnisotropicTextMaterialRhiShader(bool alphaTexture)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
DistanceFieldOutlineTextMaterialRhiShader(bool alphaTexture)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
DistanceFieldShiftedStyleTextMaterialRhiShader(bool alphaTexture)
DistanceFieldStyledTextMaterialRhiShader(bool alphaTexture)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
float toFloat(bool *ok=nullptr) const
Returns the byte array converted to a float value.
The QColor class provides colors based on RGB, HSV or CMYK values.
static QColor fromRgbF(float r, float g, float b, float a=1.0)
Static convenience function that returns a QColor constructed from the RGB color values,...
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
QVector4D column(int index) const
Returns the elements of column index as a 4D vector.
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
virtual bool screenSpaceDerivativesSupported() const =0
qreal distanceFieldRadius() const
const Texture * glyphTexture(glyph_t glyph)
virtual bool eightBitFormatIsAlphaSwizzled() const =0
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
~QSGDistanceFieldOutlineTextMaterial()
QSGDistanceFieldOutlineTextMaterial()
~QSGDistanceFieldShiftedStyleTextMaterial()
QSGDistanceFieldShiftedStyleTextMaterial()
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
const QPointF & shift() const
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
QSGMaterialType * type() const override=0
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
void setStyleColor(const QColor &color)
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
QSGDistanceFieldStyledTextMaterial()
const QVector4D & styleColor() const
~QSGDistanceFieldStyledTextMaterial()
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
QSGDistanceFieldTextMaterialRhiShader(bool alphaTexture)
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
~QSGDistanceFieldTextMaterial()
QSize textureSize() const
QSGDistanceFieldTextMaterial()
virtual void setColor(const QColor &color)
const QSGDistanceFieldGlyphCache::Texture * m_texture
const QSGDistanceFieldGlyphCache::Texture * texture() const
QSGTexture * wrapperTexture() const
const QVector4D & color() const
int compare(const QSGMaterial *other) const override
Compares this material to other and returns 0 if they are equal; -1 if this material should sort befo...
bool updateTextureSizeAndWrapper()
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QSGDistanceFieldGlyphCache * glyphCache() const
QSGDistanceFieldGlyphCache * m_glyph_cache
QSGPlainTexture * m_sgTexture
bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to enable the material to provide a custom set of graphics...
bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
QSGHiQSubPixelDistanceFieldTextMaterialRhiShader(bool alphaTexture)
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
QSGLoQSubPixelDistanceFieldTextMaterialRhiShader(bool alphaTexture)
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
QSGMaterialType * type() const override
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
Encapsulates the current rendering state during a call to QSGMaterialShader::updateUniformData() and ...
The QSGMaterialShader class represents a graphics API independent shader program.
void setShaderFileName(Stage stage, const QString &filename)
Sets the filename for the shader for the specified stage.
void setFlag(Flags flags, bool on=true)
Sets the flags on this material shader if on is true; otherwise clears the specified flags.
@ UpdatesGraphicsPipelineState
The QSGMaterial class encapsulates rendering state for a shader program.
virtual QSGMaterialType * type() const =0
This function is called by the scene graph to query an identifier that is unique to the QSGMaterialSh...
void setFlag(Flags flags, bool on=true)
Sets the flags flags on this material if on is true; otherwise clears the attribute.
void setTextureSize(const QSize &size)
void setTexture(QRhiTexture *texture)
void setOwnsTexture(bool owns)
RenderMode
\value RenderMode2D Normal 2D rendering \value RenderMode2DNoDepthBuffer Normal 2D rendering with dep...
void setFiltering(Filtering filter)
Sets the sampling mode to filter.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
The QVector2D class represents a vector or vertex in 2D space.
The QVector4D class represents a vector or vertex in 4D space.
Combined button and popup list for selecting options.
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
qfloat16 qSqrt(qfloat16 f)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
static float thresholdFunc(float glyphScale)
static QT_BEGIN_NAMESPACE float qt_sg_envFloat(const char *name, float defaultValue)
static float spreadFunc(float glyphScale)
#define QStringLiteral(str)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Describes state changes that the material wants to apply to the currently active graphics pipeline st...
The QSGMaterialType class is used as a unique type token in combination with QSGMaterial.