summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-07-13 07:06:54 +1000
committerQt Continuous Integration System <qt-info@nokia.com>2011-07-13 07:06:54 +1000
commitc3b6b687e340d4d0c65789c3ac80dbaf2eb513b5 (patch)
tree56a76d96b33eee16eea7f5ea475d4991167070ef
parent647c618da0024373fd866999e7603cbf36cc855e (diff)
parent9a79b2bccba4ac80ab7b5d13d7ad3651bde06893 (diff)
downloadqt4-tools-c3b6b687e340d4d0c65789c3ac80dbaf2eb513b5.tar.gz
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-fire-staging: Fix compiler warning in qtextdocument.cpp Fix crash when app font is added Use truncate only for subpixel boundingBox x position Use more numerically robust algorithm to compute QBezier::pointAt(). Fix editable combobox style on Mac Revert 344a4dcfe and part of 93bce787 Fix raster subpixel positioning in Lion
-rw-r--r--src/gui/painting/qbezier_p.h36
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp6
-rw-r--r--src/gui/styles/qmacstyle_mac.mm10
-rw-r--r--src/gui/text/qfontengine_coretext.mm7
-rw-r--r--src/gui/text/qtextdocument.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp35
-rw-r--r--src/gui/text/qtextengine_p.h4
-rw-r--r--src/gui/text/qtextlayout.cpp8
-rw-r--r--tests/auto/qpainterpath/tst_qpainterpath.cpp21
9 files changed, 79 insertions, 50 deletions
diff --git a/src/gui/painting/qbezier_p.h b/src/gui/painting/qbezier_p.h
index 399dd89140..f1f7eb155a 100644
--- a/src/gui/painting/qbezier_p.h
+++ b/src/gui/painting/qbezier_p.h
@@ -162,27 +162,27 @@ inline void QBezier::coefficients(qreal t, qreal &a, qreal &b, qreal &c, qreal &
inline QPointF QBezier::pointAt(qreal t) const
{
-#if 1
- qreal a, b, c, d;
- coefficients(t, a, b, c, d);
- return QPointF(a*x1 + b*x2 + c*x3 + d*x4, a*y1 + b*y2 + c*y3 + d*y4);
-#else
// numerically more stable:
+ qreal x, y;
+
qreal m_t = 1. - t;
- qreal a = x1*m_t + x2*t;
- qreal b = x2*m_t + x3*t;
- qreal c = x3*m_t + x4*t;
- a = a*m_t + b*t;
- b = b*m_t + c*t;
- qreal x = a*m_t + b*t;
- qreal a = y1*m_t + y2*t;
- qreal b = y2*m_t + y3*t;
- qreal c = y3*m_t + y4*t;
- a = a*m_t + b*t;
- b = b*m_t + c*t;
- qreal y = a*m_t + b*t;
+ {
+ qreal a = x1*m_t + x2*t;
+ qreal b = x2*m_t + x3*t;
+ qreal c = x3*m_t + x4*t;
+ a = a*m_t + b*t;
+ b = b*m_t + c*t;
+ x = a*m_t + b*t;
+ }
+ {
+ qreal a = y1*m_t + y2*t;
+ qreal b = y2*m_t + y3*t;
+ qreal c = y3*m_t + y4*t;
+ a = a*m_t + b*t;
+ b = b*m_t + c*t;
+ y = a*m_t + b*t;
+ }
return QPointF(x, y);
-#endif
}
inline QPointF QBezier::normalVector(qreal t) const
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index fdba9c99ea..3973abd218 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -198,7 +198,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const
Coord c = { 0, 0, // will be filled in later
glyph_width,
glyph_height, // texture coords
- metrics.x.round().truncate(),
+ metrics.x.truncate(),
-metrics.y.truncate() }; // baseline for horizontal scripts
listItemCoordinates.insert(key, c);
@@ -367,9 +367,7 @@ void QImageTextureGlyphCache::createTextureData(int width, int height)
int QImageTextureGlyphCache::glyphMargin() const
{
-#if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA))
- return 1;
-#elif defined(Q_WS_X11)
+#if (defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) || defined(Q_WS_X11)
return 0;
#else
return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0;
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 321db25ad0..8436856e81 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -1195,15 +1195,15 @@ QRect QMacStylePrivate::comboboxEditBounds(const QRect &outerBounds, const HIThe
QRect ret = outerBounds;
switch (bdi.kind){
case kThemeComboBox:
- ret.adjust(5, 8, -21, -4);
+ ret.adjust(5, 8, -22, -4);
break;
case kThemeComboBoxSmall:
- ret.adjust(4, 5, -18, 0);
- ret.setHeight(16);
+ ret.adjust(4, 6, -20, 0);
+ ret.setHeight(14);
break;
case kThemeComboBoxMini:
- ret.adjust(4, 5, -16, 0);
- ret.setHeight(13);
+ ret.adjust(4, 5, -18, -1);
+ ret.setHeight(12);
break;
case kThemePopupButton:
ret.adjust(10, 3, -23, -3);
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index 07711a3b38..64d4a2453c 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -718,8 +718,9 @@ void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *position
QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, bool aa)
{
+ Q_UNUSED(margin);
const glyph_metrics_t br = boundingBox(glyph);
- QImage im(qRound(br.width) + margin * 2, qRound(br.height) + margin * 2, QImage::Format_RGB32);
+ QImage im(qRound(br.width) + 2, qRound(br.height) + 2, QImage::Format_RGB32);
im.fill(0);
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
@@ -750,8 +751,8 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
CGContextSetFont(ctx, cgFont);
- qreal pos_x = -br.x.toReal() + subPixelPosition.toReal() + margin;
- qreal pos_y = im.height() + br.y.toReal() - margin;
+ qreal pos_x = -br.x.truncate() + subPixelPosition.toReal();
+ qreal pos_y = im.height() + br.y.toReal();
CGContextSetTextPosition(ctx, pos_x, pos_y);
CGSize advance;
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 0abafb81cc..143dc1ab8c 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2710,7 +2710,7 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block)
html += QLatin1Char('>');
if (block.begin().atEnd())
- html += "<br />";
+ html += QLatin1String("<br />");
QTextBlock::Iterator it = block.begin();
if (fragmentMarkers && !it.atEnd() && block == doc->begin())
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 8ddf3eb5d3..c900918850 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -3051,6 +3051,22 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo
: justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format),
num_chars(0), chars(0), logClusters(0), f(0), fontEngine(0)
{
+ f = font;
+ fontEngine = f->d->engineForScript(si.analysis.script);
+ Q_ASSERT(fontEngine);
+
+ initWithScriptItem(si);
+}
+
+QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe, const QTextCharFormat &format)
+ : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline), charFormat(format),
+ num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe)
+{
+}
+
+// Fix up flags and underlineStyle with given info
+void QTextItemInt::initWithScriptItem(const QScriptItem &si)
+{
// explicitly initialize flags so that initFontAttributes can be called
// multiple times on the same TextItem
flags = 0;
@@ -3058,13 +3074,10 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo
flags |= QTextItem::RightToLeft;
ascent = si.ascent;
descent = si.descent;
- f = font;
- fontEngine = f->d->engineForScript(si.analysis.script);
- Q_ASSERT(fontEngine);
- if (format.hasProperty(QTextFormat::TextUnderlineStyle)) {
- underlineStyle = format.underlineStyle();
- } else if (format.boolProperty(QTextFormat::FontUnderline)
+ if (charFormat.hasProperty(QTextFormat::TextUnderlineStyle)) {
+ underlineStyle = charFormat.underlineStyle();
+ } else if (charFormat.boolProperty(QTextFormat::FontUnderline)
|| f->d->underline) {
underlineStyle = QTextCharFormat::SingleUnderline;
}
@@ -3073,18 +3086,12 @@ QTextItemInt::QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFo
if (underlineStyle == QTextCharFormat::SingleUnderline)
flags |= QTextItem::Underline;
- if (f->d->overline || format.fontOverline())
+ if (f->d->overline || charFormat.fontOverline())
flags |= QTextItem::Overline;
- if (f->d->strikeOut || format.fontStrikeOut())
+ if (f->d->strikeOut || charFormat.fontStrikeOut())
flags |= QTextItem::StrikeOut;
}
-QTextItemInt::QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars_, int numChars, QFontEngine *fe)
- : flags(0), justified(false), underlineStyle(QTextCharFormat::NoUnderline),
- num_chars(numChars), chars(chars_), logClusters(0), f(font), glyphs(g), fontEngine(fe)
-{
-}
-
QTextItemInt QTextItemInt::midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const
{
QTextItemInt ti = *this;
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 055974a4ad..b1bd0c3359 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -312,11 +312,13 @@ public:
logClusters(0), f(0), fontEngine(0)
{}
QTextItemInt(const QScriptItem &si, QFont *font, const QTextCharFormat &format = QTextCharFormat());
- QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe);
+ QTextItemInt(const QGlyphLayout &g, QFont *font, const QChar *chars, int numChars, QFontEngine *fe,
+ const QTextCharFormat &format = QTextCharFormat());
/// copy the structure items, adjusting the glyphs arrays to the right subarrays.
/// the width of the returned QTextItemInt is not adjusted, for speed reasons
QTextItemInt midItem(QFontEngine *fontEngine, int firstGlyphIndex, int numGlyphs) const;
+ void initWithScriptItem(const QScriptItem &si);
QFixed descent;
QFixed ascent;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 79906675f4..3f0b9e8f7d 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2389,13 +2389,13 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR
unsigned short *logClusters = eng->logClusters(&si);
QGlyphLayout glyphs = eng->shapedGlyphs(&si);
- QTextItemInt gf(si, &f, format);
- gf.glyphs = glyphs.mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart);
- gf.chars = eng->layoutData->string.unicode() + iterator.itemStart;
+ QTextItemInt gf(glyphs.mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart),
+ &f, eng->layoutData->string.unicode() + iterator.itemStart,
+ iterator.itemEnd - iterator.itemStart, eng->fontEngine(si), format);
gf.logClusters = logClusters + iterator.itemStart - si.position;
- gf.num_chars = iterator.itemEnd - iterator.itemStart;
gf.width = iterator.itemWidth;
gf.justified = line.justified;
+ gf.initWithScriptItem(si);
Q_ASSERT(gf.fontEngine);
diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp
index 3941a11460..33315adc06 100644
--- a/tests/auto/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp
@@ -114,6 +114,8 @@ private slots:
void connectPathMoveTo();
void translate();
+
+ void lineWithinBounds();
};
// Testing get/set functions
@@ -1306,6 +1308,25 @@ void tst_QPainterPath::translate()
QCOMPARE(complexPath.translated(-offset), untranslatedComplexPath);
}
+
+void tst_QPainterPath::lineWithinBounds()
+{
+ const int iteration_count = 3;
+ volatile const qreal yVal = 0.5;
+ QPointF a(0.0, yVal);
+ QPointF b(1000.0, yVal);
+ QPointF c(2000.0, yVal);
+ QPointF d(3000.0, yVal);
+ QPainterPath path;
+ path.moveTo(QPointF(0, yVal));
+ path.cubicTo(QPointF(1000.0, yVal), QPointF(2000.0, yVal), QPointF(3000.0, yVal));
+ for(int i=0; i<=iteration_count; i++) {
+ qreal actual = path.pointAtPercent(qreal(i) / iteration_count).y();
+ QVERIFY(actual == yVal); // don't use QCOMPARE, don't want fuzzy comparison
+ }
+}
+
+
QTEST_APPLESS_MAIN(tst_QPainterPath)
#include "tst_qpainterpath.moc"