void QSGStyledTextMaterialData::deactivate()
{
    QSGMaterialShader::deactivate();

#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
    if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
        glDisable(GL_FRAMEBUFFER_SRGB);
#endif
}
void QSGTextMaskMaterialData::deactivate()
{
    QSGMaterialShader::deactivate();
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
    if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
        glDisable(GL_FRAMEBUFFER_SRGB);
#endif
}
void QSG24BitTextMaskShader::initialize()
{
    QSGTextMaskShader::initialize();
    // 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0,
    // but using sRGB looks okay.
    if (QOpenGLContext::currentContext()->hasExtension(QByteArrayLiteral("GL_ARB_framebuffer_sRGB"))
            && m_glyphFormat == QFontEngine::Format_A32
            && qAbs(fontSmoothingGamma() - 2.2) < 0.25) {
        m_useSRGB = true;
    }
}
void QSGStyledTextMaterialData::activate()
{
    QSGMaterialShader::activate();

#if !defined(QT_OPENGL_ES_2) && defined(GL_ARB_framebuffer_sRGB)
    // 0.25 was found to be acceptable error margin by experimentation. On Mac, the gamma is 2.0,
    // but using sRGB looks okay.
    if (qAbs(fontSmoothingGamma() - 2.2) < 0.25)
        glEnable(GL_FRAMEBUFFER_SRGB);
#endif
}