diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-05 20:39:49 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-11-05 20:39:49 (GMT) |
commit | e1a8f05da583724f7d3ffcd3a4f39b0dfb1f81a2 (patch) | |
tree | e8557727548cf4e144a11c44fcfa36774c7daf02 /src/gui | |
parent | 6ac4bc5cb7ac7500b39ea6828fdf76e95a2c2f0b (diff) | |
parent | 334347669839844468d19a297ed780c3e8fdcfa5 (diff) | |
download | Qt-e1a8f05da583724f7d3ffcd3a4f39b0dfb1f81a2.zip Qt-e1a8f05da583724f7d3ffcd3a4f39b0dfb1f81a2.tar.gz Qt-e1a8f05da583724f7d3ffcd3a4f39b0dfb1f81a2.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
More fix for QTBUG-14640:oci performance problem with qlonglong
Doc: Fixing typo
Fixed grabWidget sometimes returning uninitialized memory.
Fix Malayalam Rendering - 'Ra' is PreBase
Update .def files for QtGui and QtOpenVG
Use 32bit textures for alpha textures after all.
One more fix for dithering.
Doc: Fixing typo
Fix QTBUG-14640:oci performance problem with qlonglong
32bit => 16bit conversion has 4byte-aligned output.
Fix gcc bug in qReallocAligned
Prevented threading related crash in OpenGL module.
Fix possible crash in QStaticText and QDeclarativeTextLayout
Fix QTBUG-14132 oracle (xe) stored procedures with bind variables get errors
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/image/qpixmap.cpp | 5 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qstatictext.cpp | 22 | ||||
-rw-r--r-- | src/gui/text/qstatictext_p.h | 54 |
5 files changed, 72 insertions, 15 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 64d8ed2..290c0f0 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1101,10 +1101,11 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect) if (!r.intersects(widget->rect())) return QPixmap(); - QPixmap res(r.size()); + QImage res(r.size(), QImage::Format_ARGB32_Premultiplied); + res.fill(0); widget->d_func()->render(&res, QPoint(), r, QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask, true); - return res; + return QPixmap::fromImage(res); } /*! diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 3717ed9..161ced5 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3301,7 +3301,7 @@ void QRasterPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) ensureState(); drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->glyphPositions, - textItem->fontEngine); + textItem->fontEngine()); } /*! diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 7fed7e4..ab9707d 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5746,7 +5746,7 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit QStaticTextItem staticTextItem; staticTextItem.color = state->pen.color(); staticTextItem.font = state->font; - staticTextItem.fontEngine = fontEngine; + staticTextItem.setFontEngine(fontEngine); staticTextItem.numGlyphs = glyphCount; staticTextItem.glyphs = reinterpret_cast<glyph_t *>(const_cast<glyph_t *>(glyphArray)); staticTextItem.glyphPositions = positions.data(); @@ -5938,7 +5938,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText d->extended->drawStaticTextItem(item); drawDecorationForGlyphs(this, item->glyphs, item->glyphPositions, - item->numGlyphs, item->fontEngine, staticText_d->font, + item->numGlyphs, item->fontEngine(), staticText_d->font, QTextCharFormat()); } if (currentColor != oldPen.color()) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 9506006..edf248a 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -445,7 +445,7 @@ namespace { const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); QStaticTextItem currentItem; - currentItem.fontEngine = ti.fontEngine; + currentItem.setFontEngine(ti.fontEngine); currentItem.font = ti.font(); currentItem.charOffset = m_chars.size(); currentItem.numChars = ti.num_chars; @@ -713,4 +713,24 @@ void QStaticTextPrivate::init() needsRelayout = false; } +QStaticTextItem::~QStaticTextItem() +{ + if (m_userData != 0 && !m_userData->ref.deref()) + delete m_userData; + if (!m_fontEngine->ref.deref()) + delete m_fontEngine; +} + +void QStaticTextItem::setFontEngine(QFontEngine *fe) +{ + if (m_fontEngine != 0) { + if (!m_fontEngine->ref.deref()) + delete m_fontEngine; + } + + m_fontEngine = fe; + if (m_fontEngine != 0) + m_fontEngine->ref.ref(); +} + QT_END_NAMESPACE diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h index cb60626..87ef0d5 100644 --- a/src/gui/text/qstatictext_p.h +++ b/src/gui/text/qstatictext_p.h @@ -68,27 +68,60 @@ public: OpenGLUserData }; - QStaticTextUserData(Type t) : type(t) {} + QStaticTextUserData(Type t) : type(t) { ref = 0; } virtual ~QStaticTextUserData() {} + QAtomicInt ref; Type type; }; class Q_GUI_EXPORT QStaticTextItem { public: - QStaticTextItem() : chars(0), numChars(0), fontEngine(0), userData(0), - useBackendOptimizations(false), userDataNeedsUpdate(0) {} - ~QStaticTextItem() { delete userData; } + QStaticTextItem() : chars(0), numChars(0), useBackendOptimizations(false), + userDataNeedsUpdate(0), m_fontEngine(0), m_userData(0) {} + + QStaticTextItem(const QStaticTextItem &other) + { + operator=(other); + } + + void operator=(const QStaticTextItem &other) + { + glyphPositions = other.glyphPositions; + glyphs = other.glyphs; + chars = other.chars; + numGlyphs = other.numGlyphs; + numChars = other.numChars; + font = other.font; + color = other.color; + useBackendOptimizations = other.useBackendOptimizations; + userDataNeedsUpdate = other.userDataNeedsUpdate; + + m_fontEngine = 0; + m_userData = 0; + setUserData(other.userData()); + setFontEngine(other.fontEngine()); + } + + ~QStaticTextItem(); void setUserData(QStaticTextUserData *newUserData) { - if (userData == newUserData) + if (m_userData == newUserData) return; - delete userData; - userData = newUserData; + if (m_userData != 0 && !m_userData->ref.deref()) + delete m_userData; + + m_userData = newUserData; + if (m_userData != 0) + m_userData->ref.ref(); } + QStaticTextUserData *userData() const { return m_userData; } + + void setFontEngine(QFontEngine *fe); + QFontEngine *fontEngine() const { return m_fontEngine; } union { QFixedPoint *glyphPositions; // 8 bytes per glyph @@ -108,14 +141,17 @@ public: // 12 bytes for pointers int numGlyphs; // 4 bytes per item int numChars; // 4 bytes per item - QFontEngine *fontEngine; // 4 bytes per item QFont font; // 8 bytes per item QColor color; // 10 bytes per item - QStaticTextUserData *userData; // 8 bytes per item char useBackendOptimizations : 1; // 1 byte per item char userDataNeedsUpdate : 1; // // ================ // 51 bytes per item + +private: // Needs special handling in setters, so private to avoid abuse + QFontEngine *m_fontEngine; // 4 bytes per item + QStaticTextUserData *m_userData; // 8 bytes per item + }; class QStaticText; |