summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-01-08 15:13:28 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-01-08 15:14:07 (GMT)
commitf0d2a0d7a9ed0500a1423bbf1362b234525f8be7 (patch)
treec6247568431f5a8f9fc12fe145921bc9851398e4
parentfdac6df6d46e6d4f00763365de5a4437ad06ba39 (diff)
downloadQt-f0d2a0d7a9ed0500a1423bbf1362b234525f8be7.zip
Qt-f0d2a0d7a9ed0500a1423bbf1362b234525f8be7.tar.gz
Qt-f0d2a0d7a9ed0500a1423bbf1362b234525f8be7.tar.bz2
Reverted two commits that were pushed to the wrong branch.
Revert "Use the new QTextCodec api in the QXmlStreamWriter." This reverts commit fdac6df6d46e6d4f00763365de5a4437ad06ba39. Revert "Added new functions to QTextCodec that accept ConversionFlags." This reverts commit 7fb78e7f60ea72e9e471d6cbc4403d490581df17.
-rw-r--r--src/corelib/codecs/qtextcodec.cpp49
-rw-r--r--src/corelib/codecs/qtextcodec.h16
-rw-r--r--src/corelib/xml/qxmlstream.cpp7
3 files changed, 13 insertions, 59 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 86845c7..698ca9e 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1163,19 +1163,6 @@ QTextDecoder* QTextCodec::makeDecoder() const
return new QTextDecoder(this);
}
-/*!
- Creates a QTextDecoder with a specified \a flags to decode chunks
- of \c{char *} data to create chunks of Unicode data.
-
- The caller is responsible for deleting the returned object.
-
- \since 4.7
-*/
-QTextDecoder* QTextCodec::makeDecoder(QTextCodec::ConversionFlags flags) const
-{
- return new QTextDecoder(this, flags);
-}
-
/*!
Creates a QTextEncoder which stores enough state to encode chunks
@@ -1189,19 +1176,6 @@ QTextEncoder* QTextCodec::makeEncoder() const
}
/*!
- Creates a QTextEncoder with a specified \a flags to encode chunks
- of Unicode data as \c{char *} data.
-
- The caller is responsible for deleting the returned object.
-
- \since 4.7
-*/
-QTextEncoder* QTextCodec::makeEncoder(QTextCodec::ConversionFlags flags) const
-{
- return new QTextEncoder(this, flags);
-}
-
-/*!
\fn QByteArray QTextCodec::fromUnicode(const QChar *input, int number,
ConverterState *state) const
@@ -1342,17 +1316,6 @@ QString QTextCodec::toUnicode(const char *chars) const
*/
/*!
- Constructs a text encoder for the given \a codec and conversion \a flags.
-
- \since 4.7
-*/
-QTextEncoder::QTextEncoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags)
- : c(codec), state()
-{
- state.flags = flags;
-}
-
-/*!
Destroys the encoder.
*/
QTextEncoder::~QTextEncoder()
@@ -1429,18 +1392,6 @@ QByteArray QTextEncoder::fromUnicode(const QString& uc, int& lenInOut)
*/
/*!
- Constructs a text decoder for the given \a codec and conversion \a flags.
-
- \since 4.7
-*/
-
-QTextDecoder::QTextDecoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags)
- : c(codec), state()
-{
- state.flags = flags;
-}
-
-/*!
Destroys the decoder.
*/
QTextDecoder::~QTextDecoder()
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index e37527d..a099dd9 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -85,6 +85,9 @@ public:
static QTextCodec *codecForUtfText(const QByteArray &ba);
static QTextCodec *codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec);
+ QTextDecoder* makeDecoder() const;
+ QTextEncoder* makeEncoder() const;
+
bool canEncode(QChar) const;
bool canEncode(const QString&) const;
@@ -117,12 +120,6 @@ public:
QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = 0) const
{ return convertFromUnicode(in, length, state); }
- // ### Qt 5: merge these functions.
- QTextDecoder* makeDecoder() const;
- QTextDecoder* makeDecoder(ConversionFlags flags) const;
- QTextEncoder* makeEncoder() const;
- QTextEncoder* makeEncoder(ConversionFlags flags) const;
-
virtual QByteArray name() const = 0;
virtual QList<QByteArray> aliases() const;
virtual int mibEnum() const = 0;
@@ -160,7 +157,6 @@ class Q_CORE_EXPORT QTextEncoder {
Q_DISABLE_COPY(QTextEncoder)
public:
explicit QTextEncoder(const QTextCodec *codec) : c(codec), state() {}
- QTextEncoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags);
~QTextEncoder();
QByteArray fromUnicode(const QString& str);
QByteArray fromUnicode(const QChar *uc, int len);
@@ -171,13 +167,17 @@ public:
private:
const QTextCodec *c;
QTextCodec::ConverterState state;
+
+ friend class QXmlStreamWriter;
+ friend class QXmlStreamWriterPrivate;
+ friend class QCoreXmlStreamWriter;
+ friend class QCoreXmlStreamWriterPrivate;
};
class Q_CORE_EXPORT QTextDecoder {
Q_DISABLE_COPY(QTextDecoder)
public:
explicit QTextDecoder(const QTextCodec *codec) : c(codec), state() {}
- QTextDecoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags);
~QTextDecoder();
QString toUnicode(const char* chars, int len);
QString toUnicode(const QByteArray &ba);
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 1bf00b8..5717ca2 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -3003,7 +3003,8 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q)
deleteDevice = false;
#ifndef QT_NO_TEXTCODEC
codec = QTextCodec::codecForMib(106); // utf8
- encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8
+ encoder = codec->makeEncoder();
+ encoder->state.flags |= QTextCodec::IgnoreHeader; // no byte order mark for utf8
#endif
inStartElement = inEmptyElement = false;
wroteSomething = false;
@@ -3277,7 +3278,9 @@ void QXmlStreamWriter::setCodec(QTextCodec *codec)
if (codec) {
d->codec = codec;
delete d->encoder;
- d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8
+ d->encoder = codec->makeEncoder();
+ if (codec->mibEnum() == 106)
+ d->encoder->state.flags |= QTextCodec::IgnoreHeader; // no byte order mark for utf8
}
}
45ba2b11342a9e7cc06b68237b68a68955213'>tests/benchmarks/declarative/painting/data/64x64.pngBinary files differ
diff --git a/tests/benchmarks/declarative/painting/data/64x64_opaque.png b/tests/benchmarks/declarative/painting/data/64x64_opaque.png
new file mode 100644
index 0000000..94c07f3
--- /dev/null
+++ b/tests/benchmarks/declarative/painting/data/64x64_opaque.png
Binary files differ
diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.cpp b/tests/benchmarks/declarative/painting/paintbenchmark.cpp
index d6a873c..9231b67 100644
--- a/tests/benchmarks/declarative/painting/paintbenchmark.cpp
+++ b/tests/benchmarks/declarative/painting/paintbenchmark.cpp
@@ -48,10 +48,7 @@
#include <QVBoxLayout>
#include <QTime>
#include <QDebug>
-
-#ifdef HAVE_STATICTEXT
-#include <private/qstatictext_p.h>
-#endif
+#include <QStaticText>
int iterations = 20;
const int count = 600;
@@ -60,6 +57,7 @@ const int spacing = 36;
QSizeF size(1000, 800);
const qreal lineWidth = 1000;
QString strings[lines];
+QGLWidget *testWidget = 0;
void paint_QTextLayout(QPainter &p, bool useCache)
{
@@ -105,7 +103,6 @@ void paint_QTextLayout_cache(QPainter &p)
paint_QTextLayout(p, true);
}
-#ifdef HAVE_STATICTEXT
void paint_QStaticText(QPainter &p, bool useOptimizations)
{
static QStaticText *staticText[lines];
@@ -113,7 +110,10 @@ void paint_QStaticText(QPainter &p, bool useOptimizations)
if (first) {
for (int i = 0; i < lines; ++i) {
staticText[i] = new QStaticText(strings[i]);
- staticText[i]->setUseBackendOptimizations(useOptimizations);
+ if (useOptimizations)
+ staticText[i]->setPerformanceHint(QStaticText::AggressiveCaching);
+ else
+ staticText[i]->setPerformanceHint(QStaticText::ModerateCaching);
}
first = false;
}
@@ -133,7 +133,6 @@ void paint_QStaticText_optimizations(QPainter &p)
{
paint_QStaticText(p, true);
}
-#endif
void paint_QPixmapCachedText(QPainter &p)
{
@@ -160,6 +159,15 @@ void paint_QPixmapCachedText(QPainter &p)
void paint_RoundedRect(QPainter &p)
{
+ static bool first = true;
+ if (first) {
+ if (testWidget) {
+ QGLFormat format = testWidget->format();
+ if (!format.sampleBuffers())
+ qWarning() << "Cannot paint antialiased rounded rect without sampleBuffers";
+ }
+ first = false;
+ }
p.setRenderHint(QPainter::Antialiasing, true);
p.setPen(Qt::black);
p.setBrush(Qt::red);
@@ -174,27 +182,101 @@ void paint_RoundedRect(QPainter &p)
void paint_QPixmapCachedRoundedRect(QPainter &p)
{
static bool first = true;
- static QPixmap cacheRect[lines];
+ static QPixmap cacheRect;
if (first) {
- for (int i = 0; i < lines; ++i) {
- QSize size((i+1)*50, spacing-1);
- cacheRect[i] = QPixmap(size);
- cacheRect[i].fill(Qt::transparent);
- QPainter paint(&cacheRect[i]);
- paint.setRenderHint(QPainter::Antialiasing);
- paint.setPen(Qt::black);
- paint.setBrush(Qt::red);
- paint.drawRoundedRect(QRect(QPoint(0,0), size), 8, 8);
+ const int pw = 0;
+ const int radius = 8;
+ cacheRect = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2);
+ cacheRect.fill(Qt::transparent);
+ QPainter paint(&cacheRect);
+ paint.setRenderHint(QPainter::Antialiasing);
+ paint.setPen(Qt::black);
+ paint.setBrush(Qt::red);
+ if (pw%2)
+ paint.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, cacheRect.width()-(pw+1), cacheRect.height()-(pw+1)), radius, radius);
+ else
+ paint.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, cacheRect.width()-pw, cacheRect.height()-pw), radius, radius);
+
+ first = false;
+ }
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ QSize size((j+1)*50, spacing-1);
+
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true);
+
+ const int pw = 0;
+
+ int xOffset = (cacheRect.width()-1)/2;
+ int yOffset = (cacheRect.height()-1)/2;
+
+ QMargins margins(xOffset, yOffset, xOffset, yOffset);
+ QTileRules rules(Qt::StretchTile, Qt::StretchTile);
+ //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects
+ qDrawBorderPixmap(&p, QRect(-pw/2, j*spacing-pw/2, size.width()+pw, size.height()+pw), margins, cacheRect, cacheRect.rect(), margins, rules);
}
+ }
+}
+
+void paint_QPixmap63x63_opaque(QPainter &p)
+{
+ static bool first = true;
+ static QPixmap pm;
+ if (first) {
+ pm.load("data/63x63_opaque.png");
first = false;
}
for (int i = 0; i < count; i++) {
for (int j = 0; j < lines; ++j) {
- p.drawPixmap(0,j*spacing,cacheRect[j]);
+ p.drawPixmap((i%10) * 64,j*spacing, pm);
}
}
}
+void paint_QPixmap64x64_opaque(QPainter &p)
+{
+ static bool first = true;
+ static QPixmap pm;
+ if (first) {
+ pm.load("data/64x64_opaque.png");
+ first = false;
+ }
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ p.drawPixmap((i%10) * 64,j*spacing, pm);
+ }
+ }
+}
+
+void paint_QPixmap63x63(QPainter &p)
+{
+ static bool first = true;
+ static QPixmap pm;
+ if (first) {
+ pm.load("data/63x63.png");
+ first = false;
+ }
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ p.drawPixmap((i%10) * 64,j*spacing, pm);
+ }
+ }
+}
+
+void paint_QPixmap64x64(QPainter &p)
+{
+ static bool first = true;
+ static QPixmap pm;
+ if (first) {
+ pm.load("data/64x64.png");
+ first = false;
+ }
+ for (int i = 0; i < count; i++) {
+ for (int j = 0; j < lines; ++j) {
+ p.drawPixmap((i%10) * 64,j*spacing, pm);
+ }
+ }
+}
typedef void(*PaintFunc)(QPainter &);
struct {
@@ -203,13 +285,15 @@ struct {
} funcs[] = {
{ "QTextLayoutNoCache", &paint_QTextLayout_noCache },
{ "QTextLayoutWithCache", &paint_QTextLayout_cache },
-#ifdef HAVE_STATICTEXT
{ "QStaticTextNoBackendOptimizations", &paint_QStaticText_noOptimizations },
{ "QStaticTextWithBackendOptimizations", &paint_QStaticText_optimizations },
-#endif
{ "CachedText", &paint_QPixmapCachedText },
{ "RoundedRect", &paint_RoundedRect },
{ "CachedRoundedRect", &paint_QPixmapCachedRoundedRect },
+ { "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque },
+ { "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque },
+ { "QPixmap63x63", &paint_QPixmap63x63 },
+ { "QPixmap64x64", &paint_QPixmap64x64 },
{ 0, 0 }
};
@@ -231,7 +315,7 @@ public:
void paintEvent(QPaintEvent *) {
static int last = 0;
static bool firstRun = true;
- if (firstRun == 0) {
+ if (firstRun) {
timer.start();
firstRun = false;
} else {
@@ -297,11 +381,11 @@ int main(int argc, char *argv[])
QWidget w;
QGLFormat format = QGLFormat::defaultFormat();
format.setSampleBuffers(sampleBuffers);
- MyGLWidget *glw = new MyGLWidget(format);
- glw->setAutoFillBackground(false);
+ testWidget = new MyGLWidget(format);
+ testWidget->setAutoFillBackground(false);
QVBoxLayout *layout = new QVBoxLayout(&w);
w.setLayout(layout);
- layout->addWidget(glw);
+ layout->addWidget(testWidget);
w.showFullScreen();
app.exec();
diff --git a/tests/benchmarks/gui/painting/painting.pro b/tests/benchmarks/gui/painting/painting.pro
index 878567d..2c042b5 100644
--- a/tests/benchmarks/gui/painting/painting.pro
+++ b/tests/benchmarks/gui/painting/painting.pro
@@ -2,4 +2,5 @@ TEMPLATE = subdirs
SUBDIRS = \
qpainter \
qregion \
- qtransform
+ qtransform \
+ qtracebench
diff --git a/tests/benchmarks/gui/painting/qtracebench/qtracebench.pro b/tests/benchmarks/gui/painting/qtracebench/qtracebench.pro
new file mode 100644
index 0000000..56ec8bb
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/qtracebench.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qtracebench
+
+INCLUDEPATH += . $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src
+
+RESOURCES += qtracebench.qrc
+
+SOURCES += tst_qtracebench.cpp
+
diff --git a/tests/benchmarks/gui/painting/qtracebench/qtracebench.qrc b/tests/benchmarks/gui/painting/qtracebench/qtracebench.qrc
new file mode 100644
index 0000000..5569550
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/qtracebench.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource>
+ <file>traces/basicdrawing.trace</file>
+ <file>traces/webkit.trace</file>
+ <file>traces/textedit.trace</file>
+ <file>traces/creator.trace</file>
+ <file>traces/qmlphoneconcept.trace</file>
+ <file>traces/qmlsamegame.trace</file>
+ </qresource>
+</RCC>
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/basicdrawing.trace b/tests/benchmarks/gui/painting/qtracebench/traces/basicdrawing.trace
new file mode 100644
index 0000000..0241d08
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/basicdrawing.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/creator.trace b/tests/benchmarks/gui/painting/qtracebench/traces/creator.trace
new file mode 100644
index 0000000..55ee9e1
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/creator.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/qmlphoneconcept.trace b/tests/benchmarks/gui/painting/qtracebench/traces/qmlphoneconcept.trace
new file mode 100644
index 0000000..835ebfa
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/qmlphoneconcept.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/qmlsamegame.trace b/tests/benchmarks/gui/painting/qtracebench/traces/qmlsamegame.trace
new file mode 100644
index 0000000..1d76195
--- /dev/null
+++ b/tests/benchmarks/gui/painting/qtracebench/traces/qmlsamegame.trace
Binary files differ
diff --git a/tests/benchmarks/gui/painting/qtracebench/traces/textedit.trace b/tests/benchmarks/gui/painting/qtracebench/traces/textedit.trace
new file mode 100644