7#include <private/qopenglshadercache_p.h> 
    9#include <QtGui/private/qopenglcontext_p.h> 
   10#include <QtCore/qthreadstorage.h> 
   62        return resource ? resource->
shaders() : 
nullptr;
 
   73    return qt_shader_storage()->shadersForThread(
context);
 
   76const char* QOpenGLEngineSharedShaders::qShaderSnippets[] = {
 
   77    0,0,0,0,0,0,0,0,0,0,
 
   78    0,0,0,0,0,0,0,0,0,0,
 
   79    0,0,0,0,0,0,0,0,0,0,
 
  100    const char** code = qShaderSnippets; 
 
  214            qFatal(
"Shader snippet for %s (#%d) is missing!",
 
  236    CachedShader simpleShaderCache(fragSource, vertexSource);
 
  238    bool inCache = simpleShaderCache.
load(simpleShaderProg, 
context);
 
  242            qWarning(
"Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile");
 
  244            qWarning(
"Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile");
 
  252    simpleShaderProg->
link();
 
  262    vertexSource.
clear();
 
  274    inCache = blitShaderCache.
load(blitShaderProg, 
context);
 
  278            qWarning(
"Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile");
 
  280            qWarning(
"Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile");
 
  286    blitShaderProg->
link();
 
  294#ifdef QT_GL_SHARED_SHADER_DEBUG 
  301#ifdef QT_GL_SHARED_SHADER_DEBUG 
  305    cachedPrograms.
clear();
 
  307    if (blitShaderProg) {
 
  308        delete blitShaderProg;
 
  309        blitShaderProg = 
nullptr;
 
  312    if (simpleShaderProg) {
 
  313        delete simpleShaderProg;
 
  314        simpleShaderProg = 
nullptr;
 
  318#if defined (QT_DEBUG) 
  319QByteArray QOpenGLEngineSharedShaders::snippetNameStr(SnippetName 
name)
 
  321    QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator(
"SnippetName"));
 
  330    for (
int i = 0; 
i < cachedPrograms.
size(); ++
i) {
 
  332        if (*cachedProg == prog) {
 
  334            cachedPrograms.
move(
i, 0);
 
  340    std::unique_ptr<QOpenGLEngineShaderProg> newProg;
 
  363        auto shaderProgram = std::make_unique<QOpenGLShaderProgram>();
 
  372                description.
append(
"Vertex shader: main=");
 
  374                description.
append(
", position=");
 
  383                description.
append(
"Fragment shader: main=");
 
  385                description.
append(
", srcPixel=");
 
  388                    description.
append(
", composition=");
 
  392                    description.
append(
", mask=");
 
  414        newProg->program = shaderProgram.release();
 
  416        newProg->program->link();
 
  417        if (newProg->program->isLinked()) {
 
  421            qWarning(
"Shader program failed to link\n" 
  427        newProg->program->bind();
 
  430            GLuint location = newProg->program->uniformLocation(
"maskTexture");
 
  434        if (cachedPrograms.
size() > 30) {
 
  438            for (
int i = 0; 
i < 5; ++
i) {
 
  439                delete cachedPrograms.
last();
 
  444        cachedPrograms.
insert(0, newProg.get());
 
  447    return newProg.release();
 
  453        if (cachedProg->customStageSource == stage->
source()) {
 
  459    cachedPrograms.
removeIf(hasStageAsCustomShaderSouce);
 
  465      shaderProgNeedsChanging(true),
 
  466      complexGeometry(
false),
 
  467      srcPixelType(
Qt::NoBrush),
 
  468      opacityMode(NoOpacity),
 
  470      compositionMode(
QPainter::CompositionMode_SourceOver),
 
  485    if (!currentShaderProg)
 
  489    if (uniformLocations.
isEmpty())
 
  504        "inverse_2_fmp2_m_radius2",
 
  507        "invertedTextureSize",
 
  513    if (uniformLocations.
at(
id) == 
GLuint(-1))
 
  516    return uniformLocations.
at(
id);
 
  527    shaderProgNeedsChanging = 
true;
 
  536    srcPixelType = style;
 
  537    shaderProgNeedsChanging = 
true; 
 
  542    if (srcPixelType == 
type)
 
  546    shaderProgNeedsChanging = 
true; 
 
  551    if (opacityMode == 
mode)
 
  555    shaderProgNeedsChanging = 
true; 
 
  560    if (maskType == 
type)
 
  564    shaderProgNeedsChanging = 
true; 
 
  569    if (compositionMode == 
mode)
 
  575    compositionMode = 
mode;
 
  576    shaderProgNeedsChanging = shaderProgNeedsChanging || wasAdvanced || isAdvanced;
 
  583    customSrcStage = stage;
 
  584    shaderProgNeedsChanging = 
true;
 
  591    customSrcStage = 
nullptr;
 
  592    shaderProgNeedsChanging = 
true;
 
  597    if (currentShaderProg)
 
  598        return currentShaderProg->
program;
 
  613    active_engine->d_func()->setVertexAttribArrayEnabled(
QT_OPACITY_ATTR, 
false);
 
  615    shaderProgNeedsChanging = 
true;
 
  625    active_engine->d_func()->setVertexAttribArrayEnabled(
QT_OPACITY_ATTR, 
false);
 
  626    shaderProgNeedsChanging = 
true;
 
  645    if (!shaderProgNeedsChanging)
 
  648    bool useCustomSrc = customSrcStage != 
nullptr;
 
  650        useCustomSrc = 
false;
 
  651        qWarning(
"QOpenGLEngineShaderManager - Ignoring custom shader stage for non image src");
 
  656    bool texCoords = 
false;
 
  662    bool isAffine = brushTransform.
isAffine();
 
  671    else switch (srcPixelType) {
 
  674            qFatal(
"QOpenGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set");
 
  746        if (hasMask && useGlobalOpacity)
 
  748        if (hasMask && !useGlobalOpacity)
 
  750        if (!hasMask && useGlobalOpacity)
 
  752        if (!hasMask && !useGlobalOpacity)
 
  770            qCritical(
"QOpenGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type");
 
  777        switch (compositionMode) {
 
  812                qWarning(
"QOpenGLEngineShaderManager::useCorrectShaderProg() - Unsupported composition mode");
 
  822    } 
else if (texCoords) {
 
  837        complexGeometry = 
false;
 
  843    if (currentShaderProg && useCustomSrc) {
 
  855    shaderProgNeedsChanging = 
false;
 
  861#include "moc_qopenglengineshadermanager_p.cpp" 
bool store(QOpenGLShaderProgram *, QOpenGLContext *)
 
bool load(QOpenGLShaderProgram *, QOpenGLContext *)
 
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
 
void clear()
Clears the contents of the byte array and makes it null.
 
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
 
qsizetype size() const noexcept
 
QList< T > & fill(parameter_type t, qsizetype size=-1)
 
bool isEmpty() const noexcept
 
iterator insert(qsizetype i, parameter_type t)
 
const_reference at(qsizetype i) const noexcept
 
void move(qsizetype from, qsizetype to)
 
qsizetype removeIf(Predicate pred)
 
void removeLast() noexcept
 
QPaintEngineEx * active_engine
 
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
 
virtual void setUniforms(QOpenGLShaderProgram *)
 
QByteArray source() const
 
QOpenGLShaderProgram * currentProgram()
 
void setSrcPixelType(Qt::BrushStyle)
 
void setOpacityMode(OpacityMode)
 
QOpenGLEngineSharedShaders * sharedShaders
 
~QOpenGLEngineShaderManager()
 
void setMaskType(MaskType)
 
QOpenGLEngineShaderManager(QOpenGLContext *context)
 
QOpenGLShaderProgram * blitProgram()
 
GLuint getUniformLocation(Uniform id)
 
QOpenGLShaderProgram * simpleProgram()
 
void optimiseForBrushTransform(QTransform::TransformationType transformType)
 
@ NonPremultipliedImageSrc
 
void setCustomStage(QOpenGLCustomShaderStage *stage)
 
bool useCorrectShaderProg()
 
void setCompositionMode(QPainter::CompositionMode)
 
QOpenGLShaderProgram * program
 
QOpenGLEngineSharedShaders::SnippetName compositionFragShader
 
QList< uint > uniformLocations
 
bool usePmvMatrixAttribute
 
QOpenGLEngineSharedShaders::SnippetName mainFragShader
 
QOpenGLEngineSharedShaders::SnippetName positionVertexShader
 
QByteArray customStageSource
 
QOpenGLEngineSharedShaders::SnippetName srcPixelFragShader
 
QOpenGLEngineSharedShaders::SnippetName mainVertexShader
 
QOpenGLEngineSharedShaders::SnippetName maskFragShader
 
QOpenGLEngineSharedShadersResource(QOpenGLContext *ctx)
 
void invalidateResource() override
 
void freeResource(QOpenGLContext *) override
 
~QOpenGLEngineSharedShadersResource()
 
QOpenGLEngineSharedShaders * shaders() const
 
QOpenGLEngineShaderProg * findProgramInCache(const QOpenGLEngineShaderProg &prog)
 
@ MainWithTexCoordsVertexShader
 
@ PositionWithTextureBrushVertexShader
 
@ ConicalGradientBrushSrcFragmentShader
 
@ ExclusionCompositionModeFragmentShader
 
@ AffinePositionWithPatternBrushVertexShader
 
@ NonPremultipliedImageSrcFragmentShader
 
@ DifferenceCompositionModeFragmentShader
 
@ PositionWithConicalGradientBrushVertexShader
 
@ NoCompositionModeFragmentShader
 
@ TextureBrushSrcFragmentShader
 
@ MainFragmentShader_ImageArrays
 
@ DarkenCompositionModeFragmentShader
 
@ OverlayCompositionModeFragmentShader
 
@ PositionWithRadialGradientBrushVertexShader
 
@ ScreenCompositionModeFragmentShader
 
@ PositionWithLinearGradientBrushVertexShader
 
@ AlphaImageSrcFragmentShader
 
@ SolidBrushSrcFragmentShader
 
@ PositionOnlyVertexShader
 
@ CustomImageSrcFragmentShader
 
@ LightenCompositionModeFragmentShader
 
@ ShockingPinkSrcFragmentShader
 
@ TextureBrushSrcWithPatternFragmentShader
 
@ GrayscaleImageSrcFragmentShader
 
@ RgbMaskFragmentShaderPass2
 
@ PositionWithPatternBrushVertexShader
 
@ ColorBurnCompositionModeFragmentShader
 
@ MultiplyCompositionModeFragmentShader
 
@ RgbMaskFragmentShaderPass1
 
@ AffinePositionWithTextureBrushVertexShader
 
@ LinearGradientBrushSrcFragmentShader
 
@ AffinePositionWithLinearGradientBrushVertexShader
 
@ RadialGradientBrushSrcFragmentShader
 
@ AffinePositionWithConicalGradientBrushVertexShader
 
@ ImageSrcWithPatternFragmentShader
 
@ UntransformedPositionVertexShader
 
@ ColorDodgeCompositionModeFragmentShader
 
@ ComplexGeometryPositionOnlyVertexShader
 
@ RgbMaskWithGammaFragmentShader
 
@ SoftLightCompositionModeFragmentShader
 
@ PatternBrushSrcFragmentShader
 
@ HardLightCompositionModeFragmentShader
 
@ AffinePositionWithRadialGradientBrushVertexShader
 
@ MainWithTexCoordsAndOpacityVertexShader
 
QOpenGLShaderProgram * blitProgram()
 
QOpenGLShaderProgram * simpleProgram()
 
~QOpenGLEngineSharedShaders()
 
void cleanupCustomStage(QOpenGLCustomShaderStage *stage)
 
static QOpenGLEngineSharedShaders * shadersForContext(QOpenGLContext *context)
 
QOpenGLEngineSharedShaders(QOpenGLContext *context)
 
The QOpenGLMultiGroupSharedResource keeps track of a shared resource that might be needed from multip...
 
The QOpenGLShaderProgram class allows OpenGL shader programs to be linked and used.
 
void bindAttributeLocation(const char *name, int location)
Binds the attribute name to the specified location.
 
virtual bool link()
Links together the shaders that were added to this program with addShader().
 
int uniformLocation(const char *name) const
Returns the location of the uniform variable name within this shader program's parameter list.
 
QString log() const
Returns the errors and warnings that occurred during the last link() or addShader() with explicitly s...
 
bool addCacheableShaderFromSourceCode(QOpenGLShader::ShaderType type, const char *source)
Registers the shader of the specified type and source to this program.
 
bool isLinked() const
Returns true if this shader program has been linked; false otherwise.
 
bool bind()
Binds this shader program to the active QOpenGLContext and makes it the current shader program.
 
QOpenGLEngineSharedShaders * shadersForThread(QOpenGLContext *context)
 
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL con...
 
The QPainter class performs low-level painting on widgets and other paint devices.
 
CompositionMode
Defines the modes supported for digital image compositing.
 
@ CompositionMode_Lighten
 
@ CompositionMode_ColorDodge
 
@ CompositionMode_Overlay
 
@ CompositionMode_Multiply
 
@ CompositionMode_HardLight
 
@ CompositionMode_Exclusion
 
@ CompositionMode_ColorBurn
 
@ CompositionMode_Difference
 
@ CompositionMode_SoftLight
 
T & localData()
Returns a reference to the data that was set by the calling thread.
 
static QThread * currentThread()
 
qDeleteAll(list.begin(), list.end())
 
Combined button and popup list for selecting options.
 
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
 
static const GLuint QT_TEXTURE_COORDS_ATTR
 
static const GLuint QT_PMV_MATRIX_2_ATTR
 
static const GLuint QT_OPACITY_ATTR
 
static const GLuint QT_PMV_MATRIX_1_ATTR
 
static QT_BEGIN_NAMESPACE const GLuint QT_VERTEX_COORDS_ATTR
 
static const GLuint QT_PMV_MATRIX_3_ATTR
 
static const char *const qopenglslConicalGradientBrushSrcFragmentShader
 
static QT_BEGIN_NAMESPACE const char *const qopenglslMainVertexShader
 
static const char *const qopenglslPatternBrushSrcFragmentShader
 
static const char *const qopenglslMainFragmentShader_M
 
static const char *const qopenglslPositionWithConicalGradientBrushVertexShader
 
static const char *const qopenglslImageSrcWithPatternFragmentShader
 
static const char *const qopenglslSolidBrushSrcFragmentShader
 
static const char *const qopenglslImageSrcFragmentShader
 
static const char *const qopenglslAffinePositionWithLinearGradientBrushVertexShader
 
static const char *const qopenglslMainFragmentShader_ImageArrays
 
static const char *const qopenglslAlphaImageSrcFragmentShader
 
static const char *const qopenglslLinearGradientBrushSrcFragmentShader
 
static const char *const qopenglslPositionOnlyVertexShader
 
static const char *const qopenglslShockingPinkSrcFragmentShader
 
static const char *const qopenglslPositionWithPatternBrushVertexShader
 
static const char *const qopenglslMainFragmentShader_MO
 
static const char *const qopenglslMainWithTexCoordsAndOpacityVertexShader
 
static const char *const qopenglslRgbMaskFragmentShaderPass2
 
static const char *const qopenglslRgbMaskFragmentShaderPass1
 
static const char *const qopenglslCustomSrcFragmentShader
 
static const char *const qopenglslAffinePositionWithRadialGradientBrushVertexShader
 
static const char *const qopenglslGrayscaleImageSrcFragmentShader
 
static const char *const qopenglslAffinePositionWithTextureBrushVertexShader
 
static const char *const qopenglslAffinePositionWithConicalGradientBrushVertexShader
 
static const char *const qopenglslUntransformedPositionVertexShader
 
static const char *const qopenglslMainFragmentShader
 
static const char *const qopenglslAffinePositionWithPatternBrushVertexShader
 
static const char *const qopenglslTextureBrushSrcWithPatternFragmentShader
 
static const char *const qopenglslRadialGradientBrushSrcFragmentShader
 
static const char *const qopenglslTextureBrushSrcFragmentShader
 
static const char *const qopenglslMainFragmentShader_O
 
static const char *const qopenglslPositionWithLinearGradientBrushVertexShader
 
static const char *const qopenglslComplexGeometryPositionOnlyVertexShader
 
static const char *const qopenglslMaskFragmentShader
 
static const char *const qopenglslPositionWithTextureBrushVertexShader
 
static const char *const qopenglslMainWithTexCoordsVertexShader
 
static const char *const qopenglslNonPremultipliedImageSrcFragmentShader
 
GLuint GLenum transformType
 
GLsizei GLsizei GLuint * shaders
 
GLsizei const GLchar *const  * uniformNames
 
#define QT_MASK_TEXTURE_UNIT
 
static bool isCoreProfile()
 
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
 
#define qPrintable(string)
 
#define qUtf16Printable(string)
 
QVideoFrameFormat::PixelFormat fmt