From 391441b2ce2be527db0829798631436670df0965 Mon Sep 17 00:00:00 2001 From: gunnar Date: Wed, 4 Nov 2009 19:38:01 +0100 Subject: Added some helpful info to QBrush and QPen's QDebug operators Reviewed-by: TrustMe --- src/gui/painting/qbrush.cpp | 24 +++++++++++++++++++++++- src/gui/painting/qpen.cpp | 12 +++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index cbfbba6..6f5d892 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -970,7 +970,29 @@ bool QBrush::operator==(const QBrush &b) const QDebug operator<<(QDebug dbg, const QBrush &b) { #ifndef Q_BROKEN_DEBUG_STREAM - dbg.nospace() << "QBrush(" << b.color() << ',' << b.style() << ')'; + char *BRUSH_STYLES[] = { + "NoBrush", + "SolidPattern", + "Dense1Pattern", + "Dense2Pattern", + "Dense3Pattern", + "Dense4Pattern", + "Dense5Pattern", + "Dense6Pattern", + "Dense7Pattern", + "HorPattern", + "VerPattern", + "CrossPattern", + "BDiagPattern", + "FDiagPattern", + "DiagCrossPattern", + "LinearGradientPattern", + "RadialGradientPattern", + "ConicalGradientPattern", + "TexturePattern" + }; + + dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')'; return dbg.space(); #else qWarning("This compiler doesn't support streaming QBrush to QDebug"); diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index 41efc80..9746747 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -983,8 +983,18 @@ QDataStream &operator>>(QDataStream &s, QPen &p) QDebug operator<<(QDebug dbg, const QPen &p) { #ifndef Q_BROKEN_DEBUG_STREAM + char *PEN_STYLES[] = { + "NoPen", + "SolidLine", + "DashLine", + "DotLine", + "DashDotLine", + "DashDotDotLine", + "CustomDashLine" + }; + dbg.nospace() << "QPen(" << p.width() << ',' << p.brush() - << ',' << int(p.style()) << ',' << int(p.capStyle()) + << ',' << PEN_STYLES[p.style()] << ',' << int(p.capStyle()) << ',' << int(p.joinStyle()) << ',' << p.dashPattern() << ',' << p.dashOffset() << ',' << p.miterLimit() << ')'; -- cgit v0.12 From 1a71e4b7960ba27fe6d47815da9337020085ac16 Mon Sep 17 00:00:00 2001 From: gunnar Date: Wed, 4 Nov 2009 21:02:10 +0100 Subject: Made QPen== catch QPen(Qt::NoPen) == QPen(QBrush(Qt::NoBrush)) QSvgDocument uses the latter as default pen so every svg filling command would issue a penChange without this. Reviewed-by: TrustMe --- src/gui/painting/qpen.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index 9746747..1ddadf2 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -835,16 +835,19 @@ bool QPen::operator==(const QPen &p) const { QPenData *dd = static_cast(d); QPenData *pdd = static_cast(p.d); - return (p.d == d) || (p.d->style == d->style - && p.d->capStyle == d->capStyle - && p.d->joinStyle == d->joinStyle - && p.d->width == d->width - && pdd->miterLimit == dd->miterLimit - && (d->style != Qt::CustomDashLine - || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && - pdd->dashPattern == dd->dashPattern)) - && p.d->brush == d->brush - && pdd->cosmetic == dd->cosmetic); + return (p.d == d) + || (p.d->style == d->style + && p.d->capStyle == d->capStyle + && p.d->joinStyle == d->joinStyle + && p.d->width == d->width + && pdd->miterLimit == dd->miterLimit + && (d->style != Qt::CustomDashLine + || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && + pdd->dashPattern == dd->dashPattern)) + && p.d->brush == d->brush + && pdd->cosmetic == dd->cosmetic) + || ((p.d->style == Qt::NoPen || p.d->brush.style() == Qt::NoBrush) + && (d->style == Qt::NoPen || d->brush.style() == Qt::NoBrush)); } -- cgit v0.12 From 23572588c4b0c759c14a6c1687e5bd86461e31e8 Mon Sep 17 00:00:00 2001 From: gunnar Date: Wed, 4 Nov 2009 21:06:29 +0100 Subject: Fixed some debug and some minor optims to QPaintBuffer Reviewed-by: TrustMe --- src/gui/painting/qpaintbuffer.cpp | 95 +++++++++++++++++++++++---------------- src/gui/painting/qpaintbuffer_p.h | 5 ++- 2 files changed, 60 insertions(+), 40 deletions(-) diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 6b9d77c..b8700c3 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -48,7 +48,7 @@ #include -//#define QPAINTBUFFER_DEBUG_DRAW +// #define QPAINTBUFFER_DEBUG_DRAW QT_BEGIN_NAMESPACE @@ -247,23 +247,24 @@ void QPaintBuffer::draw(QPainter *painter, int frame) const #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << "QPaintBuffer::draw() --------------------------------"; -// printf("Float buffer:"); -// for (int i=0; ifloats.size(); i++) { -// if ((i % 10) == 0) { -// printf("\n%4d-%4d: ", i, i+9); -// } -// printf("%4.2f ", d->floats[i]); -// } -// printf("\n"); - -// printf("Int Buffer:"); -// for (int i=0; iints.size(); i++) { -// if ((i % 10) == 0) { -// printf("\n%4d-%4d: ", i, i+10); -// } -// printf("%5d", d->ints[i]); -// } -// printf("\n"); + Q_D(const QPaintBuffer); + printf("Float buffer:"); + for (int i=0; ifloats.size(); i++) { + if ((i % 10) == 0) { + printf("\n%4d-%4d: ", i, i+9); + } + printf("%4.2f ", d->floats[i]); + } + printf("\n"); + + printf("Int Buffer:"); + for (int i=0; iints.size(); i++) { + if ((i % 10) == 0) { + printf("\n%4d-%4d: ", i, i+10); + } + printf("%5d", d->ints[i]); + } + printf("\n"); #endif if (painter && !painter->isActive()) @@ -406,16 +407,17 @@ void QPaintBufferEngine::clipEnabledChanged() void QPaintBufferEngine::penChanged() { -#ifdef QPAINTBUFFER_DEBUG_DRAW - qDebug() << "QPaintBufferEngine:" << state()->pen; -#endif const QPen &pen = state()->pen; if (!buffer->commands.isEmpty() && buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetPen) { +#ifdef QPAINTBUFFER_DEBUG_DRAW + qDebug() << "QPaintBufferEngine: penChanged (compressed)" << state()->pen; +#endif buffer->variants[buffer->commands.last().offset] = pen; return; } + if (buffer->calculateBoundingRect) { if (pen.style() == Qt::NoPen) { buffer->penWidthAdjustment = 0; @@ -427,22 +429,28 @@ void QPaintBufferEngine::penChanged() buffer->penWidthAdjustment = transformedWidth.x() / 2.0; } } +#ifdef QPAINTBUFFER_DEBUG_DRAW + qDebug() << "QPaintBufferEngine: penChanged" << state()->pen; +#endif buffer->addCommand(QPaintBufferPrivate::Cmd_SetPen, pen); } void QPaintBufferEngine::brushChanged() { -#ifdef QPAINTBUFFER_DEBUG_DRAW - qDebug() << "QPaintBufferEngine:" << state()->brush; -#endif const QBrush &brush = state()->brush; if (!buffer->commands.isEmpty() && buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetBrush) { +#ifdef QPAINTBUFFER_DEBUG_DRAW + qDebug() << "QPaintBufferEngine: brushChanged (compressed)" << state()->brush; +#endif buffer->variants[buffer->commands.last().offset] = brush; return; } +#ifdef QPAINTBUFFER_DEBUG_DRAW + qDebug() << "QPaintBufferEngine: brushChanged" << state()->brush; +#endif buffer->addCommand(QPaintBufferPrivate::Cmd_SetBrush, brush); } @@ -488,14 +496,14 @@ void QPaintBufferEngine::transformChanged() if (!buffer->commands.isEmpty() && buffer->commands.last().id == QPaintBufferPrivate::Cmd_SetTransform) { #ifdef QPAINTBUFFER_DEBUG_DRAW - qDebug() << "QPaintBufferEngine: compressing " << state()->matrix; + qDebug() << "QPaintBufferEngine: transformChanged (compressing) " << state()->matrix; #endif buffer->variants[buffer->commands.last().offset] = state()->matrix; return; } #ifdef QPAINTBUFFER_DEBUG_DRAW - qDebug() << "QPaintBufferEngine: " << state()->matrix; + qDebug() << "QPaintBufferEngine: transformChanged:" << state()->matrix; #endif buffer->addCommand(QPaintBufferPrivate::Cmd_SetTransform, state()->matrix); } @@ -514,7 +522,18 @@ void QPaintBufferEngine::draw(const QVectorPath &path) #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << "QPaintBufferEngine: draw vpath:" << path.elementCount(); #endif - buffer->addCommand(QPaintBufferPrivate::Cmd_DrawVectorPath, path); + + bool hasBrush = qbrush_style(state()->brush) != Qt::NoBrush; + bool hasPen = qpen_style(state()->pen) != Qt::NoPen + && qbrush_style(qpen_brush(state()->pen)) != Qt::NoBrush; + + if (hasPen || hasBrush) + buffer->addCommand(QPaintBufferPrivate::Cmd_DrawVectorPath, path); +#ifdef QPAINTBUFFER_DEBUG_DRAW + else + qDebug() << " - no pen or brush active, discarded...\n"; +#endif + // if (buffer->calculateBoundingRect) { // QRealRect r = path.controlPointRect(); // buffer->updateBoundingRect(QRectF(r.x1, r.y1, r.x2 - r.x1, r.y2 - r.y1)); @@ -745,15 +764,15 @@ void QPaintBufferEngine::drawEllipse(const QRect &r) void QPaintBufferEngine::drawPath(const QPainterPath &path) { -#ifdef QPAINTBUFFER_DEBUG_DRAW - qDebug() << "QPaintBufferEngine: drawPath: element count:" << path.elementCount(); -#endif - // ### Path -> QVariant - // buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPath, QVariant(path)); +// #ifdef QPAINTBUFFER_DEBUG_DRAW +// qDebug() << "QPaintBufferEngine: drawPath: element count:" << path.elementCount(); +// #endif +// // ### Path -> QVariant +// // buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPath, QVariant(path)); QPaintEngineEx::drawPath(path); - if (buffer->calculateBoundingRect) - buffer->updateBoundingRect(path.boundingRect()); +// if (buffer->calculateBoundingRect) +// buffer->updateBoundingRect(path.boundingRect()); } void QPaintBufferEngine::drawPoints(const QPoint *points, int pointCount) @@ -1424,10 +1443,6 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) QTextItemInt &ti = (*tiCopy)(); QString text(ti.text()); -#ifdef QPAINTBUFFER_DEBUG_DRAW - qDebug() << " -> Cmd_DrawTextItem:" << pos << " " << text << " " << scaleFactor; -#endif - QFont font(ti.font()); font.setUnderline(false); font.setStrikeOut(false); @@ -1439,6 +1454,10 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) justificationWidth = si.width.toReal(); qreal scaleFactor = font.d->dpi/qreal(qt_defaultDpiY()); +#ifdef QPAINTBUFFER_DEBUG_DRAW + qDebug() << " -> Cmd_DrawTextItem:" << pos << " " << text << " " << scaleFactor; +#endif + if (scaleFactor != 1.0) { QFont fnt(font); QFakeDevice fake; diff --git a/src/gui/painting/qpaintbuffer_p.h b/src/gui/painting/qpaintbuffer_p.h index 6a7ac73..adf0564 100644 --- a/src/gui/painting/qpaintbuffer_p.h +++ b/src/gui/painting/qpaintbuffer_p.h @@ -66,6 +66,7 @@ class QPaintBufferPlayback; class Q_GUI_EXPORT QPaintBuffer : public QPaintDevice { + Q_DECLARE_PRIVATE(QPaintBuffer); public: QPaintBuffer(); QPaintBuffer(const QPaintBuffer &other); @@ -311,7 +312,7 @@ public: virtual ~QPainterReplayer() { } void setupTransform(QPainter *painter); - void process(const QPaintBufferCommand &cmd); + virtual void process(const QPaintBufferCommand &cmd); void draw(const QPaintBuffer &buffer, QPainter *painter, int frame); protected: @@ -326,7 +327,7 @@ class Q_GUI_EXPORT QPaintEngineExReplayer : public QPainterReplayer public: QPaintEngineExReplayer() { } - void process(const QPaintBufferCommand &cmd); + virtual void process(const QPaintBufferCommand &cmd); }; class QPaintBufferEnginePrivate; -- cgit v0.12 From b91f1a2f749586014e8b28c6766015ff6ba62ee7 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 5 Nov 2009 10:25:12 +1000 Subject: Modify QGLShader and QGLShaderProgram in response to API review Reviewed-by: Sarah Smith --- demos/boxes/scene.cpp | 34 +-- .../snippets/code/src_opengl_qglshaderprogram.cpp | 15 +- examples/opengl/hellogl_es2/glwidget.cpp | 30 ++- examples/opengl/textures/glwidget.cpp | 12 +- .../gl2paintengineex/qglengineshadermanager.cpp | 26 +- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 4 +- src/opengl/qglshaderprogram.cpp | 298 ++++++++++++--------- src/opengl/qglshaderprogram.h | 43 +-- src/opengl/qwindowsurface_gl.cpp | 2 +- 9 files changed, 257 insertions(+), 207 deletions(-) diff --git a/demos/boxes/scene.cpp b/demos/boxes/scene.cpp index a06e8a1..06dc0f9 100644 --- a/demos/boxes/scene.cpp +++ b/demos/boxes/scene.cpp @@ -552,14 +552,15 @@ void Scene::initGL() { m_box = new GLRoundedBox(0.25f, 1.0f, 10); - m_vertexShader = new QGLShader(":/res/boxes/basic.vsh", QGLShader::VertexShader); + m_vertexShader = new QGLShader(QGLShader::Vertex); + m_vertexShader->compileSourceFile(QLatin1String(":/res/boxes/basic.vsh")); QStringList list; list << ":/res/boxes/cubemap_posx.jpg" << ":/res/boxes/cubemap_negx.jpg" << ":/res/boxes/cubemap_posy.jpg" << ":/res/boxes/cubemap_negy.jpg" << ":/res/boxes/cubemap_posz.jpg" << ":/res/boxes/cubemap_negz.jpg"; m_environment = new GLTextureCube(list, qMin(1024, m_maxTextureSize)); - m_environmentShader = new QGLShader(QGLShader::FragmentShader); - m_environmentShader->compile(environmentShaderText); + m_environmentShader = new QGLShader(QGLShader::Fragment); + m_environmentShader->compileSourceCode(environmentShaderText); m_environmentProgram = new QGLShaderProgram; m_environmentProgram->addShader(m_vertexShader); m_environmentProgram->addShader(m_environmentShader); @@ -616,7 +617,8 @@ void Scene::initGL() files = QDir(":/res/boxes/").entryInfoList(filter, QDir::Files | QDir::Readable); foreach (QFileInfo file, files) { QGLShaderProgram *program = new QGLShaderProgram; - QGLShader* shader = new QGLShader(file.absoluteFilePath(), QGLShader::FragmentShader); + QGLShader* shader = new QGLShader(QGLShader::Fragment); + shader->compileSourceFile(file.absoluteFilePath()); // The program does not take ownership over the shaders, so store them in a vector so they can be deleted afterwards. program->addShader(m_vertexShader); program->addShader(shader); @@ -638,9 +640,9 @@ void Scene::initGL() m_programs << program; m_renderOptions->addShader(file.baseName()); - program->enable(); + program->bind(); m_cubemaps << ((program->uniformLocation("env") != -1) ? new GLRenderTargetCube(qMin(256, m_maxTextureSize)) : 0); - program->disable(); + program->release(); } if (m_programs.size() == 0) @@ -697,12 +699,12 @@ void Scene::renderBoxes(const QMatrix4x4 &view, int excludeBox) // Don't render the environment if the environment texture can't be set for the correct sampler. if (glActiveTexture) { m_environment->bind(); - m_environmentProgram->enable(); + m_environmentProgram->bind(); m_environmentProgram->setUniformValue("tex", GLint(0)); m_environmentProgram->setUniformValue("env", GLint(1)); m_environmentProgram->setUniformValue("noise", GLint(2)); m_box->draw(); - m_environmentProgram->disable(); + m_environmentProgram->release(); m_environment->unbind(); } @@ -730,14 +732,14 @@ void Scene::renderBoxes(const QMatrix4x4 &view, int excludeBox) else m_environment->bind(); } - m_programs[i]->enable(); + m_programs[i]->bind(); m_programs[i]->setUniformValue("tex", GLint(0)); m_programs[i]->setUniformValue("env", GLint(1)); m_programs[i]->setUniformValue("noise", GLint(2)); m_programs[i]->setUniformValue("view", view); m_programs[i]->setUniformValue("invView", invView); m_box->draw(); - m_programs[i]->disable(); + m_programs[i]->release(); if (glActiveTexture) { if (m_dynamicCubemap && m_cubemaps[i]) @@ -760,14 +762,14 @@ void Scene::renderBoxes(const QMatrix4x4 &view, int excludeBox) m_environment->bind(); } - m_programs[m_currentShader]->enable(); + m_programs[m_currentShader]->bind(); m_programs[m_currentShader]->setUniformValue("tex", GLint(0)); m_programs[m_currentShader]->setUniformValue("env", GLint(1)); m_programs[m_currentShader]->setUniformValue("noise", GLint(2)); m_programs[m_currentShader]->setUniformValue("view", view); m_programs[m_currentShader]->setUniformValue("invView", invView); m_box->draw(); - m_programs[m_currentShader]->disable(); + m_programs[m_currentShader]->release(); if (glActiveTexture) { if (m_dynamicCubemap) @@ -1046,9 +1048,9 @@ void Scene::setColorParameter(const QString &name, QRgb color) { // set the color in all programs foreach (QGLShaderProgram *program, m_programs) { - program->enable(); + program->bind(); program->setUniformValue(program->uniformLocation(name), QColor(color)); - program->disable(); + program->release(); } } @@ -1056,9 +1058,9 @@ void Scene::setFloatParameter(const QString &name, float value) { // set the color in all programs foreach (QGLShaderProgram *program, m_programs) { - program->enable(); + program->bind(); program->setUniformValue(program->uniformLocation(name), value); - program->disable(); + program->release(); } } diff --git a/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp b/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp index 2997297..9a15f19 100644 --- a/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp +++ b/doc/src/snippets/code/src_opengl_qglshaderprogram.cpp @@ -40,32 +40,32 @@ ****************************************************************************/ //! [0] -QGLShader shader(QGLShader::VertexShader); -shader.compile(code); +QGLShader shader(QGLShader::Vertex); +shader.compileSourceCode(code); QGLShaderProgram program(context); program.addShader(shader); program.link(); -program.enable(); +program.bind(); //! [0] //! [1] -program.addShader(QGLShader::VertexShader, +program.addShaderFromSourceCode(QGLShader::Vertex, "attribute highp vec4 vertex;\n" "attribute mediump mat4 matrix;\n" "void main(void)\n" "{\n" " gl_Position = matrix * vertex;\n" "}"); -program.addShader(QGLShader::FragmentShader, +program.addShaderFromSourceCode(QGLShader::Fragment, "uniform mediump vec4 color;\n" "void main(void)\n" "{\n" " gl_FragColor = color;\n" "}"); program.link(); -program.enable(); +program.bind(); int vertexLocation = program.attributeLocation("vertex"); int matrixLocation = program.attributeLocation("matrix"); @@ -84,9 +84,12 @@ QColor color(0, 255, 0, 255); QMatrix4x4 pmvMatrix; pmvMatrix.ortho(rect()); +program.enableAttributeArray(vertexLocation); program.setAttributeArray(vertexLocation, triangleVertices, 3); program.setUniformValue(matrixLocation, pmvMatrix); program.setUniformValue(colorLocation, color); glDrawArrays(GL_TRIANGLES, 0, 3); + +program.disableAttributeArray(vertexLocation); //! [2] diff --git a/examples/opengl/hellogl_es2/glwidget.cpp b/examples/opengl/hellogl_es2/glwidget.cpp index a31c34a..08e887a 100644 --- a/examples/opengl/hellogl_es2/glwidget.cpp +++ b/examples/opengl/hellogl_es2/glwidget.cpp @@ -92,6 +92,8 @@ void GLWidget::showBubbles(bool bubbles) void GLWidget::paintQtLogo() { + program1.enableAttributeArray(normalAttr1); + program1.enableAttributeArray(vertexAttr1); program1.setAttributeArray(vertexAttr1, vertices.constData()); program1.setAttributeArray(normalAttr1, normals.constData()); glDrawArrays(GL_TRIANGLES, 0, vertices.size()); @@ -159,6 +161,10 @@ void GLWidget::paintTexturedCube() program2.setUniformValue(textureUniform2, 0); // use texture unit 0 + program2.enableAttributeArray(vertexAttr2); + program2.enableAttributeArray(normalAttr2); + program2.enableAttributeArray(texCoordAttr2); + glDrawArrays(GL_TRIANGLES, 0, 36); program2.disableAttributeArray(vertexAttr2); @@ -173,7 +179,7 @@ void GLWidget::initializeGL () glGenTextures(1, &m_uiTexture); m_uiTexture = bindTexture(QImage(":/qt.png")); - QGLShader *vshader1 = new QGLShader(QGLShader::VertexShader, this); + QGLShader *vshader1 = new QGLShader(QGLShader::Vertex, this); const char *vsrc1 = "attribute highp vec4 vertex;\n" "attribute mediump vec3 normal;\n" @@ -188,16 +194,16 @@ void GLWidget::initializeGL () " color = clamp(color, 0.0, 1.0);\n" " gl_Position = matrix * vertex;\n" "}\n"; - vshader1->compile(vsrc1); + vshader1->compileSourceCode(vsrc1); - QGLShader *fshader1 = new QGLShader(QGLShader::FragmentShader, this); + QGLShader *fshader1 = new QGLShader(QGLShader::Fragment, this); const char *fsrc1 = "varying mediump vec4 color;\n" "void main(void)\n" "{\n" " gl_FragColor = color;\n" "}\n"; - fshader1->compile(fsrc1); + fshader1->compileSourceCode(fsrc1); program1.addShader(vshader1); program1.addShader(fshader1); @@ -207,7 +213,7 @@ void GLWidget::initializeGL () normalAttr1 = program1.attributeLocation("normal"); matrixUniform1 = program1.uniformLocation("matrix"); - QGLShader *vshader2 = new QGLShader(QGLShader::VertexShader); + QGLShader *vshader2 = new QGLShader(QGLShader::Vertex); const char *vsrc2 = "attribute highp vec4 vertex;\n" "attribute highp vec4 texCoord;\n" @@ -222,9 +228,9 @@ void GLWidget::initializeGL () " gl_Position = matrix * vertex;\n" " texc = texCoord;\n" "}\n"; - vshader2->compile(vsrc2); + vshader2->compileSourceCode(vsrc2); - QGLShader *fshader2 = new QGLShader(QGLShader::FragmentShader); + QGLShader *fshader2 = new QGLShader(QGLShader::Fragment); const char *fsrc2 = "varying highp vec4 texc;\n" "uniform sampler2D tex;\n" @@ -235,7 +241,7 @@ void GLWidget::initializeGL () " color = color * 0.2 + color * 0.8 * angle;\n" " gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);\n" "}\n"; - fshader2->compile(fsrc2); + fshader2->compileSourceCode(fsrc2); program2.addShader(vshader2); program2.addShader(fshader2); @@ -284,15 +290,15 @@ void GLWidget::paintGL() modelview.translate(0.0f, -0.2f, 0.0f); if (qtLogo) { - program1.enable(); + program1.bind(); program1.setUniformValue(matrixUniform1, modelview); paintQtLogo(); - program1.disable(); + program1.release(); } else { - program2.enable(); + program2.bind(); program1.setUniformValue(matrixUniform2, modelview); paintTexturedCube(); - program2.disable(); + program2.release(); } glDisable(GL_DEPTH_TEST); diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp index 6efd31a..0f50e2d 100644 --- a/examples/opengl/textures/glwidget.cpp +++ b/examples/opengl/textures/glwidget.cpp @@ -99,7 +99,7 @@ void GLWidget::initializeGL() #define PROGRAM_VERTEX_ATTRIBUTE 0 #define PROGRAM_TEXCOORD_ATTRIBUTE 1 - QGLShader *vshader = new QGLShader(QGLShader::VertexShader, this); + QGLShader *vshader = new QGLShader(QGLShader::Vertex, this); const char *vsrc = "attribute highp vec4 vertex;\n" "attribute mediump vec4 texCoord;\n" @@ -110,9 +110,9 @@ void GLWidget::initializeGL() " gl_Position = matrix * vertex;\n" " texc = texCoord;\n" "}\n"; - vshader->compile(vsrc); + vshader->compileSourceCode(vsrc); - QGLShader *fshader = new QGLShader(QGLShader::FragmentShader, this); + QGLShader *fshader = new QGLShader(QGLShader::Fragment, this); const char *fsrc = "uniform sampler2D texture;\n" "varying mediump vec4 texc;\n" @@ -120,7 +120,7 @@ void GLWidget::initializeGL() "{\n" " gl_FragColor = texture2D(texture, texc.st);\n" "}\n"; - fshader->compile(fsrc); + fshader->compileSourceCode(fsrc); program = new QGLShaderProgram(this); program->addShader(vshader); @@ -129,7 +129,7 @@ void GLWidget::initializeGL() program->bindAttributeLocation("texCoord", PROGRAM_TEXCOORD_ATTRIBUTE); program->link(); - program->enable(); + program->bind(); program->setUniformValue("texture", 0); #endif @@ -163,6 +163,8 @@ void GLWidget::paintGL() m.rotate(zRot / 16.0f, 0.0f, 0.0f, 1.0f); program->setUniformValue("matrix", m); + program->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE); + program->enableAttributeArray(PROGRAM_TEXCOORD_ATTRIBUTE); program->setAttributeArray (PROGRAM_VERTEX_ATTRIBUTE, vertices.constData()); program->setAttributeArray diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 40a6241..8a8f483 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -169,14 +169,14 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) source.clear(); source.append(qShaderSnippets[MainVertexShader]); source.append(qShaderSnippets[PositionOnlyVertexShader]); - vertexShader = new QGLShader(QGLShader::VertexShader, context, this); - vertexShader->compile(source); + vertexShader = new QGLShader(QGLShader::Vertex, context, this); + vertexShader->compileSourceCode(source); source.clear(); source.append(qShaderSnippets[MainFragmentShader]); source.append(qShaderSnippets[ShockingPinkSrcFragmentShader]); - fragShader = new QGLShader(QGLShader::FragmentShader, context, this); - fragShader->compile(source); + fragShader = new QGLShader(QGLShader::Fragment, context, this); + fragShader->compileSourceCode(source); simpleShaderProg = new QGLShaderProgram(context, this); simpleShaderProg->addShader(vertexShader); @@ -192,14 +192,14 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) source.clear(); source.append(qShaderSnippets[MainWithTexCoordsVertexShader]); source.append(qShaderSnippets[UntransformedPositionVertexShader]); - vertexShader = new QGLShader(QGLShader::VertexShader, context, this); - vertexShader->compile(source); + vertexShader = new QGLShader(QGLShader::Vertex, context, this); + vertexShader->compileSourceCode(source); source.clear(); source.append(qShaderSnippets[MainFragmentShader]); source.append(qShaderSnippets[ImageSrcFragmentShader]); - fragShader = new QGLShader(QGLShader::FragmentShader, context, this); - fragShader->compile(source); + fragShader = new QGLShader(QGLShader::Fragment, context, this); + fragShader->compileSourceCode(source); blitShaderProg = new QGLShaderProgram(context, this); blitShaderProg->addShader(vertexShader); @@ -243,14 +243,14 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS source.append(qShaderSnippets[prog.compositionFragShader]); if (prog.maskFragShader) source.append(qShaderSnippets[prog.maskFragShader]); - QGLShader* fragShader = new QGLShader(QGLShader::FragmentShader, ctxGuard.context(), this); - fragShader->compile(source); + QGLShader* fragShader = new QGLShader(QGLShader::Fragment, ctxGuard.context(), this); + fragShader->compileSourceCode(source); source.clear(); source.append(qShaderSnippets[prog.mainVertexShader]); source.append(qShaderSnippets[prog.positionVertexShader]); - QGLShader* vertexShader = new QGLShader(QGLShader::VertexShader, ctxGuard.context(), this); - vertexShader->compile(source); + QGLShader* vertexShader = new QGLShader(QGLShader::Vertex, ctxGuard.context(), this); + vertexShader->compileSourceCode(source); #if defined(QT_DEBUG) // Name the shaders for easier debugging @@ -673,7 +673,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() currentShaderProg = sharedShaders->findProgramInCache(requiredProgram); if (currentShaderProg) { - currentShaderProg->program->enable(); + currentShaderProg->program->bind(); if (useCustomSrc) customSrcStage->setUniforms(currentShaderProg->program); } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index a9744b3..d20700f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -246,7 +246,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray); glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray); - pex->shaderManager->blitProgram()->enable(); + pex->shaderManager->blitProgram()->bind(); pex->shaderManager->blitProgram()->setUniformValue("imageTexture", QT_IMAGE_TEXTURE_UNIT); pex->shaderManager->setDirty(); @@ -395,7 +395,7 @@ void QGL2PaintEngineExPrivate::setBrush(const QBrush* brush) void QGL2PaintEngineExPrivate::useSimpleShader() { - shaderManager->simpleProgram()->enable(); + shaderManager->simpleProgram()->bind(); shaderManager->setDirty(); if (matrixDirty) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index e28c382..b4191dc 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE The following example creates a vertex shader program using the supplied source \c{code}. Once compiled and linked, the shader program is activated in the current QGLContext by calling - QGLShaderProgram::enable(): + QGLShaderProgram::bind(): \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 0 @@ -125,11 +125,11 @@ QT_BEGIN_NAMESPACE */ /*! - \enum QGLShader::ShaderTypeBits + \enum QGLShader::ShaderTypeBit This enum specifies the type of QGLShader that is being created. - \value VertexShader Vertex shader written in the OpenGL Shading Language (GLSL). - \value FragmentShader Fragment shader written in the OpenGL Shading Language (GLSL). + \value Vertex Vertex shader written in the OpenGL Shading Language (GLSL). + \value Fragment Fragment shader written in the OpenGL Shading Language (GLSL). */ #ifndef GL_FRAGMENT_SHADER @@ -211,7 +211,7 @@ bool QGLShaderPrivate::create() return false; if (qt_resolve_glsl_extensions(const_cast(context))) { GLuint shader; - if (shaderType == QGLShader::VertexShader) + if (shaderType == QGLShader::Vertex) shader = glCreateShader(GL_VERTEX_SHADER); else shader = glCreateShader(GL_FRAGMENT_SHADER); @@ -266,14 +266,14 @@ void QGLShaderPrivate::deleteShader() /*! Constructs a new QGLShader object of the specified \a type and attaches it to \a parent. If shader programs are not supported, - QGLShaderProgram::hasShaderPrograms() will return false. + QGLShaderProgram::hasOpenGLShaderPrograms() will return false. - This constructor is normally followed by a call to compile() - or compileFile(). + This constructor is normally followed by a call to compileSourceCode() + or compileSourceFile(). The shader will be associated with the current QGLContext. - \sa compile(), compileFile() + \sa compileSourceCode(), compileSourceFile() */ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent) @@ -283,45 +283,19 @@ QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) } /*! - Constructs a new QGLShader object of the specified \a type from the - source code in \a fileName and attaches it to \a parent. - If the shader could not be loaded, then isCompiled() will return false. - - The shader will be associated with the current QGLContext. - - \sa isCompiled() -*/ -QGLShader::QGLShader - (const QString& fileName, QGLShader::ShaderType type, QObject *parent) - : QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent) -{ - Q_D(QGLShader); - if (d->create() && !compileFile(fileName)) - d->deleteShader(); -} - -static inline const QGLContext *contextOrCurrent(const QGLContext *context) -{ - if (context) - return context; - else - return QGLContext::currentContext(); -} - -/*! Constructs a new QGLShader object of the specified \a type and attaches it to \a parent. If shader programs are not supported, - then QGLShaderProgram::hasShaderPrograms() will return false. + then QGLShaderProgram::hasOpenGLShaderPrograms() will return false. - This constructor is normally followed by a call to compile() - or compileFile(). + This constructor is normally followed by a call to compileSourceCode() + or compileSourceFile(). The shader will be associated with \a context. - \sa compile(), compileFile() + \sa compileSourceCode(), compileSourceFile() */ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent) - : QObject(*new QGLShaderPrivate(contextOrCurrent(context), type), parent) + : QObject(*new QGLShaderPrivate(context ? context : QGLContext::currentContext(), type), parent) { Q_D(QGLShader); #ifndef QT_NO_DEBUG @@ -334,30 +308,6 @@ QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObj } /*! - Constructs a new QGLShader object of the specified \a type from the - source code in \a fileName and attaches it to \a parent. - If the shader could not be loaded, then isCompiled() will return false. - - The shader will be associated with \a context. - - \sa isCompiled() -*/ -QGLShader::QGLShader - (const QString& fileName, QGLShader::ShaderType type, const QGLContext *context, QObject *parent) - : QObject(*new QGLShaderPrivate(contextOrCurrent(context), type), parent) -{ - Q_D(QGLShader); -#ifndef QT_NO_DEBUG - if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) { - qWarning("QGLShader::QGLShader: \'context\' must be current context or sharing with it."); - return; - } -#endif - if (d->create() && !compileFile(fileName)) - d->deleteShader(); -} - -/*! Deletes this shader. If the shader has been attached to a QGLShaderProgram object, then the actual shader will stay around until the QGLShaderProgram is destroyed. @@ -400,9 +350,9 @@ static const char redefineHighp[] = Sets the \a source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise. - \sa compileFile() + \sa compileSourceFile() */ -bool QGLShader::compile(const char *source) +bool QGLShader::compileSourceCode(const char *source) { Q_D(QGLShader); if (d->shaderGuard.id()) { @@ -431,7 +381,7 @@ bool QGLShader::compile(const char *source) srclen.append(GLint(sizeof(qualifierDefines) - 1)); #endif #ifdef QGL_REDEFINE_HIGHP - if (d->shaderType == FragmentShader) { + if (d->shaderType == Fragment) { src.append(redefineHighp); srclen.append(GLint(sizeof(redefineHighp) - 1)); } @@ -451,11 +401,11 @@ bool QGLShader::compile(const char *source) Sets the \a source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise. - \sa compileFile() + \sa compileSourceFile() */ -bool QGLShader::compile(const QByteArray& source) +bool QGLShader::compileSourceCode(const QByteArray& source) { - return compile(source.constData()); + return compileSourceCode(source.constData()); } /*! @@ -464,11 +414,11 @@ bool QGLShader::compile(const QByteArray& source) Sets the \a source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise. - \sa compileFile() + \sa compileSourceFile() */ -bool QGLShader::compile(const QString& source) +bool QGLShader::compileSourceCode(const QString& source) { - return compile(source.toLatin1().constData()); + return compileSourceCode(source.toLatin1().constData()); } /*! @@ -476,9 +426,9 @@ bool QGLShader::compile(const QString& source) and compiles it. Returns true if the file could be opened and the source compiled, false otherwise. - \sa compile() + \sa compileSourceCode() */ -bool QGLShader::compileFile(const QString& fileName) +bool QGLShader::compileSourceFile(const QString& fileName) { QFile file(fileName); if (!file.open(QFile::ReadOnly)) { @@ -487,13 +437,13 @@ bool QGLShader::compileFile(const QString& fileName) } QByteArray contents = file.readAll(); - return compile(contents.constData()); + return compileSourceCode(contents.constData()); } /*! Returns the source code for this shader. - \sa compile() + \sa compileSourceCode() */ QByteArray QGLShader::sourceCode() const { @@ -516,7 +466,7 @@ QByteArray QGLShader::sourceCode() const /*! Returns true if this shader has been compiled; false otherwise. - \sa compile() + \sa compileSourceCode(), compileSourceFile() */ bool QGLShader::isCompiled() const { @@ -527,7 +477,7 @@ bool QGLShader::isCompiled() const /*! Returns the errors and warnings that occurred during the last compile. - \sa compile() + \sa compileSourceCode(), compileSourceFile() */ QString QGLShader::log() const { @@ -666,6 +616,7 @@ bool QGLShaderProgram::init() is deleted. This allows the caller to add the same shader to multiple shader programs. + \sa addShaderFromSourceCode(), addShaderFromSourceFile() \sa removeShader(), link(), removeAllShaders() */ bool QGLShaderProgram::addShader(QGLShader *shader) @@ -705,15 +656,16 @@ bool QGLShaderProgram::addShader(QGLShader *shader) adding vertex and fragment shaders to a shader program without creating an instance of QGLShader first. + \sa addShader(), addShaderFromSourceFile() \sa removeShader(), link(), log(), removeAllShaders() */ -bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source) +bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const char *source) { Q_D(QGLShaderProgram); if (!init()) return false; QGLShader *shader = new QGLShader(type, this); - if (!shader->compile(source)) { + if (!shader->compileSourceCode(source)) { d->log = shader->log(); delete shader; return false; @@ -734,11 +686,12 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const char *source) adding vertex and fragment shaders to a shader program without creating an instance of QGLShader first. + \sa addShader(), addShaderFromSourceFile() \sa removeShader(), link(), log(), removeAllShaders() */ -bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QByteArray& source) +bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const QByteArray& source) { - return addShader(type, source.constData()); + return addShaderFromSourceCode(type, source.constData()); } /*! @@ -753,11 +706,12 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QByteArray& s adding vertex and fragment shaders to a shader program without creating an instance of QGLShader first. + \sa addShader(), addShaderFromSourceFile() \sa removeShader(), link(), log(), removeAllShaders() */ -bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QString& source) +bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const QString& source) { - return addShader(type, source.toLatin1().constData()); + return addShaderFromSourceCode(type, source.toLatin1().constData()); } /*! @@ -770,16 +724,16 @@ bool QGLShaderProgram::addShader(QGLShader::ShaderType type, const QString& sour adding vertex and fragment shaders to a shader program without creating an instance of QGLShader first. - \sa addShader() + \sa addShader(), addShaderFromSourceCode() */ -bool QGLShaderProgram::addShaderFromFile +bool QGLShaderProgram::addShaderFromSourceFile (QGLShader::ShaderType type, const QString& fileName) { Q_D(QGLShaderProgram); if (!init()) return false; QGLShader *shader = new QGLShader(type, this); - if (!shader->compileFile(fileName)) { + if (!shader->compileSourceFile(fileName)) { d->log = shader->log(); delete shader; return false; @@ -912,14 +866,16 @@ QString QGLShaderProgram::log() const } /*! - Enable use of this shader program in the currently active QGLContext. - Returns true if the program was successfully enabled; false - otherwise. If the shader program has not yet been linked, + Binds this shader program to the active QGLContext and makes + it the current shader program. Any previously bound shader program + is released. This is equivalent to calling \c{glUseProgram()} on + programId(). Returns true if the program was successfully bound; + false otherwise. If the shader program has not yet been linked, or it needs to be re-linked, this function will call link(). - \sa link(), disable() + \sa link(), release() */ -bool QGLShaderProgram::enable() +bool QGLShaderProgram::bind() { Q_D(QGLShaderProgram); GLuint program = d->programGuard.id(); @@ -927,6 +883,12 @@ bool QGLShaderProgram::enable() return false; if (!d->linked && !link()) return false; +#ifndef QT_NO_DEBUG + if (!QGLContext::areSharing(d->programGuard.context(), QGLContext::currentContext())) { + qWarning("QGLShaderProgram::bind: program is not valid in the current context."); + return false; + } +#endif glUseProgram(program); return true; } @@ -935,13 +897,18 @@ bool QGLShaderProgram::enable() #define ctx QGLContext::currentContext() /*! - Disables the active shader program in the current QGLContext. + Releases the active shader program from the current QGLContext. This is equivalent to calling \c{glUseProgram(0)}. - \sa enable() + \sa bind() */ -void QGLShaderProgram::disable() +void QGLShaderProgram::release() { +#ifndef QT_NO_DEBUG + Q_D(QGLShaderProgram); + if (!QGLContext::areSharing(d->programGuard.context(), QGLContext::currentContext())) + qWarning("QGLShaderProgram::release: program is not valid in the current context."); +#endif #if defined(QT_OPENGL_ES_2) glUseProgram(0); #else @@ -1331,22 +1298,26 @@ void QGLShaderProgram::setAttributeValue /*! Sets an array of vertex \a values on the attribute at \a location - in this shader program. The \a size indicates the number of + in this shader program. The \a tupleSize indicates the number of components per vertex (1, 2, 3, or 4), and the \a stride indicates the number of bytes between vertices. A default \a stride value of zero indicates that the vertices are densely packed in \a values. - \sa setAttributeValue(), setUniformValue(), disableAttributeArray() + The array will become active when enableAttributeArray() is called + on the \a location. Otherwise the value specified with + setAttributeValue() for \a location will be used. + + \sa setAttributeValue(), setUniformValue(), enableAttributeArray() + \sa disableAttributeArray() */ void QGLShaderProgram::setAttributeArray - (int location, const GLfloat *values, int size, int stride) + (int location, const GLfloat *values, int tupleSize, int stride) { Q_D(QGLShaderProgram); Q_UNUSED(d); if (location != -1) { - glVertexAttribPointer(location, size, GL_FLOAT, GL_FALSE, + glVertexAttribPointer(location, tupleSize, GL_FLOAT, GL_FALSE, stride, values); - glEnableVertexAttribArray(location); } } @@ -1356,7 +1327,12 @@ void QGLShaderProgram::setAttributeArray between vertices. A default \a stride value of zero indicates that the vertices are densely packed in \a values. - \sa setAttributeValue(), setUniformValue(), disableAttributeArray() + The array will become active when enableAttributeArray() is called + on the \a location. Otherwise the value specified with + setAttributeValue() for \a location will be used. + + \sa setAttributeValue(), setUniformValue(), enableAttributeArray() + \sa disableAttributeArray() */ void QGLShaderProgram::setAttributeArray (int location, const QVector2D *values, int stride) @@ -1366,7 +1342,6 @@ void QGLShaderProgram::setAttributeArray if (location != -1) { glVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, stride, values); - glEnableVertexAttribArray(location); } } @@ -1376,7 +1351,12 @@ void QGLShaderProgram::setAttributeArray between vertices. A default \a stride value of zero indicates that the vertices are densely packed in \a values. - \sa setAttributeValue(), setUniformValue(), disableAttributeArray() + The array will become active when enableAttributeArray() is called + on the \a location. Otherwise the value specified with + setAttributeValue() for \a location will be used. + + \sa setAttributeValue(), setUniformValue(), enableAttributeArray() + \sa disableAttributeArray() */ void QGLShaderProgram::setAttributeArray (int location, const QVector3D *values, int stride) @@ -1386,7 +1366,6 @@ void QGLShaderProgram::setAttributeArray if (location != -1) { glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE, stride, values); - glEnableVertexAttribArray(location); } } @@ -1396,7 +1375,12 @@ void QGLShaderProgram::setAttributeArray between vertices. A default \a stride value of zero indicates that the vertices are densely packed in \a values. - \sa setAttributeValue(), setUniformValue(), disableAttributeArray() + The array will become active when enableAttributeArray() is called + on the \a location. Otherwise the value specified with + setAttributeValue() for \a location will be used. + + \sa setAttributeValue(), setUniformValue(), enableAttributeArray() + \sa disableAttributeArray() */ void QGLShaderProgram::setAttributeArray (int location, const QVector4D *values, int stride) @@ -1406,7 +1390,6 @@ void QGLShaderProgram::setAttributeArray if (location != -1) { glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, stride, values); - glEnableVertexAttribArray(location); } } @@ -1414,17 +1397,22 @@ void QGLShaderProgram::setAttributeArray \overload Sets an array of vertex \a values on the attribute called \a name - in this shader program. The \a size indicates the number of + in this shader program. The \a tupleSize indicates the number of components per vertex (1, 2, 3, or 4), and the \a stride indicates the number of bytes between vertices. A default \a stride value of zero indicates that the vertices are densely packed in \a values. - \sa setAttributeValue(), setUniformValue(), disableAttributeArray() + The array will become active when enableAttributeArray() is called + on \a name. Otherwise the value specified with setAttributeValue() + for \a name will be used. + + \sa setAttributeValue(), setUniformValue(), enableAttributeArray() + \sa disableAttributeArray() */ void QGLShaderProgram::setAttributeArray - (const char *name, const GLfloat *values, int size, int stride) + (const char *name, const GLfloat *values, int tupleSize, int stride) { - setAttributeArray(attributeLocation(name), values, size, stride); + setAttributeArray(attributeLocation(name), values, tupleSize, stride); } /*! @@ -1435,7 +1423,12 @@ void QGLShaderProgram::setAttributeArray between vertices. A default \a stride value of zero indicates that the vertices are densely packed in \a values. - \sa setAttributeValue(), setUniformValue(), disableAttributeArray() + The array will become active when enableAttributeArray() is called + on \a name. Otherwise the value specified with setAttributeValue() + for \a name will be used. + + \sa setAttributeValue(), setUniformValue(), enableAttributeArray() + \sa disableAttributeArray() */ void QGLShaderProgram::setAttributeArray (const char *name, const QVector2D *values, int stride) @@ -1451,7 +1444,12 @@ void QGLShaderProgram::setAttributeArray between vertices. A default \a stride value of zero indicates that the vertices are densely packed in \a values. - \sa setAttributeValue(), setUniformValue(), disableAttributeArray() + The array will become active when enableAttributeArray() is called + on \a name. Otherwise the value specified with setAttributeValue() + for \a name will be used. + + \sa setAttributeValue(), setUniformValue(), enableAttributeArray() + \sa disableAttributeArray() */ void QGLShaderProgram::setAttributeArray (const char *name, const QVector3D *values, int stride) @@ -1467,7 +1465,12 @@ void QGLShaderProgram::setAttributeArray between vertices. A default \a stride value of zero indicates that the vertices are densely packed in \a values. - \sa setAttributeValue(), setUniformValue(), disableAttributeArray() + The array will become active when enableAttributeArray() is called + on \a name. Otherwise the value specified with setAttributeValue() + for \a name will be used. + + \sa setAttributeValue(), setUniformValue(), enableAttributeArray() + \sa disableAttributeArray() */ void QGLShaderProgram::setAttributeArray (const char *name, const QVector4D *values, int stride) @@ -1476,10 +1479,42 @@ void QGLShaderProgram::setAttributeArray } /*! + Enables the vertex array at \a location in this shader program + so that the value set by setAttributeArray() on \a location + will be used by the shader program. + + \sa disableAttributeArray(), setAttributeArray(), setAttributeValue() + \sa setUniformValue() +*/ +void QGLShaderProgram::enableAttributeArray(int location) +{ + Q_D(QGLShaderProgram); + Q_UNUSED(d); + if (location != -1) + glEnableVertexAttribArray(location); +} + +/*! + \overload + + Enables the vertex array called \a name in this shader program + so that the value set by setAttributeArray() on \a name + will be used by the shader program. + + \sa disableAttributeArray(), setAttributeArray(), setAttributeValue() + \sa setUniformValue() +*/ +void QGLShaderProgram::enableAttributeArray(const char *name) +{ + enableAttributeArray(attributeLocation(name)); +} + +/*! Disables the vertex array at \a location in this shader program - that was enabled by a previous call to setAttributeArray(). + that was enabled by a previous call to enableAttributeArray(). - \sa setAttributeArray(), setAttributeValue(), setUniformValue() + \sa enableAttributeArray(), setAttributeArray(), setAttributeValue() + \sa setUniformValue() */ void QGLShaderProgram::disableAttributeArray(int location) { @@ -1493,9 +1528,10 @@ void QGLShaderProgram::disableAttributeArray(int location) \overload Disables the vertex array called \a name in this shader program - that was enabled by a previous call to setAttributeArray(). + that was enabled by a previous call to enableAttributeArray(). - \sa setAttributeArray(), setAttributeValue(), setUniformValue() + \sa enableAttributeArray(), setAttributeArray(), setAttributeValue() + \sa setUniformValue() */ void QGLShaderProgram::disableAttributeArray(const char *name) { @@ -2363,25 +2399,25 @@ void QGLShaderProgram::setUniformValueArray /*! Sets the uniform variable array at \a location in the current context to the \a count elements of \a values. Each element - has \a size components. The \a size must be 1, 2, 3, or 4. + has \a tupleSize components. The \a tupleSize must be 1, 2, 3, or 4. \sa setAttributeValue() */ -void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int size) +void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize) { Q_D(QGLShaderProgram); Q_UNUSED(d); if (location != -1) { - if (size == 1) + if (tupleSize == 1) glUniform1fv(location, count, values); - else if (size == 2) + else if (tupleSize == 2) glUniform2fv(location, count, values); - else if (size == 3) + else if (tupleSize == 3) glUniform3fv(location, count, values); - else if (size == 4) + else if (tupleSize == 4) glUniform4fv(location, count, values); else - qWarning() << "QGLShaderProgram::setUniformValue: size" << size << "not supported"; + qWarning() << "QGLShaderProgram::setUniformValue: size" << tupleSize << "not supported"; } } @@ -2390,14 +2426,14 @@ void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, Sets the uniform variable array called \a name in the current context to the \a count elements of \a values. Each element - has \a size components. The \a size must be 1, 2, 3, or 4. + has \a tupleSize components. The \a tupleSize must be 1, 2, 3, or 4. \sa setAttributeValue() */ void QGLShaderProgram::setUniformValueArray - (const char *name, const GLfloat *values, int count, int size) + (const char *name, const GLfloat *values, int count, int tupleSize) { - setUniformValueArray(uniformLocation(name), values, count, size); + setUniformValueArray(uniformLocation(name), values, count, tupleSize); } /*! @@ -2800,7 +2836,7 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x4 * The \a context is used to resolve the GLSL extensions. If \a context is null, then QGLContext::currentContext() is used. */ -bool QGLShaderProgram::hasShaderPrograms(const QGLContext *context) +bool QGLShaderProgram::hasOpenGLShaderPrograms(const QGLContext *context) { #if !defined(QT_OPENGL_ES_2) if (!context) @@ -2825,8 +2861,6 @@ void QGLShaderProgram::shaderDestroyed() removeShader(shader); } -#endif - #ifdef Q_MAC_COMPAT_GL_FUNCTIONS /*! \internal */ void QGLShaderProgram::setUniformValue(int location, QMacCompatGLint value) @@ -2877,4 +2911,6 @@ void QGLShaderProgram::setUniformValueArray(const char *name, const QMacCompatGL } #endif +#endif // !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) + QT_END_NAMESPACE diff --git a/src/opengl/qglshaderprogram.h b/src/opengl/qglshaderprogram.h index 49c3364..deeaee2 100644 --- a/src/opengl/qglshaderprogram.h +++ b/src/opengl/qglshaderprogram.h @@ -63,25 +63,23 @@ class Q_OPENGL_EXPORT QGLShader : public QObject { Q_OBJECT public: - enum ShaderTypeBits + enum ShaderTypeBit { - VertexShader = 0x0001, - FragmentShader = 0x0002 + Vertex = 0x0001, + Fragment = 0x0002 }; - Q_DECLARE_FLAGS(ShaderType, ShaderTypeBits) + Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) explicit QGLShader(QGLShader::ShaderType type, QObject *parent = 0); - QGLShader(const QString& fileName, QGLShader::ShaderType type, QObject *parent = 0); QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent = 0); - QGLShader(const QString& fileName, QGLShader::ShaderType type, const QGLContext *context, QObject *parent = 0); virtual ~QGLShader(); QGLShader::ShaderType shaderType() const; - bool compile(const char *source); - bool compile(const QByteArray& source); - bool compile(const QString& source); - bool compileFile(const QString& fileName); + bool compileSourceCode(const char *source); + bool compileSourceCode(const QByteArray& source); + bool compileSourceCode(const QString& source); + bool compileSourceFile(const QString& fileName); QByteArray sourceCode() const; @@ -114,10 +112,10 @@ public: void removeShader(QGLShader *shader); QList shaders() const; - bool addShader(QGLShader::ShaderType type, const char *source); - bool addShader(QGLShader::ShaderType type, const QByteArray& source); - bool addShader(QGLShader::ShaderType type, const QString& source); - bool addShaderFromFile(QGLShader::ShaderType type, const QString& fileName); + bool addShaderFromSourceCode(QGLShader::ShaderType type, const char *source); + bool addShaderFromSourceCode(QGLShader::ShaderType type, const QByteArray& source); + bool addShaderFromSourceCode(QGLShader::ShaderType type, const QString& source); + bool addShaderFromSourceFile(QGLShader::ShaderType type, const QString& fileName); void removeAllShaders(); @@ -125,8 +123,8 @@ public: bool isLinked() const; QString log() const; - bool enable(); - static void disable(); + bool bind(); + void release(); GLuint programId() const; @@ -159,7 +157,7 @@ public: void setAttributeValue(const char *name, const GLfloat *values, int columns, int rows); void setAttributeArray - (int location, const GLfloat *values, int size, int stride = 0); + (int location, const GLfloat *values, int tupleSize, int stride = 0); void setAttributeArray (int location, const QVector2D *values, int stride = 0); void setAttributeArray @@ -167,13 +165,16 @@ public: void setAttributeArray (int location, const QVector4D *values, int stride = 0); void setAttributeArray - (const char *name, const GLfloat *values, int size, int stride = 0); + (const char *name, const GLfloat *values, int tupleSize, int stride = 0); void setAttributeArray (const char *name, const QVector2D *values, int stride = 0); void setAttributeArray (const char *name, const QVector3D *values, int stride = 0); void setAttributeArray (const char *name, const QVector4D *values, int stride = 0); + + void enableAttributeArray(int location); + void enableAttributeArray(const char *name); void disableAttributeArray(int location); void disableAttributeArray(const char *name); @@ -244,7 +245,7 @@ public: void setUniformValue(const char *name, const GLfloat value[4][4]); void setUniformValue(const char *name, const QTransform& value); - void setUniformValueArray(int location, const GLfloat *values, int count, int size); + void setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize); void setUniformValueArray(int location, const GLint *values, int count); void setUniformValueArray(int location, const GLuint *values, int count); void setUniformValueArray(int location, const QVector2D *values, int count); @@ -260,7 +261,7 @@ public: void setUniformValueArray(int location, const QMatrix4x3 *values, int count); void setUniformValueArray(int location, const QMatrix4x4 *values, int count); - void setUniformValueArray(const char *name, const GLfloat *values, int count, int size); + void setUniformValueArray(const char *name, const GLfloat *values, int count, int tupleSize); void setUniformValueArray(const char *name, const GLint *values, int count); void setUniformValueArray(const char *name, const GLuint *values, int count); void setUniformValueArray(const char *name, const QVector2D *values, int count); @@ -276,7 +277,7 @@ public: void setUniformValueArray(const char *name, const QMatrix4x3 *values, int count); void setUniformValueArray(const char *name, const QMatrix4x4 *values, int count); - static bool hasShaderPrograms(const QGLContext *context = 0); + static bool hasOpenGLShaderPrograms(const QGLContext *context = 0); private Q_SLOTS: void shaderDestroyed(); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index ebe101d..f1f5976 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -625,7 +625,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint & QGLShaderProgram *blitProgram = QGLEngineSharedShaders::shadersForContext(ctx)->blitProgram(); - blitProgram->enable(); + blitProgram->bind(); blitProgram->setUniformValue("imageTexture", 0 /*QT_IMAGE_TEXTURE_UNIT*/); // The shader manager's blit program does not multiply the -- cgit v0.12 From a12b1538df45268f2a66ec55856ffeeb131eb751 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 4 Nov 2009 15:57:33 +0100 Subject: Fixed soft-light composition mode in raster and OpenGL1. Updated the soft-light composition mode implementation in the raster and OpenGL1 engines to use the equations in the SVG specification as of April 2009. Task-number: QTBUG-3193 Reviewed-by: Trond --- src/gui/painting/qdrawhelper.cpp | 22 +- src/opengl/util/composition_mode_softlight.glsl | 24 +- src/opengl/util/fragmentprograms_p.h | 676 ++++++++++++------------ 3 files changed, 371 insertions(+), 351 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 41602a1..4df7f8a 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -2386,12 +2386,12 @@ static void QT_FASTCALL comp_func_HardLight(uint *dest, const uint *src, int len } /* - if 2.Sca < Sa - Dca' = Dca.(Sa - (1 - Dca/Da).(2.Sca - Sa)) + Sca.(1 - Da) + Dca.(1 - Sa) - otherwise if 8.Dca <= Da - Dca' = Dca.(Sa - (1 - Dca/Da).(2.Sca - Sa).(3 - 8.Dca/Da)) + Sca.(1 - Da) + Dca.(1 - Sa) - otherwise - Dca' = (Dca.Sa + ((Dca/Da)^(0.5).Da - Dca).(2.Sca - Sa)) + Sca.(1 - Da) + Dca.(1 - Sa) + if 2.Sca <= Sa + Dca' = Dca.(Sa + (2.Sca - Sa).(1 - Dca/Da)) + Sca.(1 - Da) + Dca.(1 - Sa) + otherwise if 2.Sca > Sa and 4.Dca <= Da + Dca' = Dca.Sa + Da.(2.Sca - Sa).(4.Dca/Da.(4.Dca/Da + 1).(Dca/Da - 1) + 7.Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa) + otherwise if 2.Sca > Sa and 4.Dca > Da + Dca' = Dca.Sa + Da.(2.Sca - Sa).((Dca/Da)^0.5 - Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa) */ static inline int soft_light_op(int dst, int src, int da, int sa) { @@ -2400,13 +2400,11 @@ static inline int soft_light_op(int dst, int src, int da, int sa) const int temp = (src * (255 - da) + dst * (255 - sa)) * 255; if (src2 < sa) - return (dst * ((sa * 255) - (255 - dst_np) * (src2 - sa)) + temp) / 65025; - else if (8 * dst <= da) - return (dst * ((sa * 255) - ((255 - dst_np) * (src2 - sa) * ((3 * 255) - 8 * dst_np)) / 255) + temp) / 65025; + return (dst * (sa * 255 + (src2 - sa) * (255 - dst_np)) + temp) / 65025; + else if (4 * dst <= da) + return (dst * sa * 255 + da * (src2 - sa) * ((((16 * dst_np - 12 * 255) * dst_np + 3 * 65025) * dst_np) / 65025) + temp) / 65025; else { - // sqrt is too expensive to do three times per pixel, so skipping it for now - // a future possibility is to use a LUT - return ((dst * sa * 255) + (int(dst_np) * da - (dst * 255)) * (src2 - sa) + temp) / 65025; + return (dst * sa * 255 + da * (src2 - sa) * (int(sqrt(qreal(dst_np * 255))) - dst_np) + temp) / 65025; } } diff --git a/src/opengl/util/composition_mode_softlight.glsl b/src/opengl/util/composition_mode_softlight.glsl index 4777b74..e4c1f89 100644 --- a/src/opengl/util/composition_mode_softlight.glsl +++ b/src/opengl/util/composition_mode_softlight.glsl @@ -1,18 +1,22 @@ -// Dca' = 2.Sca < Sa ? -// Dca.(Sa - (1 - Dca/Da).(2.Sca - Sa)) + Sca.(1 - Da) + Dca.(1 - Sa) : -// (8.Dca <= Da ? -// Dca.(Sa - (1 - Dca/Da).(2.Sca - Sa).(3 - 8.Dca/Da)) + Sca.(1 - Da) + Dca.(1 - Sa) : -// (Dca.Sa + ((Dca/Da)^(0.5).Da - Dca).(2.Sca - Sa)) + Sca.(1 - Da) + Dca.(1 - Sa)) +// if 2.Sca <= Sa +// Dca' = Dca.(Sa + (2.Sca - Sa).(1 - Dca/Da)) + Sca.(1 - Da) + Dca.(1 - Sa) +// otherwise if 2.Sca > Sa and 4.Dca <= Da +// Dca' = Dca.Sa + Da.(2.Sca - Sa).(4.Dca/Da.(4.Dca/Da + 1).(Dca/Da - 1) + 7.Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa) +// otherwise if 2.Sca > Sa and 4.Dca > Da +// Dca' = Dca.Sa + Da.(2.Sca - Sa).((Dca/Da)^0.5 - Dca/Da) + Sca.(1 - Da) + Dca.(1 - Sa) // Da' = Sa + Da - Sa.Da + vec4 composite(vec4 src, vec4 dst) { vec4 result; float da = max(dst.a, 0.00001); - result.rgb = mix(dst.rgb * (src.a - (1.0 - dst.rgb / da) * (2.0 * src.rgb - src.a)), - mix(dst.rgb * (src.a - (1.0 - dst.rgb / da) * (2.0 * src.rgb - src.a) * (3.0 - 8.0 * dst.rgb / da)), - (dst.rgb * src.a + (sqrt(dst.rgb / da) * dst.a - dst.rgb) * (2.0 * src.rgb - src.a)), - step(dst.a, 8.0 * dst.rgb)), - step(src.a, 2.0 * src.rgb)) + src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a); + vec3 dst_np = dst.rgb / da; + result.rgb = mix(dst.rgb * (src.a + (2.0 * src.rgb - src.a) * (1.0 - dst_np)), + mix(dst.rgb * src.a + dst.a * (2.0 * src.rgb - src.a) * ((16.0 * dst_np - 12.0) * dst_np + 3.0) * dst_np, + dst.rgb * src.a + dst.a * (2.0 * src.rgb - src.a) * (sqrt(dst_np) - dst_np), + step(dst.a, 4.0 * dst.rgb)), + step(src.a, 2.0 * src.rgb)) + + src.rgb * (1.0 - dst.a) + dst.rgb * (1.0 - src.a); result.a = src.a + dst.a - src.a * dst.a; return result; } diff --git a/src/opengl/util/fragmentprograms_p.h b/src/opengl/util/fragmentprograms_p.h index 9154c6e..2241057 100644 --- a/src/opengl/util/fragmentprograms_p.h +++ b/src/opengl/util/fragmentprograms_p.h @@ -519,8 +519,8 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_SOLID_COMPOSITION_MODE static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_SOLID_COMPOSITION_MODES_SOFTLIGHT = "!!ARBfp1.0\n" "PARAM c[6] = { program.local[0..3],\n" - " { 1, 2, 9.9999997e-006, 8 },\n" - " { 3 } };\n" + " { 1, 2, 9.9999997e-006, 4 },\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -530,30 +530,31 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_SOLID_COMPOSITION_MODE "MUL R0.xy, fragment.position, c[1];\n" "TEX R0, R0, texture[0], 2D;\n" "MAX R1.x, R0.w, c[4].z;\n" - "RCP R1.w, R1.x;\n" - "MUL R1.xyz, R0, R1.w;\n" - "MUL R4.xyz, -R1, c[4].w;\n" - "RSQ R2.x, R1.x;\n" - "RSQ R2.z, R1.z;\n" - "RSQ R2.y, R1.y;\n" - "MAD R1.xyz, -R0, R1.w, c[4].x;\n" - "RCP R2.x, R2.x;\n" - "RCP R2.z, R2.z;\n" - "RCP R2.y, R2.y;\n" - "MAD R3.xyz, R0.w, R2, -R0;\n" - "MAD R2.xyz, fragment.color.primary, c[4].y, -fragment.color.primary.w;\n" - "MUL R3.xyz, R2, R3;\n" - "ADD R5.xyz, R4, c[5].x;\n" - "MUL R4.xyz, R1, R2;\n" - "MAD R1.xyz, -R1, R2, fragment.color.primary.w;\n" + "RCP R1.x, R1.x;\n" + "MUL R2.xyz, R0, R1.x;\n" + "MAD R1.xyz, R2, c[5].x, -c[5].y;\n" + "MAD R3.xyz, R2, R1, c[5].z;\n" + "MAD R1.xyz, fragment.color.primary, c[4].y, -fragment.color.primary.w;\n" + "MUL R4.xyz, R0.w, R1;\n" + "MUL R5.xyz, R4, R3;\n" + "RSQ R1.w, R2.x;\n" + "RSQ R2.w, R2.z;\n" + "RCP R3.x, R1.w;\n" + "RSQ R1.w, R2.y;\n" + "MUL R5.xyz, R2, R5;\n" + "RCP R3.z, R2.w;\n" + "RCP R3.y, R1.w;\n" + "ADD R3.xyz, -R2, R3;\n" + "MUL R3.xyz, R4, R3;\n" + "ADD R2.xyz, -R2, c[4].x;\n" + "MAD R1.xyz, R1, R2, fragment.color.primary.w;\n" "MUL R2.xyz, fragment.color.primary, c[4].y;\n" - "MAD R5.xyz, -R4, R5, fragment.color.primary.w;\n" + "MAD R4.xyz, fragment.color.primary.w, R0, R5;\n" "MAD R3.xyz, fragment.color.primary.w, R0, R3;\n" - "MAD R4.xyz, -R0, R5, R3;\n" + "ADD R5.xyz, R3, -R4;\n" "MUL R3.xyz, R0, c[4].w;\n" - "MUL R5.xyz, R0, R5;\n" "SGE R3.xyz, R3, R0.w;\n" - "MAD R3.xyz, R3, R4, R5;\n" + "MAD R3.xyz, R3, R5, R4;\n" "MAD R3.xyz, -R0, R1, R3;\n" "MUL R1.xyz, R0, R1;\n" "SGE R2.xyz, R2, fragment.color.primary.w;\n" @@ -861,8 +862,8 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_SOLID_COMPOSITION_MODE static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_SOLID_COMPOSITION_MODES_SOFTLIGHT_NOMASK = "!!ARBfp1.0\n" "PARAM c[3] = { program.local[0],\n" - " { 1, 2, 9.9999997e-006, 8 },\n" - " { 3 } };\n" + " { 1, 2, 9.9999997e-006, 4 },\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -872,30 +873,31 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_SOLID_COMPOSITION_MODE "MUL R0.xy, fragment.position, c[0];\n" "TEX R0, R0, texture[0], 2D;\n" "MAX R1.x, R0.w, c[1].z;\n" - "RCP R1.w, R1.x;\n" - "MUL R1.xyz, R0, R1.w;\n" - "MUL R4.xyz, -R1, c[1].w;\n" - "RSQ R2.x, R1.x;\n" - "RSQ R2.z, R1.z;\n" - "RSQ R2.y, R1.y;\n" - "RCP R2.x, R2.x;\n" - "RCP R2.z, R2.z;\n" - "RCP R2.y, R2.y;\n" - "MAD R3.xyz, R0.w, R2, -R0;\n" - "MAD R2.xyz, fragment.color.primary, c[1].y, -fragment.color.primary.w;\n" - "MUL R3.xyz, R2, R3;\n" + "RCP R1.x, R1.x;\n" + "MUL R2.xyz, R0, R1.x;\n" + "MAD R1.xyz, R2, c[2].x, -c[2].y;\n" + "MAD R3.xyz, R2, R1, c[2].z;\n" + "MAD R1.xyz, fragment.color.primary, c[1].y, -fragment.color.primary.w;\n" + "MUL R4.xyz, R0.w, R1;\n" + "MUL R5.xyz, R4, R3;\n" + "RSQ R1.w, R2.x;\n" + "RCP R3.x, R1.w;\n" + "RSQ R2.w, R2.z;\n" + "RSQ R1.w, R2.y;\n" + "MUL R5.xyz, R2, R5;\n" + "RCP R3.z, R2.w;\n" + "RCP R3.y, R1.w;\n" + "ADD R3.xyz, -R2, R3;\n" + "MUL R3.xyz, R4, R3;\n" + "ADD R2.xyz, -R2, c[1].x;\n" + "MAD R1.xyz, R1, R2, fragment.color.primary.w;\n" + "MUL R2.xyz, fragment.color.primary, c[1].y;\n" + "MAD R4.xyz, fragment.color.primary.w, R0, R5;\n" "MAD R3.xyz, fragment.color.primary.w, R0, R3;\n" - "MAD R1.xyz, -R0, R1.w, c[1].x;\n" - "ADD R5.xyz, R4, c[2].x;\n" - "MUL R4.xyz, R1, R2;\n" - "MAD R1.xyz, -R1, R2, fragment.color.primary.w;\n" - "MAD R5.xyz, -R4, R5, fragment.color.primary.w;\n" - "MAD R4.xyz, -R0, R5, R3;\n" + "ADD R5.xyz, R3, -R4;\n" "MUL R3.xyz, R0, c[1].w;\n" - "MUL R2.xyz, fragment.color.primary, c[1].y;\n" - "MUL R5.xyz, R0, R5;\n" "SGE R3.xyz, R3, R0.w;\n" - "MAD R3.xyz, R3, R4, R5;\n" + "MAD R3.xyz, R3, R5, R4;\n" "MAD R3.xyz, -R0, R1, R3;\n" "MUL R1.xyz, R0, R1;\n" "SGE R2.xyz, R2, fragment.color.primary.w;\n" @@ -1457,7 +1459,7 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_RADIAL_COMPOSITION_MOD "!!ARBfp1.0\n" "PARAM c[11] = { program.local[0..8],\n" " { 2, 4, 1, 9.9999997e-006 },\n" - " { 8, 3 } };\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -1469,53 +1471,55 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_RADIAL_COMPOSITION_MOD "MAD R0.xyz, fragment.position.x, c[2], R0;\n" "ADD R0.xyz, R0, c[4];\n" "RCP R0.z, R0.z;\n" - "MUL R1.xy, fragment.position, c[6];\n" - "TEX R1, R1, texture[0], 2D;\n" - "MAX R0.w, R1, c[9];\n" - "RCP R2.w, R0.w;\n" - "MUL R5.xyz, R1, R2.w;\n" "MUL R0.xy, R0, R0.z;\n" "MUL R0.zw, R0.xyxy, R0.xyxy;\n" "ADD R0.z, R0, R0.w;\n" "MUL R0.xy, R0, c[0];\n" "ADD R0.x, R0, R0.y;\n" - "MUL R0.y, R0.x, c[9].x;\n" - "MOV R0.x, c[9];\n" - "RSQ R2.x, R5.x;\n" - "RSQ R2.z, R5.z;\n" - "RSQ R2.y, R5.y;\n" "MUL R0.z, -R0, c[1].x;\n" - "MUL R0.z, R0, c[9].y;\n" - "MAD R0.z, R0.y, R0.y, -R0;\n" - "MUL R0.w, R0.x, c[1].x;\n" - "RSQ R0.z, R0.z;\n" - "RCP R0.x, R0.z;\n" - "RCP R0.z, R0.w;\n" - "ADD R0.x, -R0.y, R0;\n" - "MUL R0.x, R0, R0.z;\n" + "MUL R0.y, R0.z, c[9];\n" + "MUL R0.x, R0, c[9];\n" + "MUL R0.zw, fragment.position.xyxy, c[6].xyxy;\n" + "TEX R1, R0.zwzw, texture[0], 2D;\n" + "MAD R0.y, R0.x, R0.x, -R0;\n" + "RSQ R0.y, R0.y;\n" + "RCP R0.y, R0.y;\n" + "ADD R0.y, -R0.x, R0;\n" + "MOV R0.x, c[9];\n" + "MUL R0.x, R0, c[1];\n" + "MAX R0.z, R1.w, c[9].w;\n" + "RCP R0.z, R0.z;\n" + "MUL R3.xyz, R1, R0.z;\n" + "MAD R4.xyz, R3, c[10].x, -c[10].y;\n" + "RCP R0.x, R0.x;\n" + "MUL R0.x, R0.y, R0;\n" "TEX R0, R0, texture[2], 1D;\n" - "MAD R3.xyz, R0, c[9].x, -R0.w;\n" - "MAD R6.xyz, -R5, c[10].x, c[10].y;\n" - "RCP R2.x, R2.x;\n" - "RCP R2.z, R2.z;\n" - "RCP R2.y, R2.y;\n" - "MAD R2.xyz, R1.w, R2, -R1;\n" - "MUL R2.xyz, R3, R2;\n" - "MAD R4.xyz, R0.w, R1, R2;\n" - "MAD R2.xyz, -R1, R2.w, c[9].z;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R6.xyz, -R5, R6, R0.w;\n" - "MAD R5.xyz, -R1, R6, R4;\n" - "MAD R2.xyz, -R2, R3, R0.w;\n" + "MAD R2.xyz, R0, c[9].x, -R0.w;\n" + "MAD R4.xyz, R3, R4, c[10].z;\n" + "MUL R5.xyz, R1.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[9].z;\n" + "MAD R2.xyz, R2, R3, R0.w;\n" "MUL R3.xyz, R0, c[9].x;\n" - "MUL R4.xyz, R1, c[10].x;\n" - "SGE R3.xyz, R3, R0.w;\n" - "ADD R2.w, -R1, c[9].z;\n" - "MUL R6.xyz, R1, R6;\n" + "MAD R5.xyz, R0.w, R1, R6;\n" + "MAD R4.xyz, R0.w, R1, R4;\n" + "ADD R6.xyz, R4, -R5;\n" + "MUL R4.xyz, R1, c[9].y;\n" "SGE R4.xyz, R4, R1.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R1, R2, R4;\n" + "SGE R3.xyz, R3, R0.w;\n" "MUL R2.xyz, R1, R2;\n" + "ADD R2.w, -R1, c[9].z;\n" "MAD R2.xyz, R3, R4, R2;\n" "MAD R2.xyz, R0, R2.w, R2;\n" "ADD R0.x, -R0.w, c[9].z;\n" @@ -2060,7 +2064,7 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_RADIAL_COMPOSITION_MOD "!!ARBfp1.0\n" "PARAM c[8] = { program.local[0..5],\n" " { 2, 4, 1, 9.9999997e-006 },\n" - " { 8, 3 } };\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -2072,49 +2076,51 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_RADIAL_COMPOSITION_MOD "MAD R0.xyz, fragment.position.x, c[2], R0;\n" "ADD R0.xyz, R0, c[4];\n" "RCP R0.z, R0.z;\n" - "MUL R1.xy, fragment.position, c[5];\n" - "TEX R1, R1, texture[0], 2D;\n" - "MAX R0.w, R1, c[6];\n" - "RCP R2.w, R0.w;\n" - "MUL R5.xyz, R1, R2.w;\n" "MUL R0.xy, R0, R0.z;\n" "MUL R0.zw, R0.xyxy, R0.xyxy;\n" "ADD R0.z, R0, R0.w;\n" "MUL R0.xy, R0, c[0];\n" "ADD R0.x, R0, R0.y;\n" - "MUL R0.y, R0.x, c[6].x;\n" - "MOV R0.x, c[6];\n" - "RSQ R2.x, R5.x;\n" - "RSQ R2.z, R5.z;\n" - "RSQ R2.y, R5.y;\n" "MUL R0.z, -R0, c[1].x;\n" - "MUL R0.z, R0, c[6].y;\n" - "MAD R0.z, R0.y, R0.y, -R0;\n" - "MUL R0.w, R0.x, c[1].x;\n" - "RSQ R0.z, R0.z;\n" - "RCP R0.x, R0.z;\n" - "RCP R0.z, R0.w;\n" - "ADD R0.x, -R0.y, R0;\n" - "MUL R0.x, R0, R0.z;\n" + "MUL R0.y, R0.z, c[6];\n" + "MUL R0.x, R0, c[6];\n" + "MUL R0.zw, fragment.position.xyxy, c[5].xyxy;\n" + "TEX R1, R0.zwzw, texture[0], 2D;\n" + "MAD R0.y, R0.x, R0.x, -R0;\n" + "RSQ R0.y, R0.y;\n" + "RCP R0.y, R0.y;\n" + "ADD R0.y, -R0.x, R0;\n" + "MOV R0.x, c[6];\n" + "MUL R0.x, R0, c[1];\n" + "MAX R0.z, R1.w, c[6].w;\n" + "RCP R0.z, R0.z;\n" + "MUL R3.xyz, R1, R0.z;\n" + "MAD R4.xyz, R3, c[7].x, -c[7].y;\n" + "RCP R0.x, R0.x;\n" + "MUL R0.x, R0.y, R0;\n" "TEX R0, R0, texture[1], 1D;\n" - "MAD R3.xyz, R0, c[6].x, -R0.w;\n" - "MAD R6.xyz, -R5, c[7].x, c[7].y;\n" - "RCP R2.x, R2.x;\n" - "RCP R2.z, R2.z;\n" - "RCP R2.y, R2.y;\n" - "MAD R2.xyz, R1.w, R2, -R1;\n" - "MUL R2.xyz, R3, R2;\n" - "MAD R4.xyz, R0.w, R1, R2;\n" - "MAD R2.xyz, -R1, R2.w, c[6].z;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R2.xyz, -R2, R3, R0.w;\n" - "MAD R6.xyz, -R5, R6, R0.w;\n" - "MAD R5.xyz, -R1, R6, R4;\n" + "MAD R2.xyz, R0, c[6].x, -R0.w;\n" + "MAD R4.xyz, R3, R4, c[7].z;\n" + "MUL R5.xyz, R1.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[6].z;\n" + "MAD R2.xyz, R2, R3, R0.w;\n" "MUL R3.xyz, R0, c[6].x;\n" - "MUL R4.xyz, R1, c[7].x;\n" - "MUL R6.xyz, R1, R6;\n" + "MAD R5.xyz, R0.w, R1, R6;\n" + "MAD R4.xyz, R0.w, R1, R4;\n" + "ADD R6.xyz, R4, -R5;\n" + "MUL R4.xyz, R1, c[6].y;\n" "SGE R4.xyz, R4, R1.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R1, R2, R4;\n" "MUL R2.xyz, R1, R2;\n" "SGE R3.xyz, R3, R0.w;\n" @@ -2899,11 +2905,12 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_CONICAL_COMPOSITION_MO static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_CONICAL_COMPOSITION_MODES_SOFTLIGHT = "!!ARBfp1.0\n" - "PARAM c[12] = { program.local[0..7],\n" + "PARAM c[13] = { program.local[0..7],\n" " { 0.0020000001, -0.01348047, 0.05747731, 0.1212391 },\n" " { 0.1956359, 0.33299461, 0.99999559, 1.570796 },\n" " { 3.141593, 0.15915494, 1, 2 },\n" - " { 9.9999997e-006, 8, 3 } };\n" + " { 9.9999997e-006, 4, 16, 12 },\n" + " { 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -2940,41 +2947,43 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_CONICAL_COMPOSITION_MO "ADD R0.w, -R0.z, c[10].x;\n" "CMP R0.x, R0, R0.w, R0.z;\n" "MUL R0.zw, fragment.position.xyxy, c[5].xyxy;\n" - "CMP R0.x, -R0.y, -R0, R0;\n" "TEX R1, R0.zwzw, texture[0], 2D;\n" - "MAX R0.y, R1.w, c[11].x;\n" - "RCP R2.w, R0.y;\n" - "MUL R5.xyz, R1, R2.w;\n" - "RSQ R2.x, R5.x;\n" - "RSQ R2.z, R5.z;\n" - "RSQ R2.y, R5.y;\n" + "CMP R0.x, -R0.y, -R0, R0;\n" + "MAX R0.z, R1.w, c[11].x;\n" + "RCP R2.x, R0.z;\n" + "MUL R3.xyz, R1, R2.x;\n" + "MAD R4.xyz, R3, c[11].z, -c[11].w;\n" "ADD R0.x, R0, c[0];\n" "MUL R0.x, R0, c[10].y;\n" "FLR R0.y, R0.x;\n" "ADD R0.x, R0, -R0.y;\n" "TEX R0, R0, texture[2], 1D;\n" - "MAD R3.xyz, R0, c[10].w, -R0.w;\n" - "MAD R6.xyz, -R5, c[11].y, c[11].z;\n" - "RCP R2.x, R2.x;\n" - "RCP R2.z, R2.z;\n" - "RCP R2.y, R2.y;\n" - "MAD R2.xyz, R1.w, R2, -R1;\n" - "MUL R2.xyz, R3, R2;\n" - "MAD R4.xyz, R0.w, R1, R2;\n" - "MAD R2.xyz, -R1, R2.w, c[10].z;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R6.xyz, -R5, R6, R0.w;\n" - "MAD R5.xyz, -R1, R6, R4;\n" - "MAD R2.xyz, -R2, R3, R0.w;\n" + "MAD R2.xyz, R0, c[10].w, -R0.w;\n" + "MAD R4.xyz, R3, R4, c[12].x;\n" + "MUL R5.xyz, R1.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[10].z;\n" + "MAD R2.xyz, R2, R3, R0.w;\n" "MUL R3.xyz, R0, c[10].w;\n" + "MAD R5.xyz, R0.w, R1, R6;\n" + "MAD R4.xyz, R0.w, R1, R4;\n" + "ADD R6.xyz, R4, -R5;\n" "MUL R4.xyz, R1, c[11].y;\n" - "SGE R3.xyz, R3, R0.w;\n" - "ADD R2.w, -R1, c[10].z;\n" - "MUL R6.xyz, R1, R6;\n" "SGE R4.xyz, R4, R1.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R1, R2, R4;\n" + "SGE R3.xyz, R3, R0.w;\n" "MUL R2.xyz, R1, R2;\n" + "ADD R2.w, -R1, c[10].z;\n" "MAD R2.xyz, R3, R4, R2;\n" "MAD R2.xyz, R0, R2.w, R2;\n" "ADD R0.x, -R0.w, c[10].z;\n" @@ -3682,11 +3691,12 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_CONICAL_COMPOSITION_MO static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_CONICAL_COMPOSITION_MODES_SOFTLIGHT_NOMASK = "!!ARBfp1.0\n" - "PARAM c[9] = { program.local[0..4],\n" + "PARAM c[10] = { program.local[0..4],\n" " { 0.0020000001, -0.01348047, 0.05747731, 0.1212391 },\n" " { 0.1956359, 0.33299461, 0.99999559, 1.570796 },\n" " { 3.141593, 0.15915494, 1, 2 },\n" - " { 9.9999997e-006, 8, 3 } };\n" + " { 9.9999997e-006, 4, 16, 12 },\n" + " { 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -3723,37 +3733,39 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_CONICAL_COMPOSITION_MO "ADD R0.w, -R0.z, c[7].x;\n" "CMP R0.x, R0, R0.w, R0.z;\n" "MUL R0.zw, fragment.position.xyxy, c[4].xyxy;\n" - "CMP R0.x, -R0.y, -R0, R0;\n" "TEX R1, R0.zwzw, texture[0], 2D;\n" - "MAX R0.y, R1.w, c[8].x;\n" - "RCP R2.w, R0.y;\n" - "MUL R5.xyz, R1, R2.w;\n" - "RSQ R2.x, R5.x;\n" - "RSQ R2.z, R5.z;\n" - "RSQ R2.y, R5.y;\n" + "CMP R0.x, -R0.y, -R0, R0;\n" + "MAX R0.z, R1.w, c[8].x;\n" + "RCP R2.x, R0.z;\n" + "MUL R3.xyz, R1, R2.x;\n" + "MAD R4.xyz, R3, c[8].z, -c[8].w;\n" "ADD R0.x, R0, c[0];\n" "MUL R0.x, R0, c[7].y;\n" "FLR R0.y, R0.x;\n" "ADD R0.x, R0, -R0.y;\n" "TEX R0, R0, texture[1], 1D;\n" - "MAD R3.xyz, R0, c[7].w, -R0.w;\n" - "MAD R6.xyz, -R5, c[8].y, c[8].z;\n" - "RCP R2.x, R2.x;\n" - "RCP R2.z, R2.z;\n" - "RCP R2.y, R2.y;\n" - "MAD R2.xyz, R1.w, R2, -R1;\n" - "MUL R2.xyz, R3, R2;\n" - "MAD R4.xyz, R0.w, R1, R2;\n" - "MAD R2.xyz, -R1, R2.w, c[7].z;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R2.xyz, -R2, R3, R0.w;\n" - "MAD R6.xyz, -R5, R6, R0.w;\n" - "MAD R5.xyz, -R1, R6, R4;\n" + "MAD R2.xyz, R0, c[7].w, -R0.w;\n" + "MAD R4.xyz, R3, R4, c[9].x;\n" + "MUL R5.xyz, R1.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[7].z;\n" + "MAD R2.xyz, R2, R3, R0.w;\n" "MUL R3.xyz, R0, c[7].w;\n" + "MAD R5.xyz, R0.w, R1, R6;\n" + "MAD R4.xyz, R0.w, R1, R4;\n" + "ADD R6.xyz, R4, -R5;\n" "MUL R4.xyz, R1, c[8].y;\n" - "MUL R6.xyz, R1, R6;\n" "SGE R4.xyz, R4, R1.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R1, R2, R4;\n" "MUL R2.xyz, R1, R2;\n" "SGE R3.xyz, R3, R0.w;\n" @@ -4356,8 +4368,8 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_LINEAR_COMPOSITION_MOD static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_LINEAR_COMPOSITION_MODES_SOFTLIGHT = "!!ARBfp1.0\n" "PARAM c[10] = { program.local[0..7],\n" - " { 1, 2, 9.9999997e-006, 8 },\n" - " { 3 } };\n" + " { 1, 2, 9.9999997e-006, 4 },\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -4365,13 +4377,6 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_LINEAR_COMPOSITION_MOD "TEMP R4;\n" "TEMP R5;\n" "TEMP R6;\n" - "MUL R0.xy, fragment.position, c[5];\n" - "TEX R1, R0, texture[0], 2D;\n" - "MAX R0.w, R1, c[8].z;\n" - "RCP R2.w, R0.w;\n" - "MUL R2.xyz, R1, R2.w;\n" - "RSQ R0.w, R2.x;\n" - "MUL R5.xyz, -R2, c[8].w;\n" "MUL R0.xyz, fragment.position.y, c[2];\n" "MAD R0.xyz, fragment.position.x, c[1], R0;\n" "ADD R0.xyz, R0, c[3];\n" @@ -4379,32 +4384,40 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_LINEAR_COMPOSITION_MOD "MUL R0.xy, R0, R0.z;\n" "MUL R0.xy, R0, c[0];\n" "ADD R0.x, R0, R0.y;\n" - "RSQ R0.z, R2.y;\n" - "RSQ R0.y, R2.z;\n" - "MAD R2.xyz, -R1, R2.w, c[8].x;\n" - "RCP R3.x, R0.w;\n" - "RCP R3.y, R0.z;\n" - "RCP R3.z, R0.y;\n" + "MUL R1.xy, fragment.position, c[5];\n" + "TEX R1, R1, texture[0], 2D;\n" + "MAX R0.z, R1.w, c[8];\n" + "RCP R0.z, R0.z;\n" + "MUL R3.xyz, R1, R0.z;\n" + "MAD R2.xyz, R3, c[9].x, -c[9].y;\n" "MUL R0.x, R0, c[0].z;\n" "TEX R0, R0, texture[2], 1D;\n" - "MAD R4.xyz, R1.w, R3, -R1;\n" - "MAD R3.xyz, R0, c[8].y, -R0.w;\n" - "MUL R4.xyz, R3, R4;\n" - "ADD R6.xyz, R5, c[9].x;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R2.xyz, -R2, R3, R0.w;\n" + "MAD R4.xyz, R3, R2, c[9].z;\n" + "MAD R2.xyz, R0, c[8].y, -R0.w;\n" + "MUL R5.xyz, R1.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[8].x;\n" + "MAD R2.xyz, R2, R3, R0.w;\n" "MUL R3.xyz, R0, c[8].y;\n" - "MAD R6.xyz, -R5, R6, R0.w;\n" + "MAD R5.xyz, R0.w, R1, R6;\n" "MAD R4.xyz, R0.w, R1, R4;\n" - "MAD R5.xyz, -R1, R6, R4;\n" + "ADD R6.xyz, R4, -R5;\n" "MUL R4.xyz, R1, c[8].w;\n" - "SGE R3.xyz, R3, R0.w;\n" - "ADD R2.w, -R1, c[8].x;\n" - "MUL R6.xyz, R1, R6;\n" "SGE R4.xyz, R4, R1.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R1, R2, R4;\n" + "SGE R3.xyz, R3, R0.w;\n" "MUL R2.xyz, R1, R2;\n" + "ADD R2.w, -R1, c[8].x;\n" "MAD R2.xyz, R3, R4, R2;\n" "MAD R2.xyz, R0, R2.w, R2;\n" "ADD R0.x, -R0.w, c[8];\n" @@ -4815,8 +4828,8 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_LINEAR_COMPOSITION_MOD static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_LINEAR_COMPOSITION_MODES_SOFTLIGHT_NOMASK = "!!ARBfp1.0\n" "PARAM c[7] = { program.local[0..4],\n" - " { 1, 2, 9.9999997e-006, 8 },\n" - " { 3 } };\n" + " { 1, 2, 9.9999997e-006, 4 },\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -4824,13 +4837,6 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_LINEAR_COMPOSITION_MOD "TEMP R4;\n" "TEMP R5;\n" "TEMP R6;\n" - "MUL R0.xy, fragment.position, c[4];\n" - "TEX R1, R0, texture[0], 2D;\n" - "MAX R0.w, R1, c[5].z;\n" - "RCP R2.w, R0.w;\n" - "MUL R2.xyz, R1, R2.w;\n" - "RSQ R0.w, R2.x;\n" - "MUL R5.xyz, -R2, c[5].w;\n" "MUL R0.xyz, fragment.position.y, c[2];\n" "MAD R0.xyz, fragment.position.x, c[1], R0;\n" "ADD R0.xyz, R0, c[3];\n" @@ -4838,28 +4844,36 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_LINEAR_COMPOSITION_MOD "MUL R0.xy, R0, R0.z;\n" "MUL R0.xy, R0, c[0];\n" "ADD R0.x, R0, R0.y;\n" - "RSQ R0.z, R2.y;\n" - "RSQ R0.y, R2.z;\n" - "MAD R2.xyz, -R1, R2.w, c[5].x;\n" - "RCP R3.x, R0.w;\n" - "RCP R3.y, R0.z;\n" - "RCP R3.z, R0.y;\n" + "MUL R1.xy, fragment.position, c[4];\n" + "TEX R1, R1, texture[0], 2D;\n" + "MAX R0.z, R1.w, c[5];\n" + "RCP R0.z, R0.z;\n" + "MUL R3.xyz, R1, R0.z;\n" + "MAD R2.xyz, R3, c[6].x, -c[6].y;\n" "MUL R0.x, R0, c[0].z;\n" "TEX R0, R0, texture[1], 1D;\n" - "MAD R4.xyz, R1.w, R3, -R1;\n" - "MAD R3.xyz, R0, c[5].y, -R0.w;\n" - "MUL R4.xyz, R3, R4;\n" - "ADD R6.xyz, R5, c[6].x;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R2.xyz, -R2, R3, R0.w;\n" + "MAD R4.xyz, R3, R2, c[6].z;\n" + "MAD R2.xyz, R0, c[5].y, -R0.w;\n" + "MUL R5.xyz, R1.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[5].x;\n" + "MAD R2.xyz, R2, R3, R0.w;\n" "MUL R3.xyz, R0, c[5].y;\n" - "MAD R6.xyz, -R5, R6, R0.w;\n" + "MAD R5.xyz, R0.w, R1, R6;\n" "MAD R4.xyz, R0.w, R1, R4;\n" - "MAD R5.xyz, -R1, R6, R4;\n" + "ADD R6.xyz, R4, -R5;\n" "MUL R4.xyz, R1, c[5].w;\n" - "MUL R6.xyz, R1, R6;\n" "SGE R4.xyz, R4, R1.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R1, R2, R4;\n" "MUL R2.xyz, R1, R2;\n" "SGE R3.xyz, R3, R0.w;\n" @@ -5333,8 +5347,8 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_TEXTURE_COMPOSITION_MO static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_TEXTURE_COMPOSITION_MODES_SOFTLIGHT = "!!ARBfp1.0\n" "PARAM c[10] = { program.local[0..7],\n" - " { 1, 2, 9.9999997e-006, 8 },\n" - " { 3 } };\n" + " { 1, 2, 9.9999997e-006, 4 },\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -5342,44 +5356,45 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_TEXTURE_COMPOSITION_MO "TEMP R4;\n" "TEMP R5;\n" "TEMP R6;\n" - "MUL R0.xy, fragment.position, c[5];\n" - "TEX R1, R0, texture[0], 2D;\n" - "MAX R0.x, R1.w, c[8].z;\n" - "RCP R2.w, R0.x;\n" - "MUL R2.xyz, R1, R2.w;\n" - "RSQ R0.w, R2.x;\n" - "RCP R3.x, R0.w;\n" - "RSQ R0.w, R2.y;\n" - "MUL R5.xyz, -R2, c[8].w;\n" "MUL R0.xyz, fragment.position.y, c[2];\n" + "MUL R1.xy, fragment.position, c[5];\n" + "TEX R1, R1, texture[0], 2D;\n" "MAD R0.xyz, fragment.position.x, c[1], R0;\n" "ADD R0.xyz, R0, c[3];\n" "RCP R0.z, R0.z;\n" "MUL R0.xy, R0, R0.z;\n" - "RSQ R0.z, R2.z;\n" - "MAD R2.xyz, -R1, R2.w, c[8].x;\n" - "RCP R3.y, R0.w;\n" - "RCP R3.z, R0.z;\n" + "MAX R0.w, R1, c[8].z;\n" + "RCP R0.w, R0.w;\n" + "MUL R3.xyz, R1, R0.w;\n" + "MAD R2.xyz, R3, c[9].x, -c[9].y;\n" "MUL R0.xy, R0, c[0];\n" "TEX R0, R0, texture[2], 2D;\n" - "MAD R4.xyz, R1.w, R3, -R1;\n" - "MAD R3.xyz, R0, c[8].y, -R0.w;\n" - "MUL R4.xyz, R3, R4;\n" - "ADD R6.xyz, R5, c[9].x;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R2.xyz, -R2, R3, R0.w;\n" + "MAD R4.xyz, R3, R2, c[9].z;\n" + "MAD R2.xyz, R0, c[8].y, -R0.w;\n" + "MUL R5.xyz, R1.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[8].x;\n" + "MAD R2.xyz, R2, R3, R0.w;\n" "MUL R3.xyz, R0, c[8].y;\n" - "MAD R6.xyz, -R5, R6, R0.w;\n" + "MAD R5.xyz, R0.w, R1, R6;\n" "MAD R4.xyz, R0.w, R1, R4;\n" - "MAD R5.xyz, -R1, R6, R4;\n" + "ADD R6.xyz, R4, -R5;\n" "MUL R4.xyz, R1, c[8].w;\n" - "SGE R3.xyz, R3, R0.w;\n" - "ADD R2.w, -R1, c[8].x;\n" - "MUL R6.xyz, R1, R6;\n" "SGE R4.xyz, R4, R1.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R1, R2, R4;\n" + "SGE R3.xyz, R3, R0.w;\n" "MUL R2.xyz, R1, R2;\n" + "ADD R2.w, -R1, c[8].x;\n" "MAD R2.xyz, R3, R4, R2;\n" "MAD R2.xyz, R0, R2.w, R2;\n" "ADD R0.x, -R0.w, c[8];\n" @@ -5768,8 +5783,8 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_TEXTURE_COMPOSITION_MO static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_TEXTURE_COMPOSITION_MODES_SOFTLIGHT_NOMASK = "!!ARBfp1.0\n" "PARAM c[7] = { program.local[0..4],\n" - " { 1, 2, 9.9999997e-006, 8 },\n" - " { 3 } };\n" + " { 1, 2, 9.9999997e-006, 4 },\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -5777,40 +5792,41 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_TEXTURE_COMPOSITION_MO "TEMP R4;\n" "TEMP R5;\n" "TEMP R6;\n" - "MUL R0.xy, fragment.position, c[4];\n" - "TEX R1, R0, texture[0], 2D;\n" - "MAX R0.x, R1.w, c[5].z;\n" - "RCP R2.w, R0.x;\n" - "MUL R2.xyz, R1, R2.w;\n" - "RSQ R0.w, R2.x;\n" - "RCP R3.x, R0.w;\n" - "RSQ R0.w, R2.y;\n" - "MUL R5.xyz, -R2, c[5].w;\n" "MUL R0.xyz, fragment.position.y, c[2];\n" + "MUL R1.xy, fragment.position, c[4];\n" + "TEX R1, R1, texture[0], 2D;\n" "MAD R0.xyz, fragment.position.x, c[1], R0;\n" "ADD R0.xyz, R0, c[3];\n" "RCP R0.z, R0.z;\n" "MUL R0.xy, R0, R0.z;\n" - "RSQ R0.z, R2.z;\n" - "MAD R2.xyz, -R1, R2.w, c[5].x;\n" - "RCP R3.y, R0.w;\n" - "RCP R3.z, R0.z;\n" + "MAX R0.w, R1, c[5].z;\n" + "RCP R0.w, R0.w;\n" + "MUL R3.xyz, R1, R0.w;\n" + "MAD R2.xyz, R3, c[6].x, -c[6].y;\n" "MUL R0.xy, R0, c[0];\n" "TEX R0, R0, texture[1], 2D;\n" - "MAD R4.xyz, R1.w, R3, -R1;\n" - "MAD R3.xyz, R0, c[5].y, -R0.w;\n" - "MUL R4.xyz, R3, R4;\n" - "ADD R6.xyz, R5, c[6].x;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R2.xyz, -R2, R3, R0.w;\n" + "MAD R4.xyz, R3, R2, c[6].z;\n" + "MAD R2.xyz, R0, c[5].y, -R0.w;\n" + "MUL R5.xyz, R1.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[5].x;\n" + "MAD R2.xyz, R2, R3, R0.w;\n" "MUL R3.xyz, R0, c[5].y;\n" - "MAD R6.xyz, -R5, R6, R0.w;\n" + "MAD R5.xyz, R0.w, R1, R6;\n" "MAD R4.xyz, R0.w, R1, R4;\n" - "MAD R5.xyz, -R1, R6, R4;\n" + "ADD R6.xyz, R4, -R5;\n" "MUL R4.xyz, R1, c[5].w;\n" - "MUL R6.xyz, R1, R6;\n" "SGE R4.xyz, R4, R1.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R1, R2, R4;\n" "MUL R2.xyz, R1, R2;\n" "SGE R3.xyz, R3, R0.w;\n" @@ -6295,8 +6311,8 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_PATTERN_COMPOSITION_MO static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_PATTERN_COMPOSITION_MODES_SOFTLIGHT = "!!ARBfp1.0\n" "PARAM c[10] = { program.local[0..7],\n" - " { 1, 2, 9.9999997e-006, 8 },\n" - " { 3 } };\n" + " { 1, 2, 9.9999997e-006, 4 },\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -6304,46 +6320,47 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_PATTERN_COMPOSITION_MO "TEMP R4;\n" "TEMP R5;\n" "TEMP R6;\n" - "MUL R0.xy, fragment.position, c[5];\n" - "TEX R0, R0, texture[0], 2D;\n" - "MAX R1.w, R0, c[8].z;\n" - "RCP R2.w, R1.w;\n" - "MUL R2.xyz, R0, R2.w;\n" - "RSQ R1.w, R2.x;\n" - "MUL R5.xyz, -R2, c[8].w;\n" - "MUL R1.xyz, fragment.position.y, c[2];\n" - "MAD R1.xyz, fragment.position.x, c[1], R1;\n" - "ADD R1.xyz, R1, c[3];\n" + "MUL R0.xyz, fragment.position.y, c[2];\n" + "MAD R0.xyz, fragment.position.x, c[1], R0;\n" + "ADD R1.xyz, R0, c[3];\n" "RCP R1.z, R1.z;\n" "MUL R1.xy, R1, R1.z;\n" "MUL R1.xy, R1, c[0];\n" "TEX R1.x, R1, texture[2], 2D;\n" - "RSQ R1.z, R2.y;\n" - "RSQ R1.y, R2.z;\n" - "MAD R2.xyz, -R0, R2.w, c[8].x;\n" - "RCP R3.x, R1.w;\n" - "RCP R3.y, R1.z;\n" - "RCP R3.z, R1.y;\n" + "MUL R0.xy, fragment.position, c[5];\n" + "TEX R0, R0, texture[0], 2D;\n" + "MAX R1.z, R0.w, c[8];\n" + "RCP R1.z, R1.z;\n" + "MUL R3.xyz, R0, R1.z;\n" + "MAD R2.xyz, R3, c[9].x, -c[9].y;\n" "ADD R1.x, -R1, c[8];\n" "MUL R1, fragment.color.primary, R1.x;\n" - "MAD R4.xyz, R0.w, R3, -R0;\n" - "MAD R3.xyz, R1, c[8].y, -R1.w;\n" - "MUL R4.xyz, R3, R4;\n" - "ADD R6.xyz, R5, c[9].x;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R2.xyz, -R2, R3, R1.w;\n" + "MAD R4.xyz, R3, R2, c[9].z;\n" + "MAD R2.xyz, R1, c[8].y, -R1.w;\n" + "MUL R5.xyz, R0.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[8].x;\n" + "MAD R2.xyz, R2, R3, R1.w;\n" "MUL R3.xyz, R1, c[8].y;\n" - "MAD R6.xyz, -R5, R6, R1.w;\n" + "MAD R5.xyz, R1.w, R0, R6;\n" "MAD R4.xyz, R1.w, R0, R4;\n" - "MAD R5.xyz, -R0, R6, R4;\n" + "ADD R6.xyz, R4, -R5;\n" "MUL R4.xyz, R0, c[8].w;\n" - "SGE R3.xyz, R3, R1.w;\n" - "ADD R2.w, -R0, c[8].x;\n" - "MUL R6.xyz, R0, R6;\n" "SGE R4.xyz, R4, R0.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R0, R2, R4;\n" + "SGE R3.xyz, R3, R1.w;\n" "MUL R2.xyz, R0, R2;\n" + "ADD R2.w, -R0, c[8].x;\n" "MAD R2.xyz, R3, R4, R2;\n" "MAD R2.xyz, R1, R2.w, R2;\n" "ADD R1.x, -R1.w, c[8];\n" @@ -6755,8 +6772,8 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_PATTERN_COMPOSITION_MO static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_PATTERN_COMPOSITION_MODES_SOFTLIGHT_NOMASK = "!!ARBfp1.0\n" "PARAM c[7] = { program.local[0..4],\n" - " { 1, 2, 9.9999997e-006, 8 },\n" - " { 3 } };\n" + " { 1, 2, 9.9999997e-006, 4 },\n" + " { 16, 12, 3 } };\n" "TEMP R0;\n" "TEMP R1;\n" "TEMP R2;\n" @@ -6764,42 +6781,43 @@ static const char *FragmentProgram_FRAGMENT_PROGRAM_BRUSH_PATTERN_COMPOSITION_MO "TEMP R4;\n" "TEMP R5;\n" "TEMP R6;\n" - "MUL R0.xy, fragment.position, c[4];\n" - "TEX R0, R0, texture[0], 2D;\n" - "MAX R1.w, R0, c[5].z;\n" - "RCP R2.w, R1.w;\n" - "MUL R2.xyz, R0, R2.w;\n" - "RSQ R1.w, R2.x;\n" - "MUL R5.xyz, -R2, c[5].w;\n" - "MUL R1.xyz, fragment.position.y, c[2];\n" - "MAD R1.xyz, fragment.position.x, c[1], R1;\n" - "ADD R1.xyz, R1, c[3];\n" + "MUL R0.xyz, fragment.position.y, c[2];\n" + "MAD R0.xyz, fragment.position.x, c[1], R0;\n" + "ADD R1.xyz, R0, c[3];\n" "RCP R1.z, R1.z;\n" "MUL R1.xy, R1, R1.z;\n" "MUL R1.xy, R1, c[0];\n" "TEX R1.x, R1, texture[1], 2D;\n" - "RSQ R1.z, R2.y;\n" - "RSQ R1.y, R2.z;\n" - "MAD R2.xyz, -R0, R2.w, c[5].x;\n" - "RCP R3.x, R1.w;\n" - "RCP R3.y, R1.z;\n" - "RCP R3.z, R1.y;\n" + "MUL R0.xy, fragment.position, c[4];\n" + "TEX R0, R0, texture[0], 2D;\n" + "MAX R1.z, R0.w, c[5];\n" + "RCP R1.z, R1.z;\n" + "MUL R3.xyz, R0, R1.z;\n" + "MAD R2.xyz, R3, c[6].x, -c[6].y;\n" "ADD R1.x, -R1, c[5];\n" "MUL R1, fragment.color.primary, R1.x;\n" - "MAD R4.xyz, R0.w, R3, -R0;\n" - "MAD R3.xyz, R1, c[5].y, -R1.w;\n" - "MUL R4.xyz, R3, R4;\n" - "ADD R6.xyz, R5, c[6].x;\n" - "MUL R5.xyz, R2, R3;\n" - "MAD R2.xyz, -R2, R3, R1.w;\n" + "MAD R4.xyz, R3, R2, c[6].z;\n" + "MAD R2.xyz, R1, c[5].y, -R1.w;\n" + "MUL R5.xyz, R0.w, R2;\n" + "MUL R6.xyz, R5, R4;\n" + "RSQ R2.w, R3.x;\n" + "RCP R4.x, R2.w;\n" + "RSQ R2.w, R3.y;\n" + "RSQ R3.w, R3.z;\n" + "RCP R4.y, R2.w;\n" + "RCP R4.z, R3.w;\n" + "ADD R4.xyz, -R3, R4;\n" + "MUL R6.xyz, R3, R6;\n" + "MUL R4.xyz, R5, R4;\n" + "ADD R3.xyz, -R3, c[5].x;\n" + "MAD R2.xyz, R2, R3, R1.w;\n" "MUL R3.xyz, R1, c[5].y;\n" - "MAD R6.xyz, -R5, R6, R1.w;\n" + "MAD R5.xyz, R1.w, R0, R6;\n" "MAD R4.xyz, R1.w, R0, R4;\n" - "MAD R5.xyz, -R0, R6, R4;\n" + "ADD R6.xyz, R4, -R5;\n" "MUL R4.xyz, R0, c[5].w;\n" - "MUL R6.xyz, R0, R6;\n" "SGE R4.xyz, R4, R0.w;\n" - "MAD R4.xyz, R4, R5, R6;\n" + "MAD R4.xyz, R4, R6, R5;\n" "MAD R4.xyz, -R0, R2, R4;\n" "MUL R2.xyz, R0, R2;\n" "SGE R3.xyz, R3, R1.w;\n" -- cgit v0.12 From ec13cf30f10dabce37af3ce9d6763066e8cf4cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 5 Nov 2009 11:21:31 +0100 Subject: Removed the FBO stacking behaviour and the test attached to it. Having this behaviour in QGLFrameBufferObject complicates alot of things and isn't really necessary. Reviewed-by: Tom Cooksey --- src/opengl/qglframebufferobject.cpp | 33 +++--------- src/opengl/qglframebufferobject_p.h | 4 +- tests/auto/qgl/tst_qgl.cpp | 105 ------------------------------------ 3 files changed, 9 insertions(+), 133 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 7374594..5295b6d 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -361,9 +361,6 @@ void QGLFBOGLPaintDevice::beginPaint() if (QGLContext::currentContext() != context()) context()->makeCurrent(); - // We let QFBO track the previously bound FBO rather than doing it - // ourselves here. This has the advantage that begin/release & bind/end - // work as expected. wasBound = fbo->isBound(); if (!wasBound) fbo->bind(); @@ -896,17 +893,11 @@ bool QGLFramebufferObject::bind() QGL_FUNC_CONTEXT; if (!ctx) return false; // Context no longer exists. + const QGLContext *current = QGLContext::currentContext(); glBindFramebuffer(GL_FRAMEBUFFER_EXT, d->fbo()); d->valid = d->checkFramebufferStatus(); - const QGLContext *context = QGLContext::currentContext(); - if (d->valid && context) { - Q_ASSERT(QGLContextPrivate::contextGroup(context) == QGLContextPrivate::contextGroup(ctx)); - // Save the previous setting to automatically restore in release(). - if (context->d_ptr->current_fbo != d->fbo()) { - d->previous_fbo = context->d_ptr->current_fbo; - context->d_ptr->current_fbo = d->fbo(); - } - } + if (d->valid && current) + current->d_ptr->current_fbo = d->fbo(); return d->valid; } @@ -917,30 +908,20 @@ bool QGLFramebufferObject::bind() framebuffer. Returns true upon success, false otherwise. - Since 4.6: if another QGLFramebufferObject instance was already bound - to the current context when bind() was called, then this function will - automatically re-bind it to the current context. - \sa bind() */ bool QGLFramebufferObject::release() { if (!isValid()) return false; - Q_D(QGLFramebufferObject); QGL_FUNC_CONTEXT; if (!ctx) return false; // Context no longer exists. - const QGLContext *context = QGLContext::currentContext(); - if (context) { - Q_ASSERT(QGLContextPrivate::contextGroup(context) == QGLContextPrivate::contextGroup(ctx)); - // Restore the previous setting for stacked framebuffer objects. - if (d->previous_fbo != context->d_ptr->current_fbo) { - context->d_ptr->current_fbo = d->previous_fbo; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, d->previous_fbo); - } - d->previous_fbo = 0; + const QGLContext *current = QGLContext::currentContext(); + if (current) { + current->d_ptr->current_fbo = 0; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); } return true; diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index 122c42e..c341459 100644 --- a/src/opengl/qglframebufferobject_p.h +++ b/src/opengl/qglframebufferobject_p.h @@ -127,7 +127,8 @@ private: class QGLFramebufferObjectPrivate { public: - QGLFramebufferObjectPrivate() : fbo_guard(0), texture(0), depth_stencil_buffer(0), color_buffer(0), valid(false), previous_fbo(0), engine(0) {} + QGLFramebufferObjectPrivate() : fbo_guard(0), texture(0), depth_stencil_buffer(0) + , color_buffer(0), valid(false), engine(0) {} ~QGLFramebufferObjectPrivate() {} void init(QGLFramebufferObject *q, const QSize& sz, @@ -143,7 +144,6 @@ public: QGLFramebufferObjectFormat format; uint valid : 1; QGLFramebufferObject::Attachment fbo_attachment; - GLuint previous_fbo; mutable QPaintEngine *engine; QGLFBOGLPaintDevice glDevice; diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index e9f0476..c680dec 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -82,7 +82,6 @@ private slots: void glPBufferRendering(); void glWidgetReparent(); void glWidgetRenderPixmap(); - void stackedFBOs(); void colormap(); void fboFormat(); void testDontCrashOnDanglingResources(); @@ -1226,110 +1225,6 @@ void tst_QGL::glWidgetRenderPixmap() QCOMPARE(fb, reference); } - -// When using multiple FBOs at the same time, unbinding one FBO should re-bind the -// previous. I.e. It should be possible to have a stack of FBOs where pop'ing there -// top re-binds the one underneeth. -void tst_QGL::stackedFBOs() -{ - if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) - QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); - - QGLWidget glw; - glw.show(); - -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&glw); -#endif - QTest::qWait(200); - - glw.makeCurrent(); - - // No multisample with combined depth/stencil attachment: - QGLFramebufferObjectFormat fboFormat; - fboFormat.setAttachment(QGLFramebufferObject::CombinedDepthStencil); - - // Don't complicate things by using NPOT: - QGLFramebufferObject *fbo1 = new QGLFramebufferObject(128, 128, fboFormat); - QGLFramebufferObject *fbo2 = new QGLFramebufferObject(128, 128, fboFormat); - QGLFramebufferObject *fbo3 = new QGLFramebufferObject(128, 128, fboFormat); - - glClearColor(1.0, 0.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - fbo1->bind(); - glClearColor(1.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - fbo2->bind(); - glClearColor(0.0, 1.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - fbo3->bind(); - glClearColor(0.0, 0.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - glScissor(32, 32, 64, 64); - glEnable(GL_SCISSOR_TEST); - glClearColor(0.0, 1.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - fbo3->release(); - - // Scissor rect & test should be left untouched by the fbo release... - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - fbo2->release(); - - glClearColor(1.0, 1.0, 1.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - fbo1->release(); - - glClearColor(1.0, 1.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - - glw.swapBuffers(); - - QImage widgetFB = glw.grabFrameBuffer(false).convertToFormat(QImage::Format_RGB32); - QImage fb1 = fbo1->toImage().convertToFormat(QImage::Format_RGB32); - QImage fb2 = fbo2->toImage().convertToFormat(QImage::Format_RGB32); - QImage fb3 = fbo3->toImage().convertToFormat(QImage::Format_RGB32); - - delete fbo1; - delete fbo2; - delete fbo3; - - QImage widgetReference(widgetFB.size(), widgetFB.format()); - QImage fb1Reference(fb1.size(), fb1.format()); - QImage fb2Reference(fb2.size(), fb2.format()); - QImage fb3Reference(fb3.size(), fb3.format()); - - QPainter widgetReferencePainter(&widgetReference); - QPainter fb1ReferencePainter(&fb1Reference); - QPainter fb2ReferencePainter(&fb2Reference); - QPainter fb3ReferencePainter(&fb3Reference); - - widgetReferencePainter.fillRect(0, 0, widgetReference.width(), widgetReference.height(), Qt::magenta); - fb1ReferencePainter.fillRect(0, 0, fb1Reference.width(), fb1Reference.height(), Qt::red); - fb2ReferencePainter.fillRect(0, 0, fb2Reference.width(), fb2Reference.height(), Qt::green); - fb3ReferencePainter.fillRect(0, 0, fb3Reference.width(), fb3Reference.height(), Qt::blue); - - // Flip y-coords to match GL for the widget (which can be any size) - widgetReferencePainter.fillRect(32, glw.height() - 96, 64, 64, Qt::yellow); - fb1ReferencePainter.fillRect(32, 32, 64, 64, Qt::white); - fb2ReferencePainter.fillRect(32, 32, 64, 64, Qt::black); - fb3ReferencePainter.fillRect(32, 32, 64, 64, Qt::cyan); - - widgetReferencePainter.end(); - fb1ReferencePainter.end(); - fb2ReferencePainter.end(); - fb3ReferencePainter.end(); - - QCOMPARE(widgetFB, widgetReference); - QCOMPARE(fb1, fb1Reference); - QCOMPARE(fb2, fb2Reference); - QCOMPARE(fb3, fb3Reference); -} - - class ColormapExtended : public QGLColormap { public: -- cgit v0.12 From d724b1708149ec8eac0d7f6ad44161d00c66c1b2 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 5 Nov 2009 13:24:58 +0100 Subject: Don't crash in QStateMachine when event transition listens to QApplication instance We can't assert on actually watching the watched object, since we may have installed an event filter on QApplication::instance(), in which case we will filter events for all objects. Reviewed-by: Gunnar --- src/corelib/statemachine/qstatemachine.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index cf951c9..ecf3f9c 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1616,9 +1616,8 @@ void QStateMachinePrivate::unregisterEventTransition(QEventTransition *transitio } void QStateMachinePrivate::handleFilteredEvent(QObject *watched, QEvent *event) -{ - Q_ASSERT(qobjectEvents.contains(watched)); - if (qobjectEvents[watched].contains(event->type())) { +{ + if (qobjectEvents.value(watched).contains(event->type())) { postInternalEvent(new QStateMachine::WrappedEvent(watched, handler->cloneEvent(event))); processEvents(DirectProcessing); } -- cgit v0.12 From d456ac11027f7573aa32745a8bc972d2b83926f4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 5 Nov 2009 14:17:56 +0100 Subject: Add test for QEventTransition when filtering on a QApplication instance Test for 8ec037effce7f515fffed6b05c011e385fb52593. Reviewed-by: Gunnar --- tests/auto/qstatemachine/tst_qstatemachine.cpp | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp index 9a2b2ed..fd39515 100644 --- a/tests/auto/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp @@ -208,6 +208,7 @@ private slots: void task260403_clonedSignals(); void postEventFromOtherThread(); + void eventFilterForApplication(); }; tst_QStateMachine::tst_QStateMachine() @@ -4276,5 +4277,35 @@ void tst_QStateMachine::postEventFromOtherThread() QTRY_COMPARE(finishedSpy.count(), 1); } +void tst_QStateMachine::eventFilterForApplication() +{ + QStateMachine machine; + + QState *s1 = new QState(&machine); + { + machine.setInitialState(s1); + } + + QState *s2 = new QState(&machine); + + QEventTransition *transition = new QEventTransition(QCoreApplication::instance(), + QEvent::ApplicationActivate); + transition->setTargetState(s2); + s1->addTransition(transition); + + machine.start(); + QCoreApplication::processEvents(); + + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s1)); + + QCoreApplication::postEvent(QCoreApplication::instance(), + new QEvent(QEvent::ApplicationActivate)); + QCoreApplication::processEvents(); + + QCOMPARE(machine.configuration().size(), 1); + QVERIFY(machine.configuration().contains(s2)); +} + QTEST_MAIN(tst_QStateMachine) #include "tst_qstatemachine.moc" -- cgit v0.12 From 9f86dcf0acaeba57728c3d51a1a6e57f8a8445b2 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 5 Nov 2009 14:07:05 +0100 Subject: Fixed crash in QPixmap::resize_helper on mac and x11 Reviewed-by: Trond --- src/gui/image/qpixmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index c452b9a..dfeea76 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -639,13 +639,13 @@ void QPixmap::resize_helper(const QSize &s) QPixmap pm(QSize(w, h), data ? data->type : QPixmapData::PixmapType); bool uninit = false; #if defined(Q_WS_X11) - QX11PixmapData *x11Data = data->classId() == QPixmapData::X11Class ? static_cast(data.data()) : 0; + QX11PixmapData *x11Data = data && data->classId() == QPixmapData::X11Class ? static_cast(data.data()) : 0; if (x11Data) { pm.x11SetScreen(x11Data->xinfo.screen()); uninit = x11Data->flags & QX11PixmapData::Uninitialized; } #elif defined(Q_WS_MAC) - QMacPixmapData *macData = data->classId() == QPixmapData::MacClass ? static_cast(data.data()) : 0; + QMacPixmapData *macData = data && data->classId() == QPixmapData::MacClass ? static_cast(data.data()) : 0; if (macData) uninit = macData->uninit; #endif -- cgit v0.12 From 83052dc7c7ddb8169e1e5607a2fb2f9c6097c6f0 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 5 Nov 2009 14:12:55 +0100 Subject: Remove unnessisary QGLFBOGLPaintDevice re-implementations Now QGLFBO doesn't do stacking, QGLPaintDevice's base implementation is ok to use. Reviewed-By: Trond --- src/opengl/qglframebufferobject.cpp | 30 ------------------------------ src/opengl/qglframebufferobject_p.h | 3 --- 2 files changed, 33 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 5295b6d..ddb107e 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -342,36 +342,6 @@ QGLContext *QGLFBOGLPaintDevice::context() const return fboContext; } -void QGLFBOGLPaintDevice::ensureActiveTarget() -{ - if (QGLContext::currentContext() != context()) - context()->makeCurrent(); - - QGLContext* ctx = const_cast(QGLContext::currentContext()); - Q_ASSERT(ctx); - const GLuint fboId = fbo->d_func()->fbo(); - if (ctx->d_func()->current_fbo != fboId) { - ctx->d_func()->current_fbo = fboId; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); - } -} - -void QGLFBOGLPaintDevice::beginPaint() -{ - if (QGLContext::currentContext() != context()) - context()->makeCurrent(); - - wasBound = fbo->isBound(); - if (!wasBound) - fbo->bind(); -} - -void QGLFBOGLPaintDevice::endPaint() -{ - if (!wasBound) - fbo->release(); -} - bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const { QGL_FUNCP_CONTEXT; diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index c341459..800cb68 100644 --- a/src/opengl/qglframebufferobject_p.h +++ b/src/opengl/qglframebufferobject_p.h @@ -111,9 +111,6 @@ public: virtual QSize size() const {return fbo->size();} virtual QGLContext* context() const; virtual QGLFormat format() const {return fboFormat;} - virtual void ensureActiveTarget(); - virtual void beginPaint(); - virtual void endPaint(); void setFBO(QGLFramebufferObject* f, QGLFramebufferObject::Attachment attachment); -- cgit v0.12 From 0818c05f22509a4ee9310f1d313460f422d9d32b Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 5 Nov 2009 14:14:52 +0100 Subject: Fix docs for QGLFramebufferObject & add warnings in bind/release Warnings are for binding/releasing when the current context isn't in the same context group as the FBO was created in. Reviewed-By: Trond --- src/opengl/qglframebufferobject.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index ddb107e..d79283e 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -846,13 +846,6 @@ bool QGLFramebufferObject::isValid() const framebuffer to this framebuffer object. Returns true upon success, false otherwise. - Since 4.6: if another QGLFramebufferObject instance was already bound - to the current context, then its handle() will be remembered and - automatically restored when release() is called. This allows multiple - framebuffer rendering targets to be stacked up. It is important that - release() is called on the stacked framebuffer objects in the reverse - order of the calls to bind(). - \sa release() */ bool QGLFramebufferObject::bind() @@ -864,6 +857,13 @@ bool QGLFramebufferObject::bind() if (!ctx) return false; // Context no longer exists. const QGLContext *current = QGLContext::currentContext(); +#ifdef QT_DEBUG + if (!current || + QGLContextPrivate::contextGroup(current) != QGLContextPrivate::contextGroup(ctx)) + { + qWarning("QGLFramebufferObject::bind() called from incompatible context"); + } +#endif glBindFramebuffer(GL_FRAMEBUFFER_EXT, d->fbo()); d->valid = d->checkFramebufferStatus(); if (d->valid && current) @@ -889,6 +889,15 @@ bool QGLFramebufferObject::release() return false; // Context no longer exists. const QGLContext *current = QGLContext::currentContext(); + +#ifdef QT_DEBUG + if (!current || + QGLContextPrivate::contextGroup(current) != QGLContextPrivate::contextGroup(ctx)) + { + qWarning("QGLFramebufferObject::release() called from incompatible context"); + } +#endif + if (current) { current->d_ptr->current_fbo = 0; glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); -- cgit v0.12 From 86388f7a5224da867ace47a41ed93982dfed7cfc Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 5 Nov 2009 14:58:43 +0100 Subject: Use fallback stroker for cosmetic strokes with asymetric transforms Reviewed-by: Samuel --- src/gui/painting/qtransform.cpp | 9 ++++++--- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 8118450..1bd5842 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -2214,12 +2214,14 @@ bool qt_scaleForTransform(const QTransform &transform, qreal *scale) { const QTransform::TransformationType type = transform.type(); if (type <= QTransform::TxTranslate) { - *scale = 1; + if (scale) + *scale = 1; return true; } else if (type == QTransform::TxScale) { const qreal xScale = qAbs(transform.m11()); const qreal yScale = qAbs(transform.m22()); - *scale = qMax(xScale, yScale); + if (scale) + *scale = qMax(xScale, yScale); return qFuzzyCompare(xScale, yScale); } @@ -2227,7 +2229,8 @@ bool qt_scaleForTransform(const QTransform &transform, qreal *scale) + transform.m21() * transform.m21(); const qreal yScale = transform.m12() * transform.m12() + transform.m22() * transform.m22(); - *scale = qSqrt(qMax(xScale, yScale)); + if (scale) + *scale = qSqrt(qMax(xScale, yScale)); return type == QTransform::TxRotate && qFuzzyCompare(xScale, yScale); } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index d20700f..1527e72 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1221,6 +1221,9 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) } } +extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale); // qtransform.cpp + + void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) { Q_D(QGL2PaintEngineEx); @@ -1231,6 +1234,11 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) return; QOpenGL2PaintEngineState *s = state(); + if (pen.isCosmetic() && !qt_scaleForTransform(s->transform(), 0)) { + // QTriangulatingStroker class is not meant to support cosmetically sheared strokes. + QPaintEngineEx::stroke(path, pen); + return; + } ensureActive(); -- cgit v0.12 From 089056a8ae16c740616dc2b443694af7ac1853f0 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 5 Nov 2009 15:17:15 +0100 Subject: Set strokes as non-convex by default. Reviewed-by: Samuel --- src/gui/painting/qpaintengineex.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 9e21182..1fb8aab 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -431,6 +431,10 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) // Some engines might decide to optimize for the non-shape hint later on... uint flags = QVectorPath::WindingFill; + + if (path.elementCount() > 2) + flags |= QVectorPath::NonConvexShapeMask; + if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin) flags |= QVectorPath::CurvedShapeMask; -- cgit v0.12 From 154f7142bc264866519257f2d4e62982671e3b12 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 5 Nov 2009 15:58:03 +0100 Subject: update harfbuzz to fix assamese shaping bug Synced harfbuzz to e66916e33821e71ba19479c32108a2be8bb539b2 Task-number: QTBUG-1802 Reviewed-by: Eskil --- src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp | 6 ++++-- src/3rdparty/harfbuzz/tests/shaping/main.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp index 48f4f90..df447e6 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp @@ -566,7 +566,7 @@ static const unsigned char indicPosition[0xe00-0x900] = { None, None, None, None, None, None, None, None, - None, None, None, None, + Below, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, @@ -1252,7 +1252,9 @@ static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool inv // farther than 3 consonants from the end of the syllable. // #### replace the HasReph property by testing if the feature exists in the font! if (form(*uc) == Consonant || (script == HB_Script_Bengali && form(*uc) == IndependentVowel)) { - beginsWithRa = (properties & HasReph) && ((len > 2) && *uc == ra && *(uc+1) == halant); + if ((properties & HasReph) && (len > 2) && + (*uc == ra || *uc == 0x9f0) && *(uc+1) == halant) + beginsWithRa = true; if (beginsWithRa && form(*(uc+2)) == Control) beginsWithRa = false; diff --git a/src/3rdparty/harfbuzz/tests/shaping/main.cpp b/src/3rdparty/harfbuzz/tests/shaping/main.cpp index a7ea417..9b6aa31 100644 --- a/src/3rdparty/harfbuzz/tests/shaping/main.cpp +++ b/src/3rdparty/harfbuzz/tests/shaping/main.cpp @@ -515,6 +515,12 @@ void tst_QScriptEngine::bengali() { 0x179, 0x151, 0x172, 0x0 } }, { { 0x995, 0x9c7, 0x9d7, 0x0 }, { 0x179, 0x151, 0x17e, 0x0 } }, + { { 0x9b0, 0x9cd, 0x9ad, 0x0 }, + { 0x168, 0x276, 0x0 } }, + { { 0x9f0, 0x9cd, 0x9ad, 0x0 }, + { 0x168, 0x276, 0x0 } }, + { { 0x9f1, 0x9cd, 0x9ad, 0x0 }, + { 0x191, 0x17d, 0x168, 0x0 } }, { {0}, {0} } }; @@ -652,6 +658,12 @@ void tst_QScriptEngine::bengali() { 0x01fe, 0x0 } }, { { 0x09b0, 0x09cd, 0x09a8, 0x09cd, 0x200d, 0x0 }, { 0x10b, 0x167, 0x0 } }, + { { 0x9b0, 0x9cd, 0x9ad, 0x0 }, + { 0xa1, 0x167, 0x0 } }, + { { 0x9f0, 0x9cd, 0x9ad, 0x0 }, + { 0xa1, 0x167, 0x0 } }, + { { 0x9f1, 0x9cd, 0x9ad, 0x0 }, + { 0x11c, 0xa1, 0x0 } }, { {0}, {0} } }; -- cgit v0.12 From f7b457e3d72b412b1d5ce080a40f290ab9bf46ab Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 5 Nov 2009 16:32:38 +0100 Subject: Fix a bug in malayalam rendering Updated to harfbuzz e6636cadacf220785fca12b741b4587ff1ee42ec. Fixes a bug with the rendering of samvruthokaram (combination of 0xd41 + 0xd4d) in malayalam. Task-number: Parts of QTBUG-1887 Reviewed-by: Eskil --- src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp | 4 ++++ src/3rdparty/harfbuzz/tests/shaping/main.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp index df447e6..3008fca 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp @@ -1746,6 +1746,10 @@ static int indic_nextSyllableBoundary(HB_Script script, const HB_UChar16 *s, int ++pos; continue; } + if (script == HB_Script_Malayalam && state == Matra && uc[pos-1] == 0x0d41) { + ++pos; + continue; + } goto finish; case Nukta: if (state == Consonant) diff --git a/src/3rdparty/harfbuzz/tests/shaping/main.cpp b/src/3rdparty/harfbuzz/tests/shaping/main.cpp index 9b6aa31..41f2dbb 100644 --- a/src/3rdparty/harfbuzz/tests/shaping/main.cpp +++ b/src/3rdparty/harfbuzz/tests/shaping/main.cpp @@ -979,6 +979,8 @@ void tst_QScriptEngine::malayalam() { 0x5e, 0x34, 0x65, 0x0 } }, { { 0xd15, 0xd57, 0x0 }, { 0x34, 0x65, 0x0 } }, + { { 0xd1f, 0xd4d, 0xd1f, 0xd41, 0xd4d, 0x0 }, + { 0x69, 0x5b, 0x64, 0x0 } }, { {0}, {0} } }; -- cgit v0.12 From c4f5a858edbe764f1e899b6c5201a61982e13061 Mon Sep 17 00:00:00 2001 From: gunnar Date: Thu, 5 Nov 2009 19:53:55 +0100 Subject: Fixed warning in lance on printf with wrong types Reviewed-by: TrustMe --- tests/arthur/common/paintcommands.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index 475f07d..44deb0e 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -974,7 +974,7 @@ void PaintCommands::command_drawPixmap(QRegExp re) if (sh == 0) sh = -1; if (m_verboseMode) - printf(" -(lance) drawPixmap('%s' dim=(%d, %d), depth=%d, (%d, %d, %d, %d), (%d, %d, %d, %d)\n", + printf(" -(lance) drawPixmap('%s' dim=(%d, %d), depth=%d, (%f, %f, %f, %f), (%f, %f, %f, %f)\n", qPrintable(re.cap(1)), pm.width(), pm.height(), pm.depth(), tx, ty, tw, th, sx, sy, sw, sh); @@ -1022,7 +1022,7 @@ void PaintCommands::command_drawImage(QRegExp re) if (sh == 0) sh = -1; if (m_verboseMode) - printf(" -(lance) drawImage('%s' dim=(%d, %d), (%d, %d, %d, %d), (%d, %d, %d, %d)\n", + printf(" -(lance) drawImage('%s' dim=(%d, %d), (%f, %f, %f, %f), (%f, %f, %f, %f)\n", qPrintable(re.cap(1)), im.width(), im.height(), tx, ty, tw, th, sx, sy, sw, sh); m_painter->drawImage(QRectF(tx, ty, tw, th), im, QRectF(sx, sy, sw, sh), Qt::OrderedDither | Qt::OrderedAlphaDither); -- cgit v0.12 From b185b901ea31bfdc2db781e271132d34d0e8ce32 Mon Sep 17 00:00:00 2001 From: gunnar Date: Thu, 5 Nov 2009 19:55:15 +0100 Subject: Fixed bad joins in the new stroker... Normal generation was broken. Reviewed-by: Trustme --- src/opengl/gl2paintengineex/qtriangulatingstroker_p.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index 97eabef..defa3f1 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -129,9 +129,9 @@ inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, fl float pw; if (dx == 0) - pw = m_width / dy; + pw = m_width / qAbs(dy); else if (dy == 0) - pw = m_width / dx; + pw = m_width / qAbs(dx); else pw = m_width / sqrt(dx*dx + dy*dy); @@ -259,8 +259,6 @@ void QTriangulatingStroker::lineTo(const qreal *pts) - - void QTriangulatingStroker::join(const qreal *pts) { // Creates a join to the next segment (m_cx, m_cy) -> (pts[0], pts[1]) -- cgit v0.12 From 13cd3c7a8975fc6dc72719b5a78d55159ab777a3 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 6 Nov 2009 07:56:56 +0100 Subject: fix painting on Windows CE it seems the timer id ~0 is already used on windows ce or not available at all. This has caused Qt to not receive the timer messages, causing to not update. Task-number: qtbug-5496 Reviewed-by: Gunnar Sletta --- src/corelib/kernel/qeventdispatcher_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index d13e1d1..bce52c6 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -470,7 +470,7 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) } return 0; } else if (message == WM_TIMER) { - if (wp == ~0u) { + if (wp == ~1u) { KillTimer(d->internalHwnd, wp); int localSerialNumber = d->serialNumber; (void) d->wakeUps.fetchAndStoreRelease(0); @@ -488,7 +488,7 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) if (GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER) != 0) { // delay the next pass of sendPostedEvents() until we get the special // WM_TIMER, which allows all pending Windows messages to be processed - SetTimer(d->internalHwnd, ~0u, 0, 0); + SetTimer(d->internalHwnd, ~1u, 0, 0); } else { // nothing pending in the queue, let sendPostedEvents go through d->wakeUps.fetchAndStoreRelease(0); -- cgit v0.12 From 64d38ba23b4acc46fdb9145f1953315573e3f8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 5 Nov 2009 16:55:36 +0100 Subject: Fixed uninitialized background artifacts in QWidget::render. We need to use isOpaque to check whether the widget has an opaque background, it's not enough to just check the palette (it doesn't check Qt::NoSystemBackground for example). Task-number: QTBUG-5012 Reviewed-by: Gunnar Sletta --- src/gui/kernel/qwidget.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 386bf71..271b939 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5171,8 +5171,7 @@ void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset return; QPixmap pixmap(size); - if (!(renderFlags & QWidget::DrawWindowBackground) - || !q->palette().brush(q->backgroundRole()).isOpaque()) + if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque) pixmap.fill(Qt::transparent); q->render(&pixmap, QPoint(), toBePainted, renderFlags); -- cgit v0.12 From 3c0b6de86ce044ce6f3f4a445d1de90b4e7bb1d9 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 6 Nov 2009 10:10:46 +0100 Subject: Updated testcase since soft-light algorithm rewrite. The SVG standard changed the algorithm which implies some changes to the results as well. Reviewed-by: Kim --- tests/auto/qpainter/tst_qpainter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 8ed83cb..bcdbe56 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -4193,9 +4193,9 @@ void tst_QPainter::extendedBlendModes() QVERIFY(testCompositionMode(255, 255, 255, QPainter::CompositionMode_SoftLight)); QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_SoftLight)); - QVERIFY(testCompositionMode(127, 127, 127, QPainter::CompositionMode_SoftLight)); - QVERIFY(testCompositionMode( 63, 63, 86, QPainter::CompositionMode_SoftLight)); - QVERIFY(testCompositionMode(127, 63, 63, QPainter::CompositionMode_SoftLight)); + QVERIFY(testCompositionMode(127, 127, 126, QPainter::CompositionMode_SoftLight)); + QVERIFY(testCompositionMode( 63, 63, 39, QPainter::CompositionMode_SoftLight)); + QVERIFY(testCompositionMode(127, 63, 62, QPainter::CompositionMode_SoftLight)); QVERIFY(testCompositionMode(255, 255, 0, QPainter::CompositionMode_Difference)); QVERIFY(testCompositionMode( 0, 0, 0, QPainter::CompositionMode_Difference)); -- cgit v0.12 From 1e77901a50858cf9243e6d813303d8ce013e4d31 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 6 Nov 2009 10:13:27 +0100 Subject: Revert micro optimization where NoPen == NoBrush as SVG relies on this Reviewed-by: Samuel --- src/gui/painting/qpen.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index 1ddadf2..a57450d 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -845,9 +845,7 @@ bool QPen::operator==(const QPen &p) const || (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) && pdd->dashPattern == dd->dashPattern)) && p.d->brush == d->brush - && pdd->cosmetic == dd->cosmetic) - || ((p.d->style == Qt::NoPen || p.d->brush.style() == Qt::NoBrush) - && (d->style == Qt::NoPen || d->brush.style() == Qt::NoBrush)); + && pdd->cosmetic == dd->cosmetic); } -- cgit v0.12 From b8a8110ead6fe5d4a985fe9d486dd8f470aa24eb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 6 Nov 2009 11:58:38 +0100 Subject: update harfbuzz once again, adding N'Ko support integrate/update to change 797fe54d9ebbafb0cdc00705c008ea09e7ac1e9e from harfbuzz: commit 797fe54d9ebbafb0cdc00705c008ea09e7ac1e9e Author: Lars Knoll Date: Fri Nov 6 11:56:44 2009 +0100 add N'Ko support to the arabic shaper Long outstanding bug report for Qt. See http://bugreports.qt.nokia.com/browse/QTBUG-1042 Task-number: part of QTBUG-1042 Reviewed-by: Gunnar --- src/3rdparty/harfbuzz/src/harfbuzz-arabic.c | 60 +++++++++++++++++++++++++-- src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp | 8 +++- src/3rdparty/harfbuzz/src/harfbuzz-shaper.h | 2 +- src/3rdparty/harfbuzz/tests/shaping/main.cpp | 35 ++++++++++++++++ 4 files changed, 99 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c b/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c index 4d85c19..3837087 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c @@ -489,6 +489,56 @@ static void getArabicProperties(const unsigned short *chars, int len, HB_ArabicP */ } +static Joining getNkoJoining(unsigned short uc) +{ + if (uc < 0x7ca) + return JNone; + if (uc <= 0x7ea) + return JDual; + if (uc <= 0x7f3) + return JTransparent; + if (uc <= 0x7f9) + return JNone; + if (uc == 0x7fa) + return JCausing; + return JNone; +} + +static void getNkoProperties(const unsigned short *chars, int len, HB_ArabicProperties *properties) +{ + int lastPos = 0; + int i = 0; + + Joining j = getNkoJoining(chars[0]); + ArabicShape shape = joining_table[XIsolated][j].form2; + properties[0].justification = HB_NoJustification; + + for (i = 1; i < len; ++i) { + properties[i].justification = (HB_GetUnicodeCharCategory(chars[i]) == HB_Separator_Space) ? + ArabicSpace : ArabicNone; + + j = getNkoJoining(chars[i]); + + if (j == JTransparent) { + properties[i].shape = XIsolated; + continue; + } + + properties[lastPos].shape = joining_table[shape][j].form1; + shape = joining_table[shape][j].form2; + + + lastPos = i; + } + properties[lastPos].shape = joining_table[shape][JNone].form1; + + + /* + for (int i = 0; i < len; ++i) + qDebug("nko properties(%d): uc=%x shape=%d, justification=%d", i, chars[i], properties[i].shape, properties[i].justification); + */ +} + /* // The unicode to unicode shaping codec. // does only presentation forms B at the moment, but that should be enough for @@ -1012,7 +1062,10 @@ static HB_Bool arabicSyriacOpenTypeShape(HB_ShaperItem *item, HB_Bool *ot_ok) if (f + l + item->item.pos < item->stringLength) { ++l; } - getArabicProperties(uc+f, l, props); + if (item->item.script == HB_Script_Nko) + getNkoProperties(uc+f, l, props); + else + getArabicProperties(uc+f, l, props); for (i = 0; i < (int)item->num_glyphs; i++) { apply[i] = 0; @@ -1051,7 +1104,8 @@ HB_Bool HB_ArabicShape(HB_ShaperItem *item) HB_Bool haveGlyphs; HB_STACKARRAY(HB_UChar16, shapedChars, item->item.length); - assert(item->item.script == HB_Script_Arabic || item->item.script == HB_Script_Syriac); + assert(item->item.script == HB_Script_Arabic || item->item.script == HB_Script_Syriac + || item->item.script == HB_Script_Nko); #ifndef NO_OPENTYPE @@ -1065,7 +1119,7 @@ HB_Bool HB_ArabicShape(HB_ShaperItem *item) } #endif - if (item->item.script == HB_Script_Syriac) + if (item->item.script != HB_Script_Arabic) return HB_BasicShape(item); shapedString(item->string, item->stringLength, item->item.pos, item->item.length, shapedChars, &slen, diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp index f92bb55..f3ec8e1 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp @@ -637,7 +637,9 @@ const HB_ScriptEngine HB_ScriptEngines[] = { // Runic { HB_BasicShape, 0 }, // Khmer - { HB_KhmerShape, HB_KhmerAttributes } + { HB_KhmerShape, HB_KhmerAttributes }, + // N'Ko + { HB_ArabicShape, 0} }; void HB_GetCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength, @@ -877,7 +879,9 @@ static const OTScripts ot_scripts [] = { // Runic { HB_MAKE_TAG('r', 'u', 'n', 'r'), 0 }, // Khmer - { HB_MAKE_TAG('k', 'h', 'm', 'r'), 1 } + { HB_MAKE_TAG('k', 'h', 'm', 'r'), 1 }, + // N'Ko + { HB_MAKE_TAG('n', 'k', 'o', ' '), 1 } }; enum { NumOTScripts = sizeof(ot_scripts)/sizeof(OTScripts) }; diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h index d2357f43..f7c7714 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h +++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h @@ -62,6 +62,7 @@ typedef enum { HB_Script_Ogham, HB_Script_Runic, HB_Script_Khmer, + HB_Script_Nko, HB_Script_Inherited, HB_ScriptCount = HB_Script_Inherited /* @@ -102,7 +103,6 @@ typedef enum { HB_Script_Cuneiform = Common, HB_Script_Phoenician = Common, HB_Script_PhagsPa = Common, - HB_Script_Nko = Common */ } HB_Script; diff --git a/src/3rdparty/harfbuzz/tests/shaping/main.cpp b/src/3rdparty/harfbuzz/tests/shaping/main.cpp index 41f2dbb..12fa7c4 100644 --- a/src/3rdparty/harfbuzz/tests/shaping/main.cpp +++ b/src/3rdparty/harfbuzz/tests/shaping/main.cpp @@ -181,6 +181,7 @@ private slots: void sinhala(); void khmer(); + void nko(); void linearB(); }; @@ -1075,6 +1076,40 @@ void tst_QScriptEngine::khmer() } } +void tst_QScriptEngine::nko() +{ + { + FT_Face face = loadFace("DejaVuSans.ttf"); + if (face) { + const ShapeTable shape_table [] = { + { { 0x7ca, 0x0 }, + { 0x5c1, 0x0 } }, + { { 0x7ca, 0x7ca, 0x0 }, + { 0x14db, 0x14d9, 0x0 } }, + { { 0x7ca, 0x7fa, 0x7ca, 0x0 }, + { 0x14db, 0x5ec, 0x14d9, 0x0 } }, + { { 0x7ca, 0x7f3, 0x7ca, 0x0 }, + { 0x14db, 0x5e7, 0x14d9, 0x0 } }, + { { 0x7ca, 0x7f3, 0x7fa, 0x7ca, 0x0 }, + { 0x14db, 0x5e7, 0x5ec, 0x14d9, 0x0 } }, + { {0}, {0} } + }; + + + const ShapeTable *s = shape_table; + while (s->unicode[0]) { + QVERIFY( shaping(face, s, HB_Script_Nko) ); + ++s; + } + + FT_Done_Face(face); + } else { + QSKIP("couln't find DejaVuSans.ttf", SkipAll); + } + } +} + + void tst_QScriptEngine::linearB() { { -- cgit v0.12 From 2e429e40eeed266c7062502c4f7b43092340f264 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 6 Nov 2009 12:03:10 +0100 Subject: add support for the N'Ko writing system to Qt Enables N'Ko support in Qt, after having now a harfbuzz version that supports it. Task-number: QTBUG-1042 Reviewed-by: Gunnar --- src/corelib/tools/qunicodetables_p.h | 4 +- src/gui/text/qfontdatabase.cpp | 23 +++++++-- src/gui/text/qfontdatabase.h | 1 + src/gui/text/qfontdatabase_x11.cpp | 93 +++++++++++++++++++----------------- 4 files changed, 72 insertions(+), 49 deletions(-) diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h index e4041b4..4e9ce4d 100644 --- a/src/corelib/tools/qunicodetables_p.h +++ b/src/corelib/tools/qunicodetables_p.h @@ -114,6 +114,7 @@ namespace QUnicodeTables { Ogham, Runic, Khmer, + Nko, Inherited, ScriptCount = Inherited, Latin = Common, @@ -152,8 +153,7 @@ namespace QUnicodeTables { Balinese = Common, Cuneiform = Common, Phoenician = Common, - PhagsPa = Common, - Nko = Common + PhagsPa = Common }; enum { ScriptSentinel = 32 }; diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index fb8444e..7d17e49 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -534,6 +534,12 @@ static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = { { 0, 127 }, // same as latin1 // Other, { 126, 127 } + // Ogham, + { 78, 127 }, + // Runic, + { 79, 127 }, + // Nko, + { 14, 127 }, }; #define SimplifiedChineseCsbBit 18 @@ -873,7 +879,8 @@ static const int scriptForWritingSystem[] = { QUnicodeTables::Common, // Braille QUnicodeTables::Common, // Symbol QUnicodeTables::Ogham, // Ogham - QUnicodeTables::Runic // Runic + QUnicodeTables::Runic, // Runic + QUnicodeTables::Nko // Nko }; @@ -881,12 +888,12 @@ static const int scriptForWritingSystem[] = { static inline bool requiresOpenType(int writingSystem) { return ((writingSystem >= QFontDatabase::Syriac && writingSystem <= QFontDatabase::Sinhala) - || writingSystem == QFontDatabase::Khmer); + || writingSystem == QFontDatabase::Khmer || writingSystem == QFontDatabase::Nko); } static inline bool scriptRequiresOpenType(int script) { return ((script >= QUnicodeTables::Syriac && script <= QUnicodeTables::Sinhala) - || script == QUnicodeTables::Khmer); + || script == QUnicodeTables::Khmer || script == QUnicodeTables::Nko); } #endif @@ -1558,6 +1565,7 @@ QFontDatabase::QFontDatabase() \value Other (the same as Symbol) \value Ogham \value Runic + \value Nko \omitvalue WritingSystemsCount */ @@ -2232,6 +2240,9 @@ QString QFontDatabase::writingSystemName(WritingSystem writingSystem) case Runic: name = QT_TRANSLATE_NOOP("QFontDatabase", "Runic"); break; + case Nko: + name = QT_TRANSLATE_NOOP("QFontDatabase", "N'Ko"); + break; default: Q_ASSERT_X(false, "QFontDatabase::writingSystemName", "invalid 'writingSystem' parameter"); break; @@ -2445,6 +2456,12 @@ QString QFontDatabase::writingSystemSample(WritingSystem writingSystem) sample += QChar(0x16a2); sample += QChar(0x16a3); break; + case Nko: + sample += QChar(0x7ca); + sample += QChar(0x7cb); + sample += QChar(0x7cc); + sample += QChar(0x7cd); + break; default: break; } diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h index e6dcfc9..37b5860 100644 --- a/src/gui/text/qfontdatabase.h +++ b/src/gui/text/qfontdatabase.h @@ -108,6 +108,7 @@ public: Ogham, Runic, + Nko, WritingSystemsCount }; diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index f184811..dd575f9 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -155,187 +155,187 @@ static const char writingSystems_for_xlfd_encoding[sizeof(xlfd_encoding)][QFontD { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-2 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-3 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-4 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-9 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-10 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-13 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-14 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-15 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // hp-roman8 { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-5 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // *-cp1251 { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // koi8-ru { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // koi8-u { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // koi8-r { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-7 { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-8 { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // gb18030-0 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0 }, + 0, 0 }, // gb18030.2000-0 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0 }, + 0, 0 }, // gbk-0 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0 }, + 0, 0 }, // gb2312.*-0 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0 }, + 0, 0 }, // jisx0201*-0 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0 }, + 0, 0 }, // jisx0208*-0 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, - 0 }, + 0, 0 }, // ksc5601*-* { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0 }, + 0, 0 }, // big5hkscs-0 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0 }, + 0, 0 }, // hkscs-1 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0 }, + 0, 0 }, // big5*-* { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0 }, + 0, 0 }, // tscii-* { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // tis620*-* { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso8859-11 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // mulelao-1 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // ethiopic-unicode { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0 }, + 0, 0 }, // iso10646-1 { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, - 0 }, + 0, 0 }, // unicode-* { 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, - 0 }, + 0, 0 }, // *-symbol { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1 }, + 1, 0 }, // *-fontspecific { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1 }, + 1, 0 }, // fontspecific-* { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1 } + 1, 0 } }; @@ -835,7 +835,8 @@ static const char *specialLanguages[] = { "ko", // Hangul "", // Ogham "", // Runic - "km" // Khmer + "km", // Khmer + "" // N'Ko }; enum { SpecialLanguageCount = sizeof(specialLanguages) / sizeof(const char *) }; @@ -866,7 +867,8 @@ static const ushort specialChars[] = { 0, // Hangul 0x1681, // Ogham 0x16a0, // Runic - 0 // Khmer + 0, // Khmer + 0x7ca // N'Ko }; enum { SpecialCharCount = sizeof(specialChars) / sizeof(ushort) }; @@ -905,7 +907,8 @@ static const char *languageForWritingSystem[] = { "vi", // Vietnamese 0, // Symbol 0, // Ogham - 0 // Runic + 0, // Runic + 0 // N'Ko }; enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; @@ -944,7 +947,8 @@ static const ushort sampleCharForWritingSystem[] = { 0, // Vietnamese 0, // Symbol 0x1681, // Ogham - 0x16a0 // Runic + 0x16a0, // Runic + 0x7ca // N'Ko }; enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) }; @@ -984,7 +988,8 @@ static const char *openType[] = { 0, // Vietnamese 0, // Symbol 0, // Ogham - 0 // Runic + 0, // Runic + "nko " // N'Ko }; enum { OpenTypeCount = sizeof(openType) / sizeof(const char *) }; @@ -1472,7 +1477,7 @@ void qt_addPatternProps(FcPattern *pattern, int screen, int script, const QFontD !(request.styleStrategy & QFont::NoAntialias)); } - if (script != QUnicodeTables::Common) { + if (script != QUnicodeTables::Common && *specialLanguages[script] != '\0') { Q_ASSERT(script < QUnicodeTables::ScriptCount); FcLangSet *ls = FcLangSetCreate(); FcLangSetAdd(ls, (const FcChar8*)specialLanguages[script]); @@ -1615,7 +1620,7 @@ static QFontEngine *tryPatternLoad(FcPattern *p, int screen, goto done; if (!FcCharSetHasChar(cs, specialChars[script])) goto done; - } else { + } else if (*specialLanguages[script] != '\0'){ FcLangSet *langSet = 0; if (FcPatternGetLangSet(match, FC_LANG, 0, &langSet) != FcResultMatch) goto done; -- cgit v0.12 From 5b9d489f6cc08061f91b36eb07df4fd7df12ccb1 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 6 Nov 2009 12:04:53 +0100 Subject: update documentation We are at Unicode 5.1, not 4.0 Tell about N'Ko support. Reviewed-by: Gunnar --- doc/src/internationalization/i18n.qdoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/src/internationalization/i18n.qdoc b/doc/src/internationalization/i18n.qdoc index 2d1b8cc..ecc25fe 100644 --- a/doc/src/internationalization/i18n.qdoc +++ b/doc/src/internationalization/i18n.qdoc @@ -93,7 +93,7 @@ \o Greek \o Hebrew \o Thai and Lao - \o All scripts in Unicode 4.0 that do not require special processing + \o All scripts in Unicode 5.1 that do not require special processing \endlist On Windows, Unix/X11 with FontConfig (client side font support) @@ -112,6 +112,7 @@ \o Tamil \o Telugu \o Tibetan + \o N'Ko \endlist Many of these writing systems exhibit special features: @@ -181,7 +182,7 @@ \section2 Use QString for All User-Visible Text - Since QString uses the Unicode 4.0 encoding internally, every + Since QString uses the Unicode 5.1 encoding internally, every language in the world can be processed transparently using familiar text processing operations. Also, since all Qt functions that present text to the user take a QString as a parameter, -- cgit v0.12 From a48b8e3c8c05384b27fcdde4ac27b8b8866c36c2 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Fri, 6 Nov 2009 12:11:48 +0100 Subject: Fixed crash in qt_scale_image_16/32bit() when target is flipped. If the target rectangle had negative width or height and the target rectangle's border passed through pixel centres, qt_scale_image_16/32bit() could crash because of incorrect rounding. Task-number: 5493 Reviewed-by: Gunnar --- src/gui/painting/qblendfunctions.cpp | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp index f8dd424..8737f10 100644 --- a/src/gui/painting/qblendfunctions.cpp +++ b/src/gui/painting/qblendfunctions.cpp @@ -223,11 +223,23 @@ void qt_scale_image_16bit(uchar *destPixels, int dbpl, int h = ty2 - ty1; int w = tx2 - tx1; - const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1; - const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1; + quint32 basex; + quint32 srcy; - quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx; - quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty; + if (sx < 0) { + int dstx = qFloor((tx1 + 0.5 - targetRect.right()) * ix) + 1; + basex = quint32(srcRect.right() * 65536) + dstx; + } else { + int dstx = qCeil((tx1 + 0.5 - targetRect.left()) * ix) - 1; + basex = quint32(srcRect.left() * 65536) + dstx; + } + if (sy < 0) { + int dsty = qFloor((ty1 + 0.5 - targetRect.bottom()) * iy) + 1; + srcy = quint32(srcRect.bottom() * 65536) + dsty; + } else { + int dsty = qCeil((ty1 + 0.5 - targetRect.top()) * iy) - 1; + srcy = quint32(srcRect.top() * 65536) + dsty; + } quint16 *dst = ((quint16 *) (destPixels + ty1 * dbpl)) + tx1; @@ -723,11 +735,23 @@ template void qt_scale_image_32bit(uchar *destPixels, int dbpl, int h = ty2 - ty1; int w = tx2 - tx1; - const int dstx = qCeil((tx1 + 0.5 - qMin(targetRect.left(), targetRect.right())) * ix) - 1; - const int dsty = qCeil((ty1 + 0.5 - qMin(targetRect.top(), targetRect.bottom())) * iy) - 1; + quint32 basex; + quint32 srcy; - quint32 basex = quint32((sx < 0 ? srcRect.right() : srcRect.left()) * 65536) + dstx; - quint32 srcy = quint32((sy < 0 ? srcRect.bottom() : srcRect.top()) * 65536) + dsty; + if (sx < 0) { + int dstx = qFloor((tx1 + 0.5 - targetRect.right()) * ix) + 1; + basex = quint32(srcRect.right() * 65536) + dstx; + } else { + int dstx = qCeil((tx1 + 0.5 - targetRect.left()) * ix) - 1; + basex = quint32(srcRect.left() * 65536) + dstx; + } + if (sy < 0) { + int dsty = qFloor((ty1 + 0.5 - targetRect.bottom()) * iy) + 1; + srcy = quint32(srcRect.bottom() * 65536) + dsty; + } else { + int dsty = qCeil((ty1 + 0.5 - targetRect.top()) * iy) - 1; + srcy = quint32(srcRect.top() * 65536) + dsty; + } quint32 *dst = ((quint32 *) (destPixels + ty1 * dbpl)) + tx1; -- cgit v0.12 From ddc5383e9ab596d42c0f481c0916234c238e8bb5 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 6 Nov 2009 12:43:40 +0100 Subject: don't do unessesary brush comparrisons Reviewed-by: Samuel --- src/gui/painting/qpainter.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 09a4563..4c13d3e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -3890,14 +3890,6 @@ void QPainter::setBrush(const QBrush &brush) return; } - Qt::BrushStyle currentStyle = d->state->brush.style(); - if (currentStyle == brush.style()) { - if (currentStyle == Qt::NoBrush - || (currentStyle == Qt::SolidPattern - && d->state->brush.color() == brush.color())) - return; - } - d->state->brush = brush; d->state->dirtyFlags |= QPaintEngine::DirtyBrush; } -- cgit v0.12 From 38d316a105e05fa66d57c64df283ab463b5b3aee Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 6 Nov 2009 12:44:34 +0100 Subject: Compile Missing comma in qfontdatabase.cpp Reviewed-by: Gunnar --- src/gui/text/qfontdatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 7d17e49..7e93aa0 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -533,7 +533,7 @@ static int requiredUnicodeBits[QFontDatabase::WritingSystemsCount][2] = { // Vietnamese, { 0, 127 }, // same as latin1 // Other, - { 126, 127 } + { 126, 127 }, // Ogham, { 78, 127 }, // Runic, -- cgit v0.12 From 9b500e9a09907f05002bd0e57869c5312ae101db Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 6 Nov 2009 12:59:35 +0100 Subject: Fix QPainter::setPen(pen with color but no style) on non-extended. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was working with a QImage but not with a QPixmap, which is obviously a bug. In addition, it broke WebCore::GraphicsContext::setPlatformStrokeColor which does exactly what I put in the unittest: get pen, set color, set pen. This commit fixes the wrong color in the underline of the links in http://www.davidfaure.fr/kde/link_underline_color.html in QtWebkit. Merge-request: 1995 Reviewed-by: Samuel Rødal --- src/gui/painting/qpainter.cpp | 17 ++-------------- tests/auto/qpainter/tst_qpainter.cpp | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 4c13d3e..48629d1 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -3787,27 +3787,14 @@ void QPainter::setPen(const QPen &pen) if (d->state->pen == pen) return; + d->state->pen = pen; + if (d->extended) { - d->state->pen = pen; d->checkEmulation(); d->extended->penChanged(); return; } - // Do some checks to see if we are the same pen. - Qt::PenStyle currentStyle = d->state->pen.style(); - if (currentStyle == pen.style() && currentStyle != Qt::CustomDashLine) { - if (currentStyle == Qt::NoPen || - (d->state->pen.isSolid() && pen.isSolid() - && d->state->pen.color() == pen.color() - && d->state->pen.widthF() == pen.widthF() - && d->state->pen.capStyle() == pen.capStyle() - && d->state->pen.joinStyle() == pen.joinStyle() - && d->state->pen.isCosmetic() == pen.isCosmetic())) - return; - } - - d->state->pen = pen; d->state->dirtyFlags |= QPaintEngine::DirtyPen; } diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index bcdbe56..4d2c626 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -239,9 +239,12 @@ private slots: void taskQT4444_dontOverflowDashOffset(); void painterBegin(); + void setPenColorOnImage(); + void setPenColorOnPixmap(); private: void fillData(); + void setPenColor(QPainter& p); QColor baseColor( int k, int intensity=255 ); QImage getResImage( const QString &dir, const QString &addition, const QString &extension ); QBitmap getBitmap( const QString &dir, const QString &filename, bool mask ); @@ -4352,5 +4355,41 @@ void tst_QPainter::painterBegin() QVERIFY(!p.end()); } +void tst_QPainter::setPenColor(QPainter& p) +{ + p.setPen(Qt::NoPen); + + // Setting color, then style + // Should work even though the pen is "NoPen with color", temporarily. + QPen newPen(p.pen()); + newPen.setColor(Qt::red); + QCOMPARE(p.pen().style(), newPen.style()); + QCOMPARE(p.pen().style(), Qt::NoPen); + p.setPen(newPen); + + QCOMPARE(p.pen().color().name(), QString("#ff0000")); + + QPen newPen2(p.pen()); + newPen2.setStyle(Qt::SolidLine); + p.setPen(newPen2); + + QCOMPARE(p.pen().color().name(), QString("#ff0000")); +} + +void tst_QPainter::setPenColorOnImage() +{ + QImage img(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); + QPainter p(&img); + setPenColor(p); +} + +void tst_QPainter::setPenColorOnPixmap() +{ + QPixmap pix(10, 10); + QPainter p(&pix); + setPenColor(p); +} + QTEST_MAIN(tst_QPainter) + #include "tst_qpainter.moc" -- cgit v0.12 From cb2e03d3ea16edf341191e03a7138440d3a7ba22 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 6 Nov 2009 12:58:58 +0100 Subject: Fix fuzzy aliased rendering on GLES2 The GL2 paint engine adds a (0.49,0.49) pixel offset when doing aliased rendering. But this assumed if it was doing aliased rendering then multisampling was disabled. On GLES, multisampling is always enabled if the surface has it enabled. So on GLES, we never add the offset if the surface is multisampled. Reviewed-By: Gunnar --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 14 ++++++++++++-- src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 1527e72..8228c7e 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1203,7 +1203,9 @@ void QGL2PaintEngineEx::fill(const QVectorPath &path, const QBrush &brush) ensureActive(); QOpenGL2PaintEngineState *s = state(); - bool doOffset = !(s->renderHints & QPainter::Antialiasing) && style == Qt::SolidPattern; + bool doOffset = !(s->renderHints & QPainter::Antialiasing) && + (style == Qt::SolidPattern) && + !d->multisamplingAlwaysEnabled; if (doOffset) { d->temporaryTransform = s->matrix; @@ -1242,7 +1244,7 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) ensureActive(); - bool doOffset = !(s->renderHints & QPainter::Antialiasing); + bool doOffset = !(s->renderHints & QPainter::Antialiasing) && !d->multisamplingAlwaysEnabled; if (doOffset) { d->temporaryTransform = s->matrix; QTransform tx = QTransform::fromTranslate(0.49, .49); @@ -1780,6 +1782,14 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) } #endif +#if defined(QT_OPENGL_ES_2) + // OpenGL ES can't switch MSAA off, so if the gl paint device is + // multisampled, it's always multisampled. + d->multisamplingAlwaysEnabled = d->device->format().sampleBuffers(); +#else + d->multisamplingAlwaysEnabled = false; +#endif + return true; } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 4cf2a83..9720723 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -277,6 +277,7 @@ public: bool needsSync; bool inRenderText; + bool multisamplingAlwaysEnabled; GLfloat depthRange[2]; -- cgit v0.12 From 33aeddff84e449404787f4be1b53d0fb52060ffb Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 6 Nov 2009 22:04:18 +1000 Subject: Fix error when configuring on Unix using an evaluation license. If you run configure on Unix more than once using an eval license (or -DQT_EVAL), configure outputs an error and fails to overwrite src/corelib/global/qconfig_eval.cpp. This is corrected simply by removing any existing instance of the file before re-creating it. Reviewed-by: Trust Me --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 9c3e417..208bb6b 100755 --- a/configure +++ b/configure @@ -4183,6 +4183,7 @@ elif echo "$D_FLAGS" | grep QT_EVAL >/dev/null 2>&1; then fi if [ -n "$EVALKEY" ]; then + rm -f "$outpath/src/corelib/global/qconfig_eval.cpp" cat > "$outpath/src/corelib/global/qconfig_eval.cpp" < Date: Fri, 6 Nov 2009 13:05:32 +0100 Subject: Fixed g++ compiler warnings in qpen.cpp. --- src/gui/painting/qpen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index a57450d..77aa748 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -984,7 +984,7 @@ QDataStream &operator>>(QDataStream &s, QPen &p) QDebug operator<<(QDebug dbg, const QPen &p) { #ifndef Q_BROKEN_DEBUG_STREAM - char *PEN_STYLES[] = { + const char *PEN_STYLES[] = { "NoPen", "SolidLine", "DashLine", -- cgit v0.12