From dd14f5ea568ce647638993da90112e71cffc9cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 17 Sep 2010 19:47:56 +0200 Subject: Fixed memory corruption issue in qt_blurImage for Indexed8 images. If transposed was set to 0 we did not check the color depth of the image and ended up with a buffer overflow. Reviewed-by: Jens Bache-Wiig --- src/gui/image/qpixmapfilter.cpp | 15 +++++++++++---- tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index 70770c4..26bffcc 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -764,10 +764,17 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp } if (transposed == 0) { - qt_memrotate90(reinterpret_cast(temp.bits()), - temp.width(), temp.height(), temp.bytesPerLine(), - reinterpret_cast(img.bits()), - img.bytesPerLine()); + if (img.depth() == 8) { + qt_memrotate90(reinterpret_cast(temp.bits()), + temp.width(), temp.height(), temp.bytesPerLine(), + reinterpret_cast(img.bits()), + img.bytesPerLine()); + } else { + qt_memrotate90(reinterpret_cast(temp.bits()), + temp.width(), temp.height(), temp.bytesPerLine(), + reinterpret_cast(img.bits()), + img.bytesPerLine()); + } } else { img = temp; } diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp index f0f087d..1f51d51 100644 --- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp +++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp @@ -72,6 +72,7 @@ private slots: void convolutionBoundingRectFor(); void convolutionDrawSubRect(); void dropShadowBoundingRectFor(); + void blurIndexed8(); void testDefaultImplementations(); }; @@ -423,6 +424,25 @@ void tst_QPixmapFilter::dropShadowBoundingRectFor() QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta - 10, -delta - 10, 0, 0)); } +void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); + +void tst_QPixmapFilter::blurIndexed8() +{ + QImage img(16, 32, QImage::Format_Indexed8); + img.setColorCount(256); + for (int i = 0; i < 256; ++i) + img.setColor(i, qRgb(i, i, i)); + + img.fill(255); + + QImage original = img; + qt_blurImage(img, 10, true, false); + QCOMPARE(original.size(), img.size()); + + original = img; + qt_blurImage(img, 10, true, true); + QCOMPARE(original.size(), QSize(img.height(), img.width())); +} QTEST_MAIN(tst_QPixmapFilter) #include "tst_qpixmapfilter.moc" -- cgit v0.12 From a65f53a09c2a5950bd8b98fd791dc413bb11f9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 17 Sep 2010 18:26:53 +0200 Subject: Fixed compilation of MeeGo graphics system without eglext.h We don't rely on this header, so there's no need to include it. Reviewed-by: Benjamin Poulain --- src/plugins/graphicssystems/meego/qmeegoextensions.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h index 7f219de..f1a74f5 100644 --- a/src/plugins/graphicssystems/meego/qmeegoextensions.h +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.h @@ -43,7 +43,6 @@ #define MEXTENSIONS_H #include -#include #include #include #include -- cgit v0.12 From 4d8adcd20af9f346d69c9da9e49c9b3cc8a10710 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 20 Sep 2010 12:41:53 +0200 Subject: Make QStaticText honor QPainter::pen() for rich text on X11 w/raster The document layou will call setPen() with the PaintContext's text color. If this is different from the current painter settings, the pen will be passed on to the paint engine. The result was that, on X11 using the raster (or opengl) engine, QStaticText would record the pen as changed even when it hadn't explicitly been changed by the document. Task-number: QTBUG-13740 Reviewed-by: Samuel --- src/gui/text/qstatictext.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 7a5dec4..9506006 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -43,6 +43,7 @@ #include "qstatictext_p.h" #include #include +#include #include @@ -654,7 +655,9 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p) p->save(); p->translate(topLeftPosition); - document.drawContents(p); + QAbstractTextDocumentLayout::PaintContext ctx; + ctx.palette.setColor(QPalette::Text, p->pen().color()); + document.documentLayout()->draw(p, ctx); p->restore(); if (textWidth >= 0.0) -- cgit v0.12 From 6930cc6f7247464f1adae143102b5a3811f25345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Sat, 18 Sep 2010 11:26:24 +0200 Subject: Give a warning in QPixmap::handle() if pixmap is not X11 class. Reviewed-by: Markus Goetz --- src/gui/image/qpixmap.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 66a861d..1e502bd 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1177,8 +1177,12 @@ Qt::HANDLE QPixmap::handle() const { #if defined(Q_WS_X11) const QPixmapData *pd = pixmapData(); - if (pd && pd->classId() == QPixmapData::X11Class) - return static_cast(pd)->handle(); + if (pd) { + if (pd->classId() == QPixmapData::X11Class) + return static_cast(pd)->handle(); + else + qWarning("QPixmap::handle(): Pixmap is not an X11 class pixmap"); + } #endif return 0; } -- cgit v0.12 From 2b230dbc9a784e577c08fa25db3e975952849297 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 20 Sep 2010 09:35:26 +0200 Subject: qtextcodec_symbian: Add few aliases Reviewed-by: Denis --- src/corelib/codecs/qtextcodec_symbian.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/codecs/qtextcodec_symbian.cpp b/src/corelib/codecs/qtextcodec_symbian.cpp index d59998f..9d7e856 100644 --- a/src/corelib/codecs/qtextcodec_symbian.cpp +++ b/src/corelib/codecs/qtextcodec_symbian.cpp @@ -122,8 +122,8 @@ static const QSymbianCodecInitData codecsData[] = { { /*271085624*/ 271085624, 114, "GB18030\0" }, { /*536929574*/ 536929574, 38, "EUC-KR\0" }, { /*536936703*/ 536936703, 0, "CP949\0" }, - { /*536936705*/ 536936705, 37, "ISO-2022-KR\0" }, - { /*536941517*/ 536941517, 36, "KS_C_5601-1987\0" } + { /*536936705*/ 536936705, 37, "ISO-2022-KR\0csISO2022KR\0" }, + { /*536941517*/ 536941517, 36, "KS_C_5601-1987\0iso-ir-149\0KS_C_5601-1989\0KSC_5601\0Korean\0csKSC56011987\0" } }; -- cgit v0.12 From bbf11b714f6430fea2a35dc370c3530afcddf8ab Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 20 Sep 2010 13:20:36 +0200 Subject: tst_qpixmapfilter: Fix compilation in namespace Reviewed-by: Samuel --- tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp index 1f51d51..12d2c57 100644 --- a/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp +++ b/tests/auto/qpixmapfilter/tst_qpixmapfilter.cpp @@ -424,7 +424,9 @@ void tst_QPixmapFilter::dropShadowBoundingRectFor() QCOMPARE(filter.boundingRectFor(rect3), rect3.adjusted(-delta - 10, -delta - 10, 0, 0)); } +QT_BEGIN_NAMESPACE void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); +QT_END_NAMESPACE void tst_QPixmapFilter::blurIndexed8() { -- cgit v0.12 From de808f3c91afaecfc9d7a9a7ea6ff7533dfd1e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 20 Sep 2010 13:53:27 +0200 Subject: Support multisampled pbuffers under Windows. Multisampled pbuffers don't work in conjunction with the render_texture extension. Now we turn off the render_texture extension if a multi- sampled format is requested. Task-number: QTBUG-13503 Reviewed-by: Samuel --- examples/opengl/pbuffers/glwidget.cpp | 4 +++- src/opengl/qglpixelbuffer.cpp | 8 +++++++- src/opengl/qglpixelbuffer_win.cpp | 34 +++++++++++++++++++++------------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/examples/opengl/pbuffers/glwidget.cpp b/examples/opengl/pbuffers/glwidget.cpp index 6f4f060..c57a510 100644 --- a/examples/opengl/pbuffers/glwidget.cpp +++ b/examples/opengl/pbuffers/glwidget.cpp @@ -62,7 +62,9 @@ GLWidget::GLWidget(QWidget *parent) , cube(0) { // create the pbuffer - pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this); + QGLFormat pbufferFormat = format(); + pbufferFormat.setSampleBuffers(false); + pbuffer = new QGLPixelBuffer(QSize(512, 512), pbufferFormat, this); setWindowTitle(tr("OpenGL pbuffers")); initializeGeometry(); } diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 9a8b243..994947b 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -67,7 +67,13 @@ when the pbuffer contents change, eliminating the need for additional copy operations. This is supported only on Windows and Mac OS X systems that provide the \c render_texture - extension. + extension. Note that under Windows, a multi-sampled pbuffer + can't be used in conjunction with the \c render_texture + extension. If a multi-sampled pbuffer is requested under + Windows, the \c render_texture extension is turned off for that + pbuffer. + + \endlist Pbuffers are provided by the OpenGL \c pbuffer extension; call diff --git a/src/opengl/qglpixelbuffer_win.cpp b/src/opengl/qglpixelbuffer_win.cpp index 8d0d105..b55f383 100644 --- a/src/opengl/qglpixelbuffer_win.cpp +++ b/src/opengl/qglpixelbuffer_win.cpp @@ -167,6 +167,11 @@ typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, con #define WGL_FLOAT_COMPONENTS_NV 0x20B0 #endif +#ifndef WGL_ARB_multisample +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif + QGLFormat pfiToQGLFormat(HDC hdc, int pfi); static void qt_format_to_attrib_list(bool has_render_texture, const QGLFormat &f, int attribs[]) @@ -226,14 +231,12 @@ static void qt_format_to_attrib_list(bool has_render_texture, const QGLFormat &f attribs[i++] = WGL_FLOAT_COMPONENTS_NV; attribs[i++] = TRUE; } - // sample buffers doesn't work in conjunction with the render_texture extension - // so igonre that for now - // if (f.sampleBuffers()) { - // attribs[i++] = WGL_SAMPLE_BUFFERS_ARB; - // attribs[i++] = 1; - // attribs[i++] = WGL_SAMPLES_ARB; - // attribs[i++] = f.samples() == -1 ? 16 : f.samples(); - // } + if (f.sampleBuffers()) { + attribs[i++] = WGL_SAMPLE_BUFFERS_ARB; + attribs[i++] = 1; + attribs[i++] = WGL_SAMPLES_ARB; + attribs[i++] = f.samples() == -1 ? 16 : f.samples(); + } attribs[i] = 0; } @@ -257,12 +260,17 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge dc = GetDC(dmy.winId()); Q_ASSERT(dc); - PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = - (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB"); + // sample buffers doesn't work in conjunction with the render_texture extension + if (f.sampleBuffers()) { + has_render_texture = false; + } else { + PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = + (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB"); - if (wglGetExtensionsStringARB) { - QString extensions(QLatin1String(wglGetExtensionsStringARB(dc))); - has_render_texture = extensions.contains(QLatin1String("WGL_ARB_render_texture")); + if (wglGetExtensionsStringARB) { + QString extensions(QLatin1String(wglGetExtensionsStringARB(dc))); + has_render_texture = extensions.contains(QLatin1String("WGL_ARB_render_texture")); + } } int attribs[40]; -- cgit v0.12 From 6c8dcd5744e2c14d122f0967de72a9e171dd9715 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 20 Sep 2010 13:53:23 +0200 Subject: Fixes QPen dash offset for OpenGL paint engines (1.x & 2.x). Task-number: QTBUG-13409 Reviewed-by: Trond --- src/opengl/gl2paintengineex/qtriangulatingstroker.cpp | 1 + src/opengl/qpaintengine_opengl.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index 9bc099d..7b0b8a2 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -509,6 +509,7 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, c m_dash_stroker.setDashPattern(pen.dashPattern()); m_dash_stroker.setStrokeWidth(cosmetic ? width * m_inv_scale : width); + m_dash_stroker.setDashOffset(pen.dashOffset()); m_dash_stroker.setMiterLimit(pen.miterLimit()); m_dash_stroker.setClipRect(clip); diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 12c487d..a5ec12f 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -921,6 +921,7 @@ static inline QPainterPath strokeForPath(const QPainterPath &path, const QPen &c stroker.setCapStyle(cpen.capStyle()); stroker.setJoinStyle(cpen.joinStyle()); stroker.setMiterLimit(cpen.miterLimit()); + stroker.setDashOffset(cpen.dashOffset()); qreal width = cpen.widthF(); if (width == 0) -- cgit v0.12