From 07fa5bd76e6ecd87ea8f8422ddaec56eb4db2289 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 10 Mar 2011 08:55:00 +0100 Subject: Fix PBuffer example to work again Done by: Trond --- examples/opengl/pbuffers/cube.cpp | 49 +++++++++++++++++++++++------------ examples/opengl/pbuffers/cube.h | 3 ++- examples/opengl/pbuffers/glwidget.cpp | 2 +- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/examples/opengl/pbuffers/cube.cpp b/examples/opengl/pbuffers/cube.cpp index 5bd35e1..631595a 100644 --- a/examples/opengl/pbuffers/cube.cpp +++ b/examples/opengl/pbuffers/cube.cpp @@ -46,7 +46,7 @@ static const qreal FACE_SIZE = 0.4; -static const qreal speeds[] = { 1.8f, 2.4f, 3.6f }; +static const qreal speeds[] = { 3.8f, 4.4f, 5.6f }; static const qreal amplitudes[] = { 2.0f, 2.5f, 3.0f }; static inline void qSetColor(float colorVec[], QColor c) @@ -197,7 +197,8 @@ Tile *TileBuilder::newTile(const QVector3D &loc) const Cube::Cube(const QVector3D &loc) : Tile(loc) , rot(0.0f) - , r(0), a(0) + , r(0) + , animGroup(0) { } @@ -234,8 +235,8 @@ void Cube::setRotation(qreal r) void Cube::removeBounce() { - delete a; - a = 0; + delete animGroup; + animGroup = 0; delete r; r = 0; } @@ -247,8 +248,8 @@ void Cube::startAnimation() r->start(); r->setCurrentTime(startx); } - if (a) - a->start(); + if (animGroup) + animGroup->start(); if (rtn) rtn->start(); } @@ -259,8 +260,8 @@ void Cube::setAnimationPaused(bool paused) { if (r) r->pause(); - if (a) - a->pause(); + if (animGroup) + animGroup->pause(); if (rtn) rtn->pause(); } @@ -268,8 +269,8 @@ void Cube::setAnimationPaused(bool paused) { if (r) r->resume(); - if (a) - a->resume(); + if (animGroup) + animGroup->resume(); if (rtn) rtn->resume(); } @@ -312,13 +313,29 @@ Cube *CubeBuilder::newCube(const QVector3D &loc) const c->r->setDuration(d * 4.0f); c->r->setLoopCount(-1); c->r->setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve)); + + c->animGroup = new QSequentialAnimationGroup(c); + // Animate movement from bottom to top - c->a = new QPropertyAnimation(c, "altitude"); - c->a->setEndValue(loc.y()); - c->a->setStartValue(loc.y() + amplitudes[ix]); - c->a->setDuration(d / speeds[ix]); - c->a->setLoopCount(-1); - c->a->setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve)); + QPropertyAnimation *a_up = new QPropertyAnimation(c, "altitude", c->animGroup); + a_up->setEndValue(loc.y()); + a_up->setStartValue(loc.y() + amplitudes[ix]); + a_up->setDuration(d / speeds[ix]); + a_up->setLoopCount(1); + a_up->setEasingCurve(QEasingCurve(QEasingCurve::InQuad)); + + // Animate movement from top to bottom + QPropertyAnimation *a_down = new QPropertyAnimation(c, "altitude", c->animGroup); + a_down->setEndValue(loc.y() + amplitudes[ix]); + a_down->setStartValue(loc.y()); + a_down->setDuration(d / speeds[ix]); + a_down->setLoopCount(1); + a_down->setEasingCurve(QEasingCurve(QEasingCurve::OutQuad)); + + c->animGroup->addAnimation(a_up); + c->animGroup->addAnimation(a_down); + c->animGroup->setLoopCount(-1); + // Animate rotation c->rtn = new QPropertyAnimation(c, "rotation"); c->rtn->setStartValue(c->rot); diff --git a/examples/opengl/pbuffers/cube.h b/examples/opengl/pbuffers/cube.h index 2577e76..5c985a3 100644 --- a/examples/opengl/pbuffers/cube.h +++ b/examples/opengl/pbuffers/cube.h @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -130,8 +131,8 @@ signals: private: qreal rot; QPropertyAnimation *r; - QPropertyAnimation *a; QPropertyAnimation *rtn; + QSequentialAnimationGroup *animGroup; qreal startx; friend class CubeBuilder; }; diff --git a/examples/opengl/pbuffers/glwidget.cpp b/examples/opengl/pbuffers/glwidget.cpp index 930cbc8..f6f89e5 100644 --- a/examples/opengl/pbuffers/glwidget.cpp +++ b/examples/opengl/pbuffers/glwidget.cpp @@ -135,7 +135,7 @@ void GLWidget::initializeGeometry() CubeBuilder cBuilder(geom, 0.5); cBuilder.setColor(QColor(255, 255, 255, 212)); // build the 3 bouncing, spinning cubes - for (int i = 0; i < 3; ++i) + for (int i = 3; i > 0; --i) cubes.append(cBuilder.newCube(QVector3D((float)(i-1), -1.5f, 5 - i))); // build the spinning cube which goes in the dynamic texture -- cgit v0.12 From 86e7893c2c1a4c316a1db510ab6abeafa7267c3d Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 11 Mar 2011 11:37:52 +0100 Subject: Fix combining marks handling in Core Text shaper For fonts without combined glyph for combinations like U+0062 U+0300, Core Text will return glyph sequences like <`>, the latter will have advance_x = 0, advance_y = to keep it above the previous glyph. To get correct positioning in flipped coordinate, we need to store the negative y advance in Qt. Task-number: QTBUG-15675 Reviewed-by: Eskil --- src/gui/text/qfontengine_coretext.mm | 3 ++- .../qtextscriptengine/tst_qtextscriptengine.cpp | 25 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm index 2ae60b1..0209689 100644 --- a/src/gui/text/qfontengine_coretext.mm +++ b/src/gui/text/qfontengine_coretext.mm @@ -234,7 +234,8 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay int idx = rtlOffset + rtlSign * i; outGlyphs[idx] = tmpGlyphs[i] | fontIndex; outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x); - outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i + 1].y - tmpPoints[i].y); + // Use negative y advance for flipped coordinate system + outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i].y - tmpPoints[i + 1].y); if (fontDef.styleStrategy & QFont::ForceIntegerMetrics) { outAdvances_x[idx] = outAdvances_x[idx].round(); diff --git a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp index 91d0f3f..4f4e706a 100644 --- a/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/qtextscriptengine/tst_qtextscriptengine.cpp @@ -56,7 +56,7 @@ -#if defined(Q_WS_X11) +#if defined(Q_WS_X11) || defined(Q_WS_MAC) #define private public #include #include @@ -104,6 +104,7 @@ private slots: void khmer(); void linearB(); void controlInSyllable_qtbug14204(); + void combiningMarks_qtbug15675(); }; tst_QTextScriptEngine::tst_QTextScriptEngine() @@ -1133,5 +1134,27 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204() #endif } +void tst_QTextScriptEngine::combiningMarks_qtbug15675() +{ +#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) + QString s; + s.append(QChar(0x0061)); + s.append(QChar(0x0062)); + s.append(QChar(0x0300)); + s.append(QChar(0x0063)); + + QFont font("Monaco"); + QTextLayout layout(s, font); + QTextEngine *e = layout.d; + e->itemize(); + e->shape(0); + + QVERIFY(e->layoutData->items[0].num_glyphs == 4); + QVERIFY(e->layoutData->glyphLayout.advances_y[2] > 0); +#else + QSKIP("Mac specific test", SkipAll); +#endif +} + QTEST_MAIN(tst_QTextScriptEngine) #include "tst_qtextscriptengine.moc" -- cgit v0.12 From 6f5553b95c4df489e0bf047399a90e9a564314e6 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 7 Mar 2011 14:35:46 +0100 Subject: Fix static text item positioning GL2 paint engine Reviewed-by: Eskil --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index bbb75bc..fa38b5d 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1623,8 +1623,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp if (c.isNull()) continue; - int x = staticTextItem->glyphPositions[i].x.toInt() + c.baseLineX - margin; - int y = staticTextItem->glyphPositions[i].y.toInt() - c.baseLineY - margin; + int x = qFloor(staticTextItem->glyphPositions[i].x) + c.baseLineX - margin; + int y = qFloor(staticTextItem->glyphPositions[i].y) - c.baseLineY - margin; vertexCoordinates->addQuad(QRectF(x, y, c.w, c.h)); textureCoordinates->addQuad(QRectF(c.x*dx, c.y*dy, c.w * dx, c.h * dy)); -- cgit v0.12