summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qdrawhelper.cpp89
-rw-r--r--src/gui/painting/qdrawhelper_avx.cpp1
-rw-r--r--src/gui/painting/qdrawhelper_sse2.cpp7
-rw-r--r--src/gui/painting/qdrawhelper_x86_p.h6
-rw-r--r--tests/auto/gui/text/qstatictext/tst_qstatictext.cpp28
5 files changed, 87 insertions, 44 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index c71d75cf94..865dab6597 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -5605,7 +5605,7 @@ static void qt_gradient_quint16(int count, const QSpan *spans, void *userData)
}
}
-inline static void qt_bitmapblit_quint32(QRasterBuffer *rasterBuffer,
+inline static void qt_bitmapblit_argb32(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride)
@@ -5614,6 +5614,15 @@ inline static void qt_bitmapblit_quint32(QRasterBuffer *rasterBuffer,
map, mapWidth, mapHeight, mapStride);
}
+inline static void qt_bitmapblit_rgba8888(QRasterBuffer *rasterBuffer,
+ int x, int y, quint32 color,
+ const uchar *map,
+ int mapWidth, int mapHeight, int mapStride)
+{
+ qt_bitmapblit_template<quint32>(rasterBuffer, x, y, ARGB2RGBA(color),
+ map, mapWidth, mapHeight, mapStride);
+}
+
inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
@@ -5725,11 +5734,11 @@ static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, in
}
#endif
-static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
- const uchar *map,
- int mapWidth, int mapHeight, int mapStride,
- const QClipData *clip)
+static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer,
+ int x, int y, quint32 color,
+ const uchar *map,
+ int mapWidth, int mapHeight, int mapStride,
+ const QClipData *clip)
{
const quint32 c = color;
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32);
@@ -5820,10 +5829,19 @@ static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer,
}
}
-static void qt_alphargbblit_quint32(QRasterBuffer *rasterBuffer,
- int x, int y, quint32 color,
- const uint *src, int mapWidth, int mapHeight, int srcStride,
- const QClipData *clip)
+static void qt_alphamapblit_rgba8888(QRasterBuffer *rasterBuffer,
+ int x, int y, quint32 color,
+ const uchar *map,
+ int mapWidth, int mapHeight, int mapStride,
+ const QClipData *clip)
+{
+ qt_alphamapblit_argb32(rasterBuffer, x, y, ARGB2RGBA(color), map, mapWidth, mapHeight, mapStride, clip);
+}
+
+static void qt_alphargbblit_argb32(QRasterBuffer *rasterBuffer,
+ int x, int y, quint32 color,
+ const uint *src, int mapWidth, int mapHeight, int srcStride,
+ const QClipData *clip)
{
const quint32 c = color;
@@ -5965,27 +5983,27 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
{
blend_color_argb,
qt_gradient_argb32,
- qt_bitmapblit_quint32,
- qt_alphamapblit_quint32,
- qt_alphargbblit_quint32,
+ qt_bitmapblit_argb32,
+ qt_alphamapblit_argb32,
+ qt_alphargbblit_argb32,
qt_rectfill_argb32
},
// Format_ARGB32,
{
blend_color_generic,
qt_gradient_argb32,
- qt_bitmapblit_quint32,
- qt_alphamapblit_quint32,
- qt_alphargbblit_quint32,
+ qt_bitmapblit_argb32,
+ qt_alphamapblit_argb32,
+ qt_alphargbblit_argb32,
qt_rectfill_nonpremul_argb32
},
// Format_ARGB32_Premultiplied
{
blend_color_argb,
qt_gradient_argb32,
- qt_bitmapblit_quint32,
- qt_alphamapblit_quint32,
- qt_alphargbblit_quint32,
+ qt_bitmapblit_argb32,
+ qt_alphamapblit_argb32,
+ qt_alphargbblit_argb32,
qt_rectfill_argb32
},
// Format_RGB16
@@ -6049,42 +6067,39 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
{
blend_color_generic,
blend_src_generic,
- qt_bitmapblit_quint32,
+ qt_bitmapblit_rgba8888,
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- qt_alphamapblit_quint32,
- qt_alphargbblit_quint32,
+ qt_alphamapblit_rgba8888,
#else
0,
- 0,
#endif
+ 0,
qt_rectfill_rgba
},
// Format_RGBA8888
{
blend_color_generic,
blend_src_generic,
- qt_bitmapblit_quint32,
+ qt_bitmapblit_rgba8888,
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- qt_alphamapblit_quint32,
- qt_alphargbblit_quint32,
+ qt_alphamapblit_rgba8888,
#else
0,
- 0,
#endif
+ 0,
qt_rectfill_nonpremul_rgba
},
// Format_RGB8888_Premultiplied
{
blend_color_generic,
blend_src_generic,
- qt_bitmapblit_quint32,
+ qt_bitmapblit_rgba8888,
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
- qt_alphamapblit_quint32,
- qt_alphargbblit_quint32,
+ qt_alphamapblit_rgba8888,
#else
0,
- 0,
#endif
+ 0,
qt_rectfill_rgba
}
};
@@ -6173,9 +6188,9 @@ void qInitDrawhelperAsm()
qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_avx;
qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_avx;
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_avx;
- qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit32_avx;
- qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit32_avx;
- qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit32_avx;
+ qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit8888_avx;
+ qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit8888_avx;
+ qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit8888_avx;
extern void qt_scale_image_argb32_on_argb32_avx(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
@@ -6198,9 +6213,9 @@ void qInitDrawhelperAsm()
qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse2;
- qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit32_sse2;
- qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit32_sse2;
- qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2;
+ qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit8888_sse2;
+ qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit8888_sse2;
+ qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit8888_sse2;
extern void qt_scale_image_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
diff --git a/src/gui/painting/qdrawhelper_avx.cpp b/src/gui/painting/qdrawhelper_avx.cpp
index 7da6ce6a20..7d42525150 100644
--- a/src/gui/painting/qdrawhelper_avx.cpp
+++ b/src/gui/painting/qdrawhelper_avx.cpp
@@ -60,6 +60,7 @@
#define qt_memfill32_sse2 qt_memfill32_avx
#define qt_memfill16_sse2 qt_memfill16_avx
#define qt_bitmapblit32_sse2 qt_bitmapblit32_avx
+#define qt_bitmapblit8888_sse2 qt_bitmapblit8888_avx
#define qt_bitmapblit16_sse2 qt_bitmapblit16_avx
#define QSimdSse2 QSimdAvx
#define qt_fetch_radial_gradient_sse2 qt_fetch_radial_gradient_avx
diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp
index a9dc5a7fb7..ea191c2ec5 100644
--- a/src/gui/painting/qdrawhelper_sse2.cpp
+++ b/src/gui/painting/qdrawhelper_sse2.cpp
@@ -470,6 +470,13 @@ void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
}
}
+void qt_bitmapblit8888_sse2(QRasterBuffer *rasterBuffer, int x, int y,
+ quint32 color,
+ const uchar *src, int width, int height, int stride)
+{
+ qt_bitmapblit32_sse2(rasterBuffer, x, y, ARGB2RGBA(color), src, width, height, stride);
+}
+
void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride)
diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h
index d64b9cec39..aee508f641 100644
--- a/src/gui/painting/qdrawhelper_x86_p.h
+++ b/src/gui/painting/qdrawhelper_x86_p.h
@@ -63,6 +63,9 @@ void qt_memfill16_sse2(quint16 *dest, quint16 value, int count);
void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride);
+void qt_bitmapblit8888_sse2(QRasterBuffer *rasterBuffer, int x, int y,
+ quint32 color,
+ const uchar *src, int width, int height, int stride);
void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride);
@@ -85,6 +88,9 @@ void qt_memfill16_avx(quint16 *dest, quint16 value, int count);
void qt_bitmapblit32_avx(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride);
+void qt_bitmapblit8888_avx(QRasterBuffer *rasterBuffer, int x, int y,
+ quint32 color,
+ const uchar *src, int width, int height, int stride);
void qt_bitmapblit16_avx(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride);
diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
index 46f97840af..4ae70fe137 100644
--- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
@@ -87,6 +87,7 @@ private slots:
void plainTextVsRichText();
+ void setPenPlainText_data();
void setPenPlainText();
void setPenRichText();
void richTextOverridesPen();
@@ -106,6 +107,8 @@ private:
QImage const m_whiteSquare;
};
+Q_DECLARE_METATYPE(QImage::Format);
+
void tst_QStaticText::initTestCase()
{
// a "blank" square; we compare against in our testfunctions to verify
@@ -615,30 +618,41 @@ void tst_QStaticText::plainTextVsRichText()
QCOMPARE(imagePlainText, imageRichText);
}
+void tst_QStaticText::setPenPlainText_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("rgb32") << QImage::Format_RGB32;
+ QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied;
+ QTest::newRow("rgbx8888") << QImage::Format_RGBX8888;
+}
+
void tst_QStaticText::setPenPlainText()
{
+ QFETCH(QImage::Format, format);
+
QFont font = QGuiApplication::font();
font.setStyleStrategy(QFont::NoAntialias);
QFontMetricsF fm(font);
- QPixmap image(qCeil(fm.width("XXXXX")), qCeil(fm.height()));
+ QImage image(qCeil(fm.width("XXXXX")), qCeil(fm.height()), format);
image.fill(Qt::white);
{
QPainter p(&image);
p.setFont(font);
- p.setPen(Qt::green);
+ p.setPen(Qt::yellow);
QStaticText staticText("XXXXX");
staticText.setTextFormat(Qt::PlainText);
p.drawStaticText(0, 0, staticText);
}
- QImage img = image.toImage();
- for (int x=0; x<img.width(); ++x) {
- for (int y=0; y<img.height(); ++y) {
- QRgb pixel = img.pixel(x, y);
+ for (int x=0; x<image.width(); ++x) {
+ for (int y=0; y<image.height(); ++y) {
+ QRgb pixel = image.pixel(x, y);
QVERIFY(pixel == QColor(Qt::white).rgba()
- || pixel == QColor(Qt::green).rgba());
+ || pixel == QColor(Qt::yellow).rgba());
}
}
}