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;
65 Q_ASSERT(oldMaterial ==
nullptr || newMaterial->type() == oldMaterial->type());
73 Q_ASSERT(oldMat ==
nullptr || oldMat->texture());
79 bool updateRange =
false;
80 if (!oldMat || mat->fontScale() != oldMat->fontScale()) {
84 if (
state.isMatrixDirty()) {
89 const int matrixCount =
qMin(
state.projectionMatrixCount(), newMaterial->viewCount());
90 for (
int viewIndex = 0; viewIndex < matrixCount; ++viewIndex) {
91 if (
state.isMatrixDirty()) {
93 memcpy(
buf->data() + 64 * viewIndex,
m.constData(), 64);
98 if (textureUpdated || !oldMat || oldMat->texture()->texture != mat->texture()->texture) {
99 const QVector2D ts(1.0f / mat->textureSize().width(), 1.0f / mat->textureSize().height());
105 if (!oldMat || mat->color() != oldMat->color() ||
state.isOpacityDirty()) {
117 memcpy(
buf->data() +
offset, &alphaMinMax, 8);
237 return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
265 if (!oldMat || mat->styleColor() != oldMat->styleColor() ||
state.isOpacityDirty()) {
266 QVector4D styleColor = mat->styleColor();
267 styleColor *=
state.opacity();
346 if (!oldMat || mat->fontScale() != oldMat->fontScale() ||
state.isMatrixDirty()) {
347 float dfRadius = mat->glyphCache()->distanceFieldRadius();
353 float styleAlphaMin0 =
qMax(0.0f, outlineLimit -
range);
354 float styleAlphaMin1 =
qMin(outlineLimit +
range, alphaMin);
414 if (!oldMat || oldMat->fontScale() != mat->fontScale() || oldMat->shift() != mat->shift()
415 || oldMat->textureSize() != mat->textureSize())
418 1.0 / mat->fontScale() * mat->shift().y());
504 if (!oldMat || mat->fontScale() != oldMat->fontScale()) {
505 float fontScale = mat->fontScale();
511 if (!oldMat ||
state.isMatrixDirty()) {
512 int viewportWidth =
state.viewportRect().width();
529 ps->
srcColor = GraphicsPipelineState::ConstantColor;
530 ps->
dstColor = GraphicsPipelineState::OneMinusSrcColor;
DistanceFieldAnisotropicOutlineTextMaterialRhiShader(bool alphaTexture, int viewCount)
DistanceFieldAnisotropicShiftedTextMaterialRhiShader(bool alphaTexture, int viewCount)
DistanceFieldAnisotropicTextMaterialRhiShader(bool alphaTexture, int viewCount)
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, int viewCount)
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, int viewCount)
DistanceFieldStyledTextMaterialRhiShader(bool alphaTexture, int viewCount)
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...
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.
QMatrix4x4 inverted(bool *invertible=nullptr) const
Returns the inverse of this matrix.
virtual bool screenSpaceDerivativesSupported() const =0
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...
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()
~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,...
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...
quint32 m_currentUbufOffset
QSGDistanceFieldTextMaterialRhiShader(bool alphaTexture, int viewCount)
QSGMaterialShader * createShader(QSGRendererInterface::RenderMode renderMode) const override
This function returns a new instance of a the QSGMaterialShader implementation used to render geometr...
~QSGDistanceFieldTextMaterial()
QSGDistanceFieldTextMaterial()
virtual void setColor(const QColor &color)
const QSGDistanceFieldGlyphCache::Texture * m_texture
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 * m_glyph_cache
QSGPlainTexture * m_sgTexture
QSGHiQSubPixelDistanceFieldTextMaterialRhiShader(bool alphaTexture, int viewCount)
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...
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, int viewCount)
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.
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.
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
GLenum GLuint GLintptr offset
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.