62 return shaders->
value(context);
73 return qt_shader_storage()->shadersForThread(context);
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,
95 static bool snippetsPopulated =
false;
96 if (!snippetsPopulated) {
160 #if defined(QT_DEBUG) 164 qFatal(
"Shader snippet for %s (#%d) is missing!",
169 snippetsPopulated =
true;
186 CachedShader simpleShaderCache(fragSource, vertexSource);
194 qWarning(
"Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile");
199 qWarning(
"Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile");
216 qCritical() <<
"Errors linking simple shader:" 221 vertexSource.
clear();
239 qWarning(
"Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile");
244 qWarning(
"Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile");
258 qCritical() <<
"Errors linking blit shader:" 262 #ifdef QT_GL_SHARED_SHADER_DEBUG 269 #ifdef QT_GL_SHARED_SHADER_DEBUG 289 #if defined (QT_DEBUG) 292 QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator(
"SnippetName"));
303 if (*cachedProg == prog) {
339 #if defined(QT_DEBUG) 341 description.
append(
"Fragment shader: main=");
343 description.
append(
", srcPixel=");
346 description.
append(
", composition=");
350 description.
append(
", mask=");
356 qWarning() <<
"Warning:" << description <<
"failed to compile!";
361 #if defined(QT_DEBUG) 364 description.
append(
"Vertex shader: main=");
366 description.
append(
", position=");
371 qWarning() <<
"Warning:" << description <<
"failed to compile!";
405 #if defined(QT_DEBUG) 430 for (
int i = 0; i < 5; ++i) {
439 return newProg.
take();
458 shaderProgNeedsChanging(true),
459 complexGeometry(false),
461 opacityMode(NoOpacity),
463 compositionMode(
QPainter::CompositionMode_SourceOver),
482 if (uniformLocations.
isEmpty())
485 static const char *uniformNames[] = {
497 "inverse_2_fmp2_m_radius2",
500 "invertedTextureSize",
506 if (uniformLocations.
at(
id) == GLuint(-1))
509 return uniformLocations.
at(
id);
634 useCustomSrc =
false;
635 qWarning(
"QGLEngineShaderManager - Ignoring custom shader stage for non image src");
640 bool texCoords =
false;
658 qFatal(
"QGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set");
720 if (hasCompose && hasMask && useGlobalOpacity)
722 if (hasCompose && hasMask && !useGlobalOpacity)
724 if (!hasCompose && hasMask && useGlobalOpacity)
726 if (!hasCompose && hasMask && !useGlobalOpacity)
728 if (hasCompose && !hasMask && useGlobalOpacity)
730 if (hasCompose && !hasMask && !useGlobalOpacity)
732 if (!hasCompose && !hasMask && useGlobalOpacity)
734 if (!hasCompose && !hasMask && !useGlobalOpacity)
752 qCritical(
"QGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type");
794 qWarning(
"QGLEngineShaderManager::useCorrectShaderProg() - Unsupported composition mode");
804 }
else if (texCoords) {
static const char *const qglslAffinePositionWithTextureBrushVertexShader
The QPainter class performs low-level painting on widgets and other paint devices.
void bindAttributeLocation(const char *name, int location)
Binds the attribute name to the specified location.
QGLSharedResourceGuard ctxGuard
static const GLuint QT_PMV_MATRIX_3_ATTR
const QGLContext * context() const
bool shaderProgNeedsChanging
static const char *const qglslPositionWithLinearGradientBrushVertexShader
static const char *const qglslPositionWithRadialGradientBrushVertexShader
bool compileSourceCode(const char *source)
Sets the source code for this shader and compiles it.
T * value(const QGLContext *context)
#define QT_END_NAMESPACE
This macro expands to.
QVector< uint > uniformLocations
static const char *const qglslCustomSrcFragmentShader
QGLEngineSharedShaders::SnippetName mainVertexShader
CompositionMode
Defines the modes supported for digital image compositing.
static const char *const qglslAffinePositionWithPatternBrushVertexShader
static const char *const qglslNonPremultipliedImageSrcFragmentShader
T * data() const
Returns the value of the pointer referenced by this object.
static const char *const qglslMainFragmentShader
~QGLEngineShaderManager()
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
QGLCustomShaderStage * customSrcStage
QByteArray & append(char c)
Appends the character ch to this byte array.
QGLEngineSharedShaders::SnippetName mainFragShader
QGLShaderProgram * blitProgram()
void setMaskType(MaskType)
The QByteArray class provides an array of bytes.
T * take()
Returns the value of the pointer referenced by this object.
void setSrcPixelType(Qt::BrushStyle)
void insert(int i, const T &t)
Inserts value at index position i in the list.
QGLShaderProgram * blitProgram()
void removeLast()
Removes the last item in the list.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static const char *const qglslConicalGradientBrushSrcFragmentShader
int count(const T &t) const
Returns the number of occurrences of value in the list.
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...
static const char *const qglslRgbMaskFragmentShaderPass2
QGLEngineSharedShaders::SnippetName maskFragShader
QGLEngineSharedShaders::SnippetName positionVertexShader
static const char *const qglslAffinePositionWithConicalGradientBrushVertexShader
The QString class provides a Unicode character string.
QGLEngineShaderProg * findProgramInCache(const QGLEngineShaderProg &prog)
QGLShaderProgram * blitShaderProg
QByteArray customStageSource
static const char *const qglslRgbMaskFragmentShaderPass1
void setVertexAttribArrayEnabled(int arrayIndex, bool enabled=true)
~QGLEngineSharedShaders()
static QGLEngineSharedShaders * shadersForContext(const QGLContext *context)
QByteArray sourceCode() const
Returns the source code for this shader.
QGLShaderProgram * simpleShaderProg
static const char *const qglslPositionWithPatternBrushVertexShader
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
void setObjectName(const QString &name)
static const GLuint QT_OPACITY_ATTR
static const char *const qglslPatternBrushSrcFragmentShader
QGLEngineShaderProg * currentShaderProg
static const char *const qglslSolidBrushSrcFragmentShader
void move(int from, int to)
Moves the item at index position from to index position to.
Q_CORE_EXPORT void qDebug(const char *,...)
static const char *const qglslMainFragmentShader_O
QByteArray source() const
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
void append(const T &t)
Inserts value at the end of the list.
QGLEngineSharedShaders(const QGLContext *context)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QTransform brushTransform
static const char *const qglslShockingPinkSrcFragmentShader
static const char *const qglslPositionWithTextureBrushVertexShader
QList< QGLShader * > shaders
virtual void setUniforms(QGLShaderProgram *)
The QGLContext class encapsulates an OpenGL rendering context.
static const char *const qglslMainFragmentShader_C
The QGLShader class allows OpenGL shaders to be compiled.
T & localData()
Returns a reference to the data that was set by the calling thread.
const T & at(int i) const
Returns the item at index position i in the list.
QPainter::CompositionMode compositionMode
static const GLuint QT_PMV_MATRIX_2_ATTR
QList< QGLEngineShaderProg * > cachedPrograms
void setCompositionMode(QPainter::CompositionMode)
static const char *const qglslPositionOnlyVertexShader
bool usePmvMatrixAttribute
Q_CORE_EXPORT void qWarning(const char *,...)
QGLShaderProgram * simpleProgram()
QGLEngineSharedShaders::SnippetName compositionFragShader
bool load(QGLShaderProgram *, const QGLContext *)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
bool store(QGLShaderProgram *, const QGLContext *)
void setCustomStage(QGLCustomShaderStage *stage)
static const char *const qglslLinearGradientBrushSrcFragmentShader
static const char *const qglslPositionWithConicalGradientBrushVertexShader
void clear()
Removes all items from the list.
QThreadStorage< QGLContextGroupResource< QGLEngineSharedShaders > * > m_storage
void cleanupCustomStage(QGLCustomShaderStage *stage)
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
const T & at(int i) const
Returns the item at index position i in the vector.
static const char *const qglslMainFragmentShader_CM
virtual bool link()
Links together the shaders that were added to this program with addShader().
static const char *const qglslTextureBrushSrcWithPatternFragmentShader
Q_CORE_EXPORT void qFatal(const char *,...)
void setUniformValue(int location, GLfloat value)
Sets the uniform variable at location in the current context to value.
static const char *const qglslMainFragmentShader_ImageArrays
static const char *const qglslMainWithTexCoordsAndOpacityVertexShader
static const GLuint QT_PMV_MATRIX_1_ATTR
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
static const char *const qglslMainFragmentShader_CO
static QTestResult::TestLocation location
T & last()
Returns a reference to the last item in the list.
int size() const
Returns the number of items in the list.
QString objectName() const
static const GLuint QT_TEXTURE_COORDS_ATTR
QGLShaderProgram * currentProgram()
QGLEngineSharedShaders * shadersForThread(const QGLContext *context)
static const char *const qglslRadialGradientBrushSrcFragmentShader
bool useCorrectShaderProg()
static const char *const qglslMainFragmentShader_M
bool addShader(QGLShader *shader)
Adds a compiled shader to this shader program.
QGLEngineSharedShaders::SnippetName srcPixelFragShader
static const char *const qglslAffinePositionWithRadialGradientBrushVertexShader
QGLShaderProgram * simpleProgram()
static const char *const qglslMainWithTexCoordsVertexShader
static const char *const qglslMaskFragmentShader
static const char *const qglslAffinePositionWithLinearGradientBrushVertexShader
static const char *const qglslImageSrcFragmentShader
void optimiseForBrushTransform(QTransform::TransformationType transformType)
static const char *const qglslMainFragmentShader_MO
GLuint getUniformLocation(Uniform id)
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
static const char *const qglslUntransformedPositionVertexShader
#define QT_MASK_TEXTURE_UNIT
static const char *const qglslComplexGeometryPositionOnlyVertexShader
static const char * qShaderSnippets[TotalSnippetCount]
static const GLuint QT_VERTEX_COORDS_ATTR
QGLEngineSharedShaders * sharedShaders
bool bind()
Binds this shader program to the active QGLContext and makes it the current shader program...
QList< QGLShader * > shaders() const
Returns a list of all shaders that have been added to this shader program using addShader().
QGLEngineShaderManager(QGLContext *context)
void setOpacityMode(OpacityMode)
QGLShaderProgram * program
static const char *const qglslImageSrcWithPatternFragmentShader
The QThreadStorage class provides per-thread data storage.
The QGLShaderProgram class allows OpenGL shader programs to be linked and used.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static const char *const qglslMainVertexShader
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
void clear()
Clears the contents of the byte array and makes it empty.
Q_GLOBAL_STATIC(QGLShaderStorage, qt_shader_storage)
static const char *const qglslTextureBrushSrcFragmentShader
bool isLinked() const
Returns true if this shader program has been linked; false otherwise.
static const char *const qglslMainFragmentShader_CMO
Q_CORE_EXPORT void qCritical(const char *,...)
void removeAt(int i)
Removes the item at index position i.