Qt 4.8
qglengineshadermanager.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtOpenGL module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
45 #include "qglshadercache_p.h"
46 
47 #if defined(QT_DEBUG)
48 #include <QMetaEnum>
49 #endif
50 
51 // #define QT_GL_SHARED_SHADER_DEBUG
52 
54 
56 {
57 public:
60  if (!shaders)
62  return shaders->value(context);
63  }
64 
65 private:
67 };
68 
69 Q_GLOBAL_STATIC(QGLShaderStorage, qt_shader_storage);
70 
72 {
73  return qt_shader_storage()->shadersForThread(context);
74 }
75 
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,
80  0,0,0,0,0
81 };
82 
84  : ctxGuard(context)
85  , blitShaderProg(0)
86  , simpleShaderProg(0)
87 {
88 
89 /*
90  Rather than having the shader source array statically initialised, it is initialised
91  here instead. This is to allow new shader names to be inserted or existing names moved
92  around without having to change the order of the glsl strings. It is hoped this will
93  make future hard-to-find runtime bugs more obvious and generally give more solid code.
94 */
95  static bool snippetsPopulated = false;
96  if (!snippetsPopulated) {
97 
98  const char** code = qShaderSnippets; // shortcut
99 
103 
117 
127 
131  code[CustomImageSrcFragmentShader] = qglslCustomSrcFragmentShader; // Calls "customShader", which must be appended
140 
141  code[NoMaskFragmentShader] = "";
145  code[RgbMaskWithGammaFragmentShader] = ""; //###
146 
148  code[MultiplyCompositionModeFragmentShader] = ""; //###
149  code[ScreenCompositionModeFragmentShader] = ""; //###
150  code[OverlayCompositionModeFragmentShader] = ""; //###
151  code[DarkenCompositionModeFragmentShader] = ""; //###
152  code[LightenCompositionModeFragmentShader] = ""; //###
159 
160 #if defined(QT_DEBUG)
161  // Check that all the elements have been filled:
162  for (int i = 0; i < TotalSnippetCount; ++i) {
163  if (qShaderSnippets[i] == 0) {
164  qFatal("Shader snippet for %s (#%d) is missing!",
165  snippetNameStr(SnippetName(i)).constData(), i);
166  }
167  }
168 #endif
169  snippetsPopulated = true;
170  }
171 
172  QGLShader* fragShader;
173  QGLShader* vertexShader;
174  QByteArray vertexSource;
175  QByteArray fragSource;
176 
177  // Compile up the simple shader:
178  vertexSource.append(qShaderSnippets[MainVertexShader]);
180 
183 
184  simpleShaderProg = new QGLShaderProgram(context, 0);
185 
186  CachedShader simpleShaderCache(fragSource, vertexSource);
187 
188  bool inCache = simpleShaderCache.load(simpleShaderProg, context);
189 
190  if (!inCache) {
191  vertexShader = new QGLShader(QGLShader::Vertex, context, 0);
192  shaders.append(vertexShader);
193  if (!vertexShader->compileSourceCode(vertexSource))
194  qWarning("Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile");
195 
196  fragShader = new QGLShader(QGLShader::Fragment, context, 0);
197  shaders.append(fragShader);
198  if (!fragShader->compileSourceCode(fragSource))
199  qWarning("Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile");
200 
201  simpleShaderProg->addShader(vertexShader);
202  simpleShaderProg->addShader(fragShader);
203 
208  }
209 
211 
212  if (simpleShaderProg->isLinked()) {
213  if (!inCache)
214  simpleShaderCache.store(simpleShaderProg, context);
215  } else {
216  qCritical() << "Errors linking simple shader:"
217  << simpleShaderProg->log();
218  }
219 
220  // Compile the blit shader:
221  vertexSource.clear();
224 
225  fragSource.clear();
226  fragSource.append(qShaderSnippets[MainFragmentShader]);
228 
229  blitShaderProg = new QGLShaderProgram(context, 0);
230 
231  CachedShader blitShaderCache(fragSource, vertexSource);
232 
233  inCache = blitShaderCache.load(blitShaderProg, context);
234 
235  if (!inCache) {
236  vertexShader = new QGLShader(QGLShader::Vertex, context, 0);
237  shaders.append(vertexShader);
238  if (!vertexShader->compileSourceCode(vertexSource))
239  qWarning("Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile");
240 
241  fragShader = new QGLShader(QGLShader::Fragment, context, 0);
242  shaders.append(fragShader);
243  if (!fragShader->compileSourceCode(fragSource))
244  qWarning("Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile");
245 
246  blitShaderProg->addShader(vertexShader);
247  blitShaderProg->addShader(fragShader);
248 
251  }
252 
253  blitShaderProg->link();
254  if (blitShaderProg->isLinked()) {
255  if (!inCache)
256  blitShaderCache.store(blitShaderProg, context);
257  } else {
258  qCritical() << "Errors linking blit shader:"
259  << blitShaderProg->log();
260  }
261 
262 #ifdef QT_GL_SHARED_SHADER_DEBUG
263  qDebug(" -> QGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread());
264 #endif
265 }
266 
268 {
269 #ifdef QT_GL_SHARED_SHADER_DEBUG
270  qDebug(" -> ~QGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread());
271 #endif
273  shaders.clear();
274 
277 
278  if (blitShaderProg) {
279  delete blitShaderProg;
280  blitShaderProg = 0;
281  }
282 
283  if (simpleShaderProg) {
284  delete simpleShaderProg;
285  simpleShaderProg = 0;
286  }
287 }
288 
289 #if defined (QT_DEBUG)
290 QByteArray QGLEngineSharedShaders::snippetNameStr(SnippetName name)
291 {
292  QMetaEnum m = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("SnippetName"));
293  return QByteArray(m.valueToKey(name));
294 }
295 #endif
296 
297 // The address returned here will only be valid until next time this function is called.
298 // The program is return bound.
300 {
301  for (int i = 0; i < cachedPrograms.size(); ++i) {
302  QGLEngineShaderProg *cachedProg = cachedPrograms[i];
303  if (*cachedProg == prog) {
304  // Move the program to the top of the list as a poor-man's cache algo
305  cachedPrograms.move(i, 0);
306  cachedProg->program->bind();
307  return cachedProg;
308  }
309  }
310 
312 
313  do {
314  QByteArray fragSource;
315  // Insert the custom stage before the srcPixel shader to work around an ATI driver bug
316  // where you cannot forward declare a function that takes a sampler as argument.
318  fragSource.append(prog.customStageSource);
319  fragSource.append(qShaderSnippets[prog.mainFragShader]);
320  fragSource.append(qShaderSnippets[prog.srcPixelFragShader]);
321  if (prog.compositionFragShader)
322  fragSource.append(qShaderSnippets[prog.compositionFragShader]);
323  if (prog.maskFragShader)
324  fragSource.append(qShaderSnippets[prog.maskFragShader]);
325 
326  QByteArray vertexSource;
327  vertexSource.append(qShaderSnippets[prog.mainVertexShader]);
328  vertexSource.append(qShaderSnippets[prog.positionVertexShader]);
329 
331 
332  CachedShader shaderCache(fragSource, vertexSource);
333  bool inCache = shaderCache.load(shaderProgram.data(), ctxGuard.context());
334 
335  if (!inCache) {
336 
338  QByteArray description;
339 #if defined(QT_DEBUG)
340  // Name the shader for easier debugging
341  description.append("Fragment shader: main=");
342  description.append(snippetNameStr(prog.mainFragShader));
343  description.append(", srcPixel=");
344  description.append(snippetNameStr(prog.srcPixelFragShader));
345  if (prog.compositionFragShader) {
346  description.append(", composition=");
347  description.append(snippetNameStr(prog.compositionFragShader));
348  }
349  if (prog.maskFragShader) {
350  description.append(", mask=");
351  description.append(snippetNameStr(prog.maskFragShader));
352  }
353  fragShader->setObjectName(QString::fromLatin1(description));
354 #endif
355  if (!fragShader->compileSourceCode(fragSource)) {
356  qWarning() << "Warning:" << description << "failed to compile!";
357  break;
358  }
359 
361 #if defined(QT_DEBUG)
362  // Name the shader for easier debugging
363  description.clear();
364  description.append("Vertex shader: main=");
365  description.append(snippetNameStr(prog.mainVertexShader));
366  description.append(", position=");
367  description.append(snippetNameStr(prog.positionVertexShader));
368  vertexShader->setObjectName(QString::fromLatin1(description));
369 #endif
370  if (!vertexShader->compileSourceCode(vertexSource)) {
371  qWarning() << "Warning:" << description << "failed to compile!";
372  break;
373  }
374 
375  shaders.append(vertexShader.data());
376  shaders.append(fragShader.data());
377  shaderProgram->addShader(vertexShader.take());
378  shaderProgram->addShader(fragShader.take());
379 
380  // We have to bind the vertex attribute names before the program is linked:
381  shaderProgram->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR);
382  if (prog.useTextureCoords)
383  shaderProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
384  if (prog.useOpacityAttribute)
385  shaderProgram->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR);
386  if (prog.usePmvMatrixAttribute) {
387  shaderProgram->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR);
388  shaderProgram->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR);
389  shaderProgram->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR);
390  }
391  }
392 
393  newProg.reset(new QGLEngineShaderProg(prog));
394  newProg->program = shaderProgram.take();
395 
396  newProg->program->link();
397  if (newProg->program->isLinked()) {
398  if (!inCache)
399  shaderCache.store(newProg->program, ctxGuard.context());
400  } else {
401  QLatin1String none("none");
402  QLatin1String br("\n");
403  QString error;
404  error = QLatin1String("Shader program failed to link,");
405 #if defined(QT_DEBUG)
406  error += QLatin1String("\n Shaders Used:\n");
407  for (int i = 0; i < newProg->program->shaders().count(); ++i) {
408  QGLShader *shader = newProg->program->shaders().at(i);
409  error += QLatin1String(" ") + shader->objectName() + QLatin1String(": \n")
410  + QLatin1String(shader->sourceCode()) + br;
411  }
412 #endif
413  error += QLatin1String(" Error Log:\n")
414  + QLatin1String(" ") + newProg->program->log();
415  qWarning() << error;
416  break;
417  }
418 
419  newProg->program->bind();
420 
422  GLuint location = newProg->program->uniformLocation("maskTexture");
423  newProg->program->setUniformValue(location, QT_MASK_TEXTURE_UNIT);
424  }
425 
426  if (cachedPrograms.count() > 30) {
427  // The cache is full, so delete the last 5 programs in the list.
428  // These programs will be least used, as a program us bumped to
429  // the top of the list when it's used.
430  for (int i = 0; i < 5; ++i) {
431  delete cachedPrograms.last();
433  }
434  }
435 
436  cachedPrograms.insert(0, newProg.data());
437  } while (false);
438 
439  return newProg.take();
440 }
441 
443 {
444  // Remove any shader programs which has this as the custom shader src:
445  for (int i = 0; i < cachedPrograms.size(); ++i) {
446  QGLEngineShaderProg *cachedProg = cachedPrograms[i];
447  if (cachedProg->customStageSource == stage->source()) {
448  delete cachedProg;
450  i--;
451  }
452  }
453 }
454 
455 
457  : ctx(context),
458  shaderProgNeedsChanging(true),
459  complexGeometry(false),
460  srcPixelType(Qt::NoBrush),
461  opacityMode(NoOpacity),
462  maskType(NoMask),
463  compositionMode(QPainter::CompositionMode_SourceOver),
464  customSrcStage(0),
465  currentShaderProg(0)
466 {
468 }
469 
471 {
472  //###
474 }
475 
477 {
478  if (!currentShaderProg)
479  return 0;
480 
481  QVector<uint> &uniformLocations = currentShaderProg->uniformLocations;
482  if (uniformLocations.isEmpty())
483  uniformLocations.fill(GLuint(-1), NumUniforms);
484 
485  static const char *uniformNames[] = {
486  "imageTexture",
487  "patternColor",
488  "globalOpacity",
489  "depth",
490  "maskTexture",
491  "fragmentColor",
492  "linearData",
493  "angle",
494  "halfViewportSize",
495  "fmp",
496  "fmp2_m_radius2",
497  "inverse_2_fmp2_m_radius2",
498  "sqrfr",
499  "bradius",
500  "invertedTextureSize",
501  "brushTransform",
502  "brushTexture",
503  "matrix"
504  };
505 
506  if (uniformLocations.at(id) == GLuint(-1))
507  uniformLocations[id] = currentShaderProg->program->uniformLocation(uniformNames[id]);
508 
509  return uniformLocations.at(id);
510 }
511 
512 
514 {
515  Q_UNUSED(transformType); // Currently ignored
516 }
517 
519 {
521 }
522 
524 {
525  Q_ASSERT(style != Qt::NoBrush);
526  if (srcPixelType == PixelSrcType(style))
527  return;
528 
529  srcPixelType = style;
530  shaderProgNeedsChanging = true; //###
531 }
532 
534 {
535  if (srcPixelType == type)
536  return;
537 
538  srcPixelType = type;
539  shaderProgNeedsChanging = true; //###
540 }
541 
543 {
544  if (opacityMode == mode)
545  return;
546 
547  opacityMode = mode;
548  shaderProgNeedsChanging = true; //###
549 }
550 
552 {
553  if (maskType == type)
554  return;
555 
556  maskType = type;
557  shaderProgNeedsChanging = true; //###
558 }
559 
561 {
562  if (compositionMode == mode)
563  return;
564 
565  compositionMode = mode;
566  shaderProgNeedsChanging = true; //###
567 }
568 
570 {
571  if (customSrcStage)
573  customSrcStage = stage;
575 }
576 
578 {
579  if (customSrcStage)
581  customSrcStage = 0;
583 }
584 
586 {
587  if (currentShaderProg)
588  return currentShaderProg->program;
589  else
590  return sharedShaders->simpleProgram();
591 }
592 
594 {
596  QGLContextPrivate* ctx_d = ctx->d_func();
601 }
602 
604 {
606  QGLContextPrivate* ctx_d = ctx->d_func();
611 }
612 
614 {
615  return sharedShaders->simpleProgram();
616 }
617 
619 {
620  return sharedShaders->blitProgram();
621 }
622 
623 
624 
625 // Select & use the correct shader program using the current state.
626 // Returns true if program needed changing.
628 {
630  return false;
631 
632  bool useCustomSrc = customSrcStage != 0;
634  useCustomSrc = false;
635  qWarning("QGLEngineShaderManager - Ignoring custom shader stage for non image src");
636  }
637 
638  QGLEngineShaderProg requiredProgram;
639 
640  bool texCoords = false;
641 
642  // Choose vertex shader shader position function (which typically also sets
643  // varyings) and the source pixel (srcPixel) fragment shader function:
646  bool isAffine = brushTransform.isAffine();
648  if (isAffine)
650  else
652 
654  }
655  else switch (srcPixelType) {
656  default:
657  case Qt::NoBrush:
658  qFatal("QGLEngineShaderManager::useCorrectShaderProg() - Qt::NoBrush style is set");
659  break;
663  texCoords = true;
664  break;
668  texCoords = true;
669  break;
673  texCoords = true;
674  break;
679  break;
680  case Qt::SolidPattern:
683  break;
688  break;
693  break;
698  break;
699  case Qt::TexturePattern:
703  break;
704  };
705 
706  if (useCustomSrc) {
708  requiredProgram.customStageSource = customSrcStage->source();
709  }
710 
711  const bool hasCompose = compositionMode > QPainter::CompositionMode_Plus;
712  const bool hasMask = maskType != QGLEngineShaderManager::NoMask;
713 
714  // Choose fragment shader main function:
715  if (opacityMode == AttributeOpacity) {
716  Q_ASSERT(!hasCompose && !hasMask);
718  } else {
719  bool useGlobalOpacity = (opacityMode == UniformOpacity);
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)
736  }
737 
738  if (hasMask) {
739  if (maskType == PixelMask) {
741  texCoords = true;
742  } else if (maskType == SubPixelMaskPass1) {
744  texCoords = true;
745  } else if (maskType == SubPixelMaskPass2) {
747  texCoords = true;
748  } else if (maskType == SubPixelWithGammaMask) {
750  texCoords = true;
751  } else {
752  qCritical("QGLEngineShaderManager::useCorrectShaderProg() - Unknown mask type");
753  }
754  } else {
756  }
757 
758  if (hasCompose) {
759  switch (compositionMode) {
762  break;
765  break;
768  break;
771  break;
774  break;
777  break;
780  break;
783  break;
786  break;
789  break;
792  break;
793  default:
794  qWarning("QGLEngineShaderManager::useCorrectShaderProg() - Unsupported composition mode");
795  }
796  } else {
798  }
799 
800  // Choose vertex shader main function
801  if (opacityMode == AttributeOpacity) {
802  Q_ASSERT(texCoords);
804  } else if (texCoords) {
806  } else {
808  }
809  requiredProgram.useTextureCoords = texCoords;
810  requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity);
813  requiredProgram.usePmvMatrixAttribute = false;
814  } else {
815  requiredProgram.usePmvMatrixAttribute = true;
816 
817  // Force complexGeometry off, since we currently don't support that mode for
818  // non-solid brushes
819  complexGeometry = false;
820  }
821 
822  // At this point, requiredProgram is fully populated so try to find the program in the cache
824 
825  if (currentShaderProg && useCustomSrc) {
827  }
828 
829  // Make sure all the vertex attribute arrays the program uses are enabled (and the ones it
830  // doesn't use are disabled)
831  QGLContextPrivate* ctx_d = ctx->d_func();
835 
836  shaderProgNeedsChanging = false;
837  return true;
838 }
839 
static const char *const qglslAffinePositionWithTextureBrushVertexShader
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void bindAttributeLocation(const char *name, int location)
Binds the attribute name to the specified location.
QGLSharedResourceGuard ctxGuard
BrushStyle
Definition: qnamespace.h:1162
static const GLuint QT_PMV_MATRIX_3_ATTR
const QGLContext * context() const
Definition: qgl_p.h:873
static const char *const qglslPositionWithLinearGradientBrushVertexShader
int type
Definition: qmetatype.cpp:239
static const char *const qglslPositionWithRadialGradientBrushVertexShader
bool compileSourceCode(const char *source)
Sets the source code for this shader and compiles it.
The QMetaEnum class provides meta-data about an enumerator.
Definition: qmetaobject.h:147
T * value(const QGLContext *context)
Definition: qgl_p.h:775
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static const char *const qglslCustomSrcFragmentShader
QGLEngineSharedShaders::SnippetName mainVertexShader
CompositionMode
Defines the modes supported for digital image compositing.
Definition: qpainter.h:138
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
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
QGLCustomShaderStage * customSrcStage
QByteArray & append(char c)
Appends the character ch to this byte array.
QGLEngineSharedShaders::SnippetName mainFragShader
QGLShaderProgram * blitProgram()
#define error(msg)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
T * take()
Returns the value of the pointer referenced by this object.
void setSrcPixelType(Qt::BrushStyle)
const char * valueToKey(int value) const
Returns the string that is used as the name of the given enumeration value, or 0 if value is not defi...
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
QGLShaderProgram * blitProgram()
void removeLast()
Removes the last item in the list.
Definition: qlist.h:287
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.
Definition: qlist.h:891
int uniformLocation(const char *name) const
Returns the location of the uniform variable name within this shader program&#39;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.
Definition: qstring.h:83
QGLEngineShaderProg * findProgramInCache(const QGLEngineShaderProg &prog)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static const char *const qglslRgbMaskFragmentShaderPass1
void setVertexAttribArrayEnabled(int arrayIndex, bool enabled=true)
Definition: qgl.cpp:2189
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)
Definition: qobject.cpp:1112
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.
Definition: qlist.h:628
Q_CORE_EXPORT void qDebug(const char *,...)
static const char *const qglslMainFragmentShader_O
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
TransformationType
Definition: qtransform.h:68
QGLEngineSharedShaders(const QGLContext *context)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static const char *const qglslShockingPinkSrcFragmentShader
static const char *const qglslPositionWithTextureBrushVertexShader
virtual void setUniforms(QGLShaderProgram *)
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
static const char *const qglslMainFragmentShader_C
const char * name
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.
Definition: qlist.h:468
QPainter::CompositionMode compositionMode
static const GLuint QT_PMV_MATRIX_2_ATTR
QList< QGLEngineShaderProg * > cachedPrograms
void setCompositionMode(QPainter::CompositionMode)
static const char *const qglslPositionOnlyVertexShader
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...
Definition: qstring.h:654
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.
Definition: qlist.h:764
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.
Definition: qvector.h:350
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 *,...)
bool isAffine() const
Returns true if the matrix represent an affine transformation, otherwise returns false.
Definition: qtransform.h:200
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...
Definition: qstring.cpp:4188
static const char *const qglslMainFragmentShader_CO
#define ctx
Definition: qgl.cpp:6094
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QString objectName() const
static const GLuint QT_TEXTURE_COORDS_ATTR
Definition: qnamespace.h:54
QGLShaderProgram * currentProgram()
QGLEngineSharedShaders * shadersForThread(const QGLContext *context)
static const char *const qglslRadialGradientBrushSrcFragmentShader
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.
Definition: qvector.h:139
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)
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...
Definition: qglobal.h:1729
static const char *const qglslMainVertexShader
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
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.
Definition: qlist.h:480