From 960ff0590e99b28bc72d3aa104794bfa13eda2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 10 Mar 2010 12:58:33 +0100 Subject: Compile with Qt3Support in a ScratchBox environment. Reviewed-by: Tom Cooksey --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 2b5f2f4..5f0d920 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -64,6 +64,7 @@ // #define QT_OPENGL_CACHE_AS_VBOS +#include "qglgradientcache_p.h" #include "qpaintengineex_opengl2_p.h" #include //for memcpy @@ -80,7 +81,6 @@ #include #include -#include "qglgradientcache_p.h" #include "qglengineshadermanager_p.h" #include "qgl2pexvertexarray_p.h" #include "qtriangulatingstroker_p.h" -- cgit v0.12 From 9bba92715d96939e4d36c6ea42e8b466756bf891 Mon Sep 17 00:00:00 2001 From: Alexader Karaivanov Date: Wed, 10 Mar 2010 12:42:39 +0100 Subject: Fixes Q3ListViewItem grandchildren not sorted if item has one child Q3ListViewItem::sortChildItems() used to exits early if there is only 1 child item and leaves grandchildren unsorted. Merge-request: 2260 Reviewed-by: Olivier Goffart --- src/qt3support/itemviews/q3listview.cpp | 9 ++- tests/auto/q3listview/tst_q3listview.cpp | 126 ++++++++++++++++++++++++++++++- 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/src/qt3support/itemviews/q3listview.cpp b/src/qt3support/itemviews/q3listview.cpp index 12dad84..4900827 100644 --- a/src/qt3support/itemviews/q3listview.cpp +++ b/src/qt3support/itemviews/q3listview.cpp @@ -1324,8 +1324,15 @@ void Q3ListViewItem::sortChildItems(int column, bool ascending) const int nColumns = (listView() ? listView()->columns() : 0); // and don't sort if we already have the right sorting order - if (column > nColumns || childItem == 0 || childItem->siblingItem == 0) + if (column > nColumns || childItem == 0) return; + + // If there is just one child, just sort its children + if (childItem->siblingItem == 0) { + if (childItem->isOpen()) + childItem->sortChildItems(column, ascending); + return; + } // make an array for qHeapSort() Q3ListViewPrivate::SortableItem * siblings diff --git a/tests/auto/q3listview/tst_q3listview.cpp b/tests/auto/q3listview/tst_q3listview.cpp index 4de6f95..56fa25f 100644 --- a/tests/auto/q3listview/tst_q3listview.cpp +++ b/tests/auto/q3listview/tst_q3listview.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include #include @@ -87,6 +88,8 @@ public slots: private slots: void getSetCheck(); void sortchild(); + void sortchild2(); // item -> item -> 3 items + void sortchild3(); // item -> 3 items void takeItem_data(); void takeItem(); void selections_mouseClick_data(); @@ -262,7 +265,7 @@ void tst_Q3ListView::sortchild() QVERIFY( item == item1 ); listview->setSorting( 0, FALSE ); - + item = listview->firstChild(); QVERIFY( item == item1 ); item = item->itemBelow(); @@ -291,6 +294,127 @@ void tst_Q3ListView::sortchild() delete listview; } +void tst_Q3ListView::sortchild2() +{ + Q3ListView* listview = new Q3ListView( 0 ); + + listview->addColumn( "" ); + + Q3ListViewItem* item1 = new Q3ListViewItem( listview, "zzz" ); + Q3ListViewItem* item2 = new Q3ListViewItem( listview, "hhh" ); + Q3ListViewItem* item3 = new Q3ListViewItem( listview, "bbb" ); + Q3ListViewItem* item4 = new Q3ListViewItem( listview, "jjj" ); + Q3ListViewItem* item5 = new Q3ListViewItem( listview, "ddd" ); + Q3ListViewItem* item6 = new Q3ListViewItem( listview, "lll" ); + + Q3ListViewItem* item31 = new Q3ListViewItem( item3, "bbb-level2" ); + + Q3ListViewItem* item31b = new Q3ListViewItem( item31, "234" ); + Q3ListViewItem* item31c = new Q3ListViewItem( item31, "345" ); + Q3ListViewItem* item31a = new Q3ListViewItem( item31, "123" ); + + listview->setOpen( item3, TRUE ); + listview->setOpen( item31, TRUE ); + + listview->setSorting( 0, TRUE ); + listview->show(); + + Q3ListViewItem *item = listview->firstChild(); + QVERIFY( item == item3 ); + item = item->itemBelow(); + QVERIFY( item == item31 ); + item = item->itemBelow(); + QVERIFY( item == item31a ); + item = item->itemBelow(); + QVERIFY( item == item31b ); + item = item->itemBelow(); + QVERIFY( item == item31c ); + item = item->itemBelow(); + QVERIFY( item == item5 ); + item = item->itemBelow(); + QVERIFY( item == item2 ); + item = item->itemBelow(); + QVERIFY( item == item4 ); + item = item->itemBelow(); + QVERIFY( item == item6 ); + item = item->itemBelow(); + QVERIFY( item == item1 ); + + listview->setSorting( 0, FALSE ); + + item = listview->firstChild(); + QVERIFY( item == item1 ); + item = item->itemBelow(); + QVERIFY( item == item6 ); + item = item->itemBelow(); + QVERIFY( item == item4 ); + item = item->itemBelow(); + QVERIFY( item == item2 ); + item = item->itemBelow(); + QVERIFY( item == item5 ); + item = item->itemBelow(); + QVERIFY( item == item3 ); + item = item->itemBelow(); + QVERIFY( item == item31 ); + item = item->itemBelow(); + QVERIFY( item == item31c ); + item = item->itemBelow(); + QVERIFY( item == item31b ); + item = item->itemBelow(); + QVERIFY( item == item31a ); + + item = listview->firstChild(); + item->moveItem( item->itemBelow() ); + + listview->setSorting( 0, FALSE ); + QVERIFY( item == listview->firstChild() ); + + delete listview; +} + +void tst_Q3ListView::sortchild3() +{ + Q3ListView* listview = new Q3ListView( 0 ); + + listview->addColumn( "" ); + + Q3ListViewItem* item3 = new Q3ListViewItem( listview, "bbb" ); + + + Q3ListViewItem* item31b = new Q3ListViewItem( item3, "234" ); + Q3ListViewItem* item31c = new Q3ListViewItem( item3, "345" ); + Q3ListViewItem* item31a = new Q3ListViewItem( item3, "123" ); + + listview->setOpen( item3, TRUE ); + + listview->setSorting( 0, TRUE ); + listview->show(); + + Q3ListViewItem *item = listview->firstChild(); + QVERIFY( item == item3 ); + item = item->itemBelow(); + QVERIFY( item == item31a ); + item = item->itemBelow(); + QVERIFY( item == item31b ); + item = item->itemBelow(); + QVERIFY( item == item31c ); + item = item->itemBelow(); + + listview->setSorting( 0, FALSE ); + + item = listview->firstChild(); + QVERIFY( item == item3 ); + item = item->itemBelow(); + QVERIFY( item == item31c ); + item = item->itemBelow(); + QVERIFY( item == item31b ); + item = item->itemBelow(); + QVERIFY( item == item31a ); + + delete listview; +} + + void tst_Q3ListView::takeItem_data() { QTest::addColumn("selectionMode"); -- cgit v0.12 From 01a045084ad45da37e6b79938354c82419c0a83e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lind?= Date: Wed, 10 Mar 2010 13:34:51 +0100 Subject: Added configure check to diasable building QtDeclarative when Qt is not building the QtScript module --- configure | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/configure b/configure index 71056b6..60bcc67 100755 --- a/configure +++ b/configure @@ -5962,19 +5962,6 @@ if [ "$CFG_NETWORKMANAGER" = "auto" ]; then fi fi -if [ -f "$relpath/src/declarative/declarative.pro" ]; then - if [ "$CFG_DECLARATIVE" = "auto" ]; then - CFG_DECLARATIVE=yes - fi -else - if [ "$CFG_DECLARATIVE" = "auto" ] || [ "$CFG_DECLARATIVE" = "no" ]; then - CFG_DECLARATIVE=no - else - echo "Error: Unable to locate the qt-declarative package. Refer to the documentation on how to build the package." - exit 1 - fi -fi - if [ "$CFG_JAVASCRIPTCORE_JIT" = "yes" ] || [ "$CFG_JAVASCRIPTCORE_JIT" = "auto" ]; then if [ "$CFG_ARCH" = "arm" ] || [ "$CFG_ARCH" = "armv6" ]; then "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/javascriptcore-jit "javascriptcore-jit" $L_FLAGS $I_FLAGS $l_FLAGS @@ -6629,12 +6616,6 @@ else QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SVG" fi -if [ "$CFG_DECLARATIVE" = "yes" ]; then - QT_CONFIG="$QT_CONFIG declarative" -else - QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DECLARATIVE" -fi - if [ "$CFG_WEBKIT" = "auto" ]; then CFG_WEBKIT="$canBuildWebKit" fi @@ -6674,6 +6655,27 @@ else QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_SCRIPTTOOLS" fi + +if [ "$CFG_DECLARATIVE" = "yes" ]; then + if [ "$CFG_SCRIPT" = "no" ]; then + echo "Error: QtDeclarative was requested, but it can't be built due to QtScript being disabled." + exit 1 + fi +fi +if [ "$CFG_DECLARATIVE" = "auto" ]; then + if [ "$CFG_SCRIPT" = "no" ]; then + CFG_DECLARATIVE=no + else + CFG_DECLARATIVE=yes + fi +fi + +if [ "$CFG_DECLARATIVE" = "yes" ]; then + QT_CONFIG="$QT_CONFIG declarative" +else + QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_DECLARATIVE" +fi + if [ "$CFG_EXCEPTIONS" = "no" ]; then case "$COMPILER" in g++*) -- cgit v0.12 From ef9e7168a8ed3e8149204cf6c604a38db35245c0 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 10 Mar 2010 14:44:37 +0100 Subject: Cocoa: Fix misaligned text between format changes This reverts part of commit e008504b5ec34975e34adf3b1a2b7170d0e4dd38. The original commit aimed to round up all fractional numbers for the font to "improve appearance". Rounding up the last advance of a set of advances in a glyph layout, however, breaks text layout completely, since the layout of text will be different depending on how many text lines is used to represent it (since the last glyph in each line will have a higher advance than the others.) This was e.g. visible in Qt Creator when turning on whitespace visualization, as all spaces then created a format change, thus a new text line in the text layout, and hence an increase of X pixels in the positioning of the text after the space, where 0.0 < X < 1.0. I see no negative results of removing the rounding, but if there are any problems, it has to be fixed in the usage of the advances not in the advances themselves. Task-number: QTCREATORBUG-381, QTBUG-8791 Reviewed-by: mae --- src/gui/text/qfontengine_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 48bc635..8588214 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -308,7 +308,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay CTFontGetAdvancesForGlyphs(runFont, kCTFontHorizontalOrientation, tmpGlyphs + glyphCount - 1, &lastGlyphAdvance, 1); outGlyphs[rtl ? 0 : (glyphCount - 1)] = tmpGlyphs[glyphCount - 1] | fontIndex; - outAdvances_x[rtl ? 0 : (glyphCount - 1)] = QFixed::fromReal(lastGlyphAdvance.width).ceil(); + outAdvances_x[rtl ? 0 : (glyphCount - 1)] = QFixed::fromReal(lastGlyphAdvance.width); } outGlyphs += glyphCount; outAttributes += glyphCount; -- cgit v0.12 From c94db224c6abb8ed9e214bb96a14b69eb1c557ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 10 Mar 2010 15:22:21 +0100 Subject: Compile fix when Qt3Support is enabled for devices using EGL. Reviewed-by: Samuel --- src/opengl/gl2paintengineex/qglgradientcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp index 192e01c..a1495dd 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache.cpp +++ b/src/opengl/gl2paintengineex/qglgradientcache.cpp @@ -39,10 +39,10 @@ ** ****************************************************************************/ +#include "qglgradientcache_p.h" #include #include -#include "qglgradientcache_p.h" QT_BEGIN_NAMESPACE -- cgit v0.12 From 7ddf13c8fba2aadf00c0d6c822c6b4acbd3bd54f Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 10 Mar 2010 13:34:52 +0100 Subject: Make calls to QGLFormat::set*BufferSize also update flags Reviewed-By: Trond --- src/opengl/qgl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 73cd6a8..7839191 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -766,6 +766,7 @@ void QGLFormat::setSamples(int numSamples) return; } d->numSamples = numSamples; + setSampleBuffers(numSamples > 0); } /*! @@ -904,6 +905,7 @@ void QGLFormat::setDepthBufferSize(int size) return; } d->depthSize = size; + setDepth(size > 0); } /*! @@ -1017,7 +1019,7 @@ void QGLFormat::setAlphaBufferSize(int size) return; } d->alphaSize = size; - setOption(QGL::AlphaChannel); + setAlpha(size > 0); } /*! @@ -1044,6 +1046,7 @@ void QGLFormat::setAccumBufferSize(int size) return; } d->accumSize = size; + setAccum(size > 0); } /*! @@ -1069,6 +1072,7 @@ void QGLFormat::setStencilBufferSize(int size) return; } d->stencilSize = size; + setStencil(size > 0); } /*! -- cgit v0.12 From 9bf426a2af27ad5bfdb35706c3ed48e77f654f4d Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 10 Mar 2010 14:50:59 +0100 Subject: Update QGLFormat from EGLConfig properly Previously, some members of QGLFormat (like alphaBufferSize) would be left to the initial -1 value. Reviewed-By: TrustMe --- src/opengl/qgl_egl.cpp | 70 ++++++++++++++++++--------------------- src/opengl/qgl_egl_p.h | 2 +- src/opengl/qgl_qws.cpp | 2 +- src/opengl/qgl_wince.cpp | 2 +- src/opengl/qgl_x11egl.cpp | 5 ++- src/opengl/qglpixelbuffer_egl.cpp | 2 +- 6 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 3d146b7..c08d6fd 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -111,46 +111,40 @@ void qt_eglproperties_set_glformat(QEglProperties& eglProperties, const QGLForma eglProperties.setValue(EGL_SAMPLE_BUFFERS, sampleCount ? 1 : 0); } - // Updates "format" with the parameters of the selected configuration. -void qt_egl_update_format(const QEglContext& context, QGLFormat& format) +void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config) { - EGLint value = 0; - - if (context.configAttrib(EGL_RED_SIZE, &value)) - format.setRedBufferSize(value); - if (context.configAttrib(EGL_GREEN_SIZE, &value)) - format.setGreenBufferSize(value); - if (context.configAttrib(EGL_BLUE_SIZE, &value)) - format.setBlueBufferSize(value); - if (context.configAttrib(EGL_ALPHA_SIZE, &value)) { - format.setAlpha(value != 0); - if (format.alpha()) - format.setAlphaBufferSize(value); - } - - if (context.configAttrib(EGL_DEPTH_SIZE, &value)) { - format.setDepth(value != 0); - if (format.depth()) - format.setDepthBufferSize(value); - } - - if (context.configAttrib(EGL_LEVEL, &value)) - format.setPlane(value); - - if (context.configAttrib(EGL_SAMPLE_BUFFERS, &value)) { - format.setSampleBuffers(value != 0); - if (format.sampleBuffers()) { - context.configAttrib(EGL_SAMPLES, &value); - format.setSamples(value); - } - } - - if (context.configAttrib(EGL_STENCIL_SIZE, &value)) { - format.setStencil(value != 0); - if (format.stencil()) - format.setStencilBufferSize(value); - } + EGLint redSize = 0; + EGLint greenSize = 0; + EGLint blueSize = 0; + EGLint alphaSize = 0; + EGLint depthSize = 0; + EGLint stencilSize = 0; + EGLint sampleCount = 0; + EGLint level = 0; + + EGLDisplay display = QEgl::display(); + eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize); + eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize); + eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueSize); + eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaSize); + eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize); + eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize); + eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount); + eglGetConfigAttrib(display, config, EGL_LEVEL, &level); + + format.setRedBufferSize(redSize); + format.setGreenBufferSize(greenSize); + format.setBlueBufferSize(blueSize); + format.setAlphaBufferSize(alphaSize); + format.setDepthBufferSize(depthSize); + format.setStencilBufferSize(stencilSize); + format.setSamples(sampleCount); + format.setPlane(level + 1); // EGL calls level 0 "normal" whereas Qt calls 1 "normal" + format.setDirectRendering(true); // All EGL contexts are direct-rendered + format.setRgba(true); // EGL doesn't support colour index rendering + format.setStereo(false); // EGL doesn't support stereo buffers + format.setAccumBufferSize(0); // EGL doesn't support accululation buffers // Clear the EGL error state because some of the above may // have errored out because the attribute is not applicable diff --git a/src/opengl/qgl_egl_p.h b/src/opengl/qgl_egl_p.h index 6b65227..43793cd 100644 --- a/src/opengl/qgl_egl_p.h +++ b/src/opengl/qgl_egl_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE class QGLFormat; void qt_eglproperties_set_glformat(QEglProperties& props, const QGLFormat& format); -void qt_egl_update_format(const QEglContext& context, QGLFormat& format); +void qt_glformat_from_eglconfig(QGLFormat& format, const EGLConfig config); QT_END_NAMESPACE diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp index f72f051..96b2454 100644 --- a/src/opengl/qgl_qws.cpp +++ b/src/opengl/qgl_qws.cpp @@ -200,7 +200,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) } // Inform the higher layers about the actual format properties. - qt_egl_update_format(*(d->eglContext), d->glFormat); + qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config()); // Create a new context for the configuration. if (!d->eglContext->createContext diff --git a/src/opengl/qgl_wince.cpp b/src/opengl/qgl_wince.cpp index 3bf7f3a..fefcca2 100644 --- a/src/opengl/qgl_wince.cpp +++ b/src/opengl/qgl_wince.cpp @@ -163,7 +163,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) } // Inform the higher layers about the actual format properties. - qt_egl_update_format(*(d->eglContext), d->glFormat); + qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config()); // Create a new context for the configuration. if (!d->eglContext->createContext diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index a7c92cf..fe87c65 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -216,9 +216,8 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) const_cast(shareContext)->d_func()->sharing = true; } - // Inform the higher layers about the actual format properties. - qt_egl_update_format(*(d->eglContext), d->glFormat); - + // Inform the higher layers about the actual format properties + qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config()); // Do don't create the EGLSurface for everything. // QWidget - yes, create the EGLSurface and store it in QGLContextPrivate::eglSurface diff --git a/src/opengl/qglpixelbuffer_egl.cpp b/src/opengl/qglpixelbuffer_egl.cpp index ee0714f..db9e754 100644 --- a/src/opengl/qglpixelbuffer_egl.cpp +++ b/src/opengl/qglpixelbuffer_egl.cpp @@ -113,7 +113,7 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge } // Retrieve the actual format properties. - qt_egl_update_format(*ctx, format); + qt_glformat_from_eglconfig(format, ctx->config()); // Create the attributes needed for the pbuffer. QEglProperties attribs; -- cgit v0.12 From 1ceb2ec18056c41c040e3087f79860b7eb7b9d3f Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 10 Mar 2010 15:25:38 +0100 Subject: Update tst_QGL::getSetCheck to check for new (correct) behaviour Reviewed-By: Trond --- tests/auto/qgl/tst_qgl.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index d89e463..15c0b66 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -227,12 +227,12 @@ void tst_QGL::getSetCheck() QCOMPARE(false, obj1.alpha()); QVERIFY(!obj1.testOption(QGL::AlphaChannel)); QVERIFY(obj1.testOption(QGL::NoAlphaChannel)); - obj1.setAlphaBufferSize(0); + obj1.setAlphaBufferSize(1); QCOMPARE(true, obj1.alpha()); // setAlphaBufferSize() enables alpha. - QCOMPARE(0, obj1.alphaBufferSize()); + QCOMPARE(1, obj1.alphaBufferSize()); QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size -2147483648"); obj1.setAlphaBufferSize(TEST_INT_MIN); - QCOMPARE(0, obj1.alphaBufferSize()); // Makes no sense with a negative buffer size + QCOMPARE(1, obj1.alphaBufferSize()); // Makes no sense with a negative buffer size obj1.setAlphaBufferSize(3); QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size -1"); obj1.setAlphaBufferSize(-1); @@ -243,11 +243,11 @@ void tst_QGL::getSetCheck() // int QGLFormat::stencilBufferSize() // void QGLFormat::setStencilBufferSize(int) QCOMPARE(-1, obj1.stencilBufferSize()); - obj1.setStencilBufferSize(0); - QCOMPARE(0, obj1.stencilBufferSize()); + obj1.setStencilBufferSize(1); + QCOMPARE(1, obj1.stencilBufferSize()); QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size -2147483648"); obj1.setStencilBufferSize(TEST_INT_MIN); - QCOMPARE(0, obj1.stencilBufferSize()); // Makes no sense with a negative buffer size + QCOMPARE(1, obj1.stencilBufferSize()); // Makes no sense with a negative buffer size obj1.setStencilBufferSize(3); QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size -1"); obj1.setStencilBufferSize(-1); @@ -352,6 +352,7 @@ void tst_QGL::getSetCheck() // bool QGLFormat::accum() // void QGLFormat::setAccum(bool) + obj1.setAccumBufferSize(0); QCOMPARE(false, obj1.accum()); QVERIFY(!obj1.testOption(QGL::AccumBuffer)); QVERIFY(obj1.testOption(QGL::NoAccumBuffer)); -- cgit v0.12 From 477a3f2720710130dad88a1e8391f7eaf24ffb38 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 10 Mar 2010 14:17:50 +0100 Subject: Fixed assert failure when drawing dashes with raster engine. Reviewed-by: Samuel --- src/gui/painting/qpaintengine_raster.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index bfcf7db..03d0825 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1725,9 +1725,10 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) if (patternLength > 0) { int n = qFloor(dashOffset / patternLength); dashOffset -= n * patternLength; - while (dashOffset > pattern.at(dashIndex)) { + while (dashOffset >= pattern.at(dashIndex)) { dashOffset -= pattern.at(dashIndex); - dashIndex = (dashIndex + 1) % pattern.size(); + if (++dashIndex >= pattern.size()) + dashIndex = 0; inDash = !inDash; } } @@ -1738,7 +1739,6 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) const QLineF *lines = reinterpret_cast(path.points()); for (int i = 0; i < lineCount; ++i) { - dashOffset = s->lastPen.dashOffset(); if (lines[i].p1() == lines[i].p2()) { if (s->lastPen.capStyle() != Qt::FlatCap) { QPointF p = lines[i].p1(); @@ -3626,13 +3626,14 @@ void QRasterPaintEnginePrivate::rasterizeLine_dashed(QLineF line, } else { *dashOffset = 0; *inDash = !(*inDash); - *dashIndex = (*dashIndex + 1) % pattern.size(); + if (++*dashIndex >= pattern.size()) + *dashIndex = 0; length -= dash; l.setLength(dash); line.setP1(l.p2()); } - if (rasterize && dash != 0) + if (rasterize && dash > 0) rasterizer->rasterizeLine(l.p1(), l.p2(), width / dash, squareCap); } } -- cgit v0.12 From ee6c26115959f46621f5a45f3fbe4a49989fd095 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 10 Mar 2010 12:51:46 +0100 Subject: Added clipping to the dashed stroke processor in the GL2 engine. Without clipping, the stroker could consume a huge amount of memory when scaling up cosmetic, dashed strokes. I also made QDashStroker clip more aggressively. Task-number: QTBUG-7832 Reviewed-by: Samuel --- src/gui/painting/qstroker.cpp | 116 +++++++++++++++++---- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 10 +- .../gl2paintengineex/qtriangulatingstroker.cpp | 5 +- .../gl2paintengineex/qtriangulatingstroker_p.h | 4 +- 4 files changed, 105 insertions(+), 30 deletions(-) diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 16e3c38..9740fce 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -1043,6 +1043,47 @@ QVector QDashStroker::patternForStyle(Qt::PenStyle style) return pattern; } +static inline bool lineRectIntersectsRect(qfixed2d p1, qfixed2d p2, const qfixed2d &tl, const qfixed2d &br) +{ + return ((p1.x > tl.x || p2.x > tl.x) && (p1.x < br.x || p2.x < br.x) + && (p1.y > tl.y || p2.y > tl.y) && (p1.y < br.y || p2.y < br.y)); +} + +// If the line intersects the rectangle, this function will return true. +static bool lineIntersectsRect(qfixed2d p1, qfixed2d p2, const qfixed2d &tl, const qfixed2d &br) +{ + if (!lineRectIntersectsRect(p1, p2, tl, br)) + return false; + if (p1.x == p2.x || p1.y == p2.y) + return true; + + if (p1.y > p2.y) + qSwap(p1, p2); // make p1 above p2 + qfixed2d u; + qfixed2d v; + qfixed2d w = {p2.x - p1.x, p2.y - p1.y}; + if (p1.x < p2.x) { + // backslash + u.x = tl.x - p1.x; u.y = br.y - p1.y; + v.x = br.x - p1.x; v.y = tl.y - p1.y; + } else { + // slash + u.x = tl.x - p1.x; u.y = tl.y - p1.y; + v.x = br.x - p1.x; v.y = br.y - p1.y; + } +#if defined(QFIXED_IS_26_6) || defined(QFIXED_IS_16_16) + qint64 val1 = qint64(u.x) * qint64(w.y) - qint64(u.y) * qint64(w.x); + qint64 val2 = qint64(v.x) * qint64(w.y) - qint64(v.y) * qint64(w.x); + return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0); +#elif defined(QFIXED_IS_32_32) + // Cannot do proper test because it may overflow. + return true; +#else + qreal val1 = u.x * w.y - u.y * w.x; + qreal val2 = v.x * w.y - v.y * w.x; + return (val1 < 0 && val2 > 0) || (val1 > 0 && val2 < 0); +#endif +} void QDashStroker::processCurrentSubpath() { @@ -1067,9 +1108,11 @@ void QDashStroker::processCurrentSubpath() if (qFuzzyIsNull(sumLength)) return; + qreal invSumLength = qreal(1) / sumLength; + Q_ASSERT(dashCount > 0); - dashCount = (dashCount / 2) * 2; // Round down to even number + dashCount = dashCount & -2; // Round down to even number int idash = 0; // Index to current dash qreal pos = 0; // The position on the curve, 0 <= pos <= path.length @@ -1077,11 +1120,12 @@ void QDashStroker::processCurrentSubpath() qreal doffset = m_dashOffset * m_stroke_width; // make sure doffset is in range [0..sumLength) - doffset -= qFloor(doffset / sumLength) * sumLength; + doffset -= qFloor(doffset * invSumLength) * sumLength; while (doffset >= dashes[idash]) { doffset -= dashes[idash]; - idash = (idash + 1) % dashCount; + if (++idash >= dashCount) + idash = 0; } qreal estart = 0; // The elements starting position @@ -1119,12 +1163,41 @@ void QDashStroker::processCurrentSubpath() estop = estart + elen; bool done = pos >= estop; + + if (clipping) { + // Check if the entire line can be clipped away. + if (!lineIntersectsRect(prev, e, clip_tl, clip_br)) { + // Cut away full dash sequences. + elen -= qFloor(elen * invSumLength) * sumLength; + // Update dash offset. + while (!done) { + qreal dpos = pos + dashes[idash] - doffset - estart; + + Q_ASSERT(dpos >= 0); + + if (dpos > elen) { // dash extends this line + doffset = dashes[idash] - (dpos - elen); // subtract the part already used + pos = estop; // move pos to next path element + done = true; + } else { // Dash is on this line + pos = dpos + estart; + done = pos >= estop; + if (++idash >= dashCount) + idash = 0; + doffset = 0; // full segment so no offset on next. + } + } + hasMoveTo = false; + move_to_pos = e; + } + } + // Dash away... while (!done) { QPointF p2; - int idash_incr = 0; bool has_offset = doffset > 0; + bool evenDash = (idash & 1) == 0; qreal dpos = pos + dashes[idash] - doffset - estart; Q_ASSERT(dpos >= 0); @@ -1138,39 +1211,36 @@ void QDashStroker::processCurrentSubpath() p2 = cline.pointAt(dpos/elen); pos = dpos + estart; done = pos >= estop; - idash_incr = 1; + if (++idash >= dashCount) + idash = 0; doffset = 0; // full segment so no offset on next. } - if (idash % 2 == 0) { + if (evenDash) { line_to_pos.x = qt_real_to_fixed(p2.x()); line_to_pos.y = qt_real_to_fixed(p2.y()); - // If we have an offset, we're continuing a dash - // from a previous element and should only - // continue the current dash, without starting a - // new subpath. - if (!has_offset || !hasMoveTo) { - emitMoveTo(move_to_pos.x, move_to_pos.y); - hasMoveTo = true; - } - if (!clipping - // if move_to is inside... - || (move_to_pos.x > clip_tl.x && move_to_pos.x < clip_br.x - && move_to_pos.y > clip_tl.y && move_to_pos.y < clip_br.y) - // Or if line_to is inside... - || (line_to_pos.x > clip_tl.x && line_to_pos.x < clip_br.x - && line_to_pos.y > clip_tl.y && line_to_pos.y < clip_br.y)) + || lineRectIntersectsRect(move_to_pos, line_to_pos, clip_tl, clip_br)) { + // If we have an offset, we're continuing a dash + // from a previous element and should only + // continue the current dash, without starting a + // new subpath. + if (!has_offset || !hasMoveTo) { + emitMoveTo(move_to_pos.x, move_to_pos.y); + hasMoveTo = true; + } + emitLineTo(line_to_pos.x, line_to_pos.y); + } else { + hasMoveTo = false; } + move_to_pos = line_to_pos; } else { move_to_pos.x = qt_real_to_fixed(p2.x()); move_to_pos.y = qt_real_to_fixed(p2.y()); } - - idash = (idash + idash_incr) % dashCount; } // Shuffle to the next cycle... diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 5f0d920..d68a268 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1155,16 +1155,20 @@ void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen) // prepareForDraw() down below. updateMatrix(); + QRectF clip = q->state()->matrix.inverted().mapRect(q->state()->clipEnabled + ? q->state()->rectangleClip + : QRectF(0, 0, width, height)); + if (penStyle == Qt::SolidLine) { - stroker.process(path, pen); + stroker.process(path, pen, clip); } else { // Some sort of dash - dasher.process(path, pen); + dasher.process(path, pen, clip); QVectorPath dashStroke(dasher.points(), dasher.elementCount(), dasher.elementTypes()); - stroker.process(dashStroke, pen); + stroker.process(dashStroke, pen, clip); } if (opaque) { diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index 5229d3f..d952988 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -73,7 +73,7 @@ void QTriangulatingStroker::endCapOrJoinClosed(const qreal *start, const qreal * } -void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen) +void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, const QRectF &) { const qreal *pts = path.points(); const QPainterPath::ElementType *types = path.elements(); @@ -480,7 +480,7 @@ QDashedStrokeProcessor::QDashedStrokeProcessor() m_dash_stroker.setCubicToHook(qdashprocessor_cubicTo); } -void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen) +void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, const QRectF &clip) { const qreal *pts = path.points(); @@ -497,6 +497,7 @@ void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen) m_dash_stroker.setDashPattern(pen.dashPattern()); m_dash_stroker.setStrokeWidth(pen.isCosmetic() ? width * m_inv_scale : width); m_dash_stroker.setMiterLimit(pen.miterLimit()); + m_dash_stroker.setClipRect(clip); qreal curvyness = sqrt(width) * m_inv_scale / 8; if (count < 2) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index 06b8a44..956d7cc 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE class QTriangulatingStroker { public: - void process(const QVectorPath &path, const QPen &pen); + void process(const QVectorPath &path, const QPen &pen, const QRectF &clip); inline int vertexCount() const { return m_vertices.size(); } inline const float *vertices() const { return m_vertices.data(); } @@ -96,7 +96,7 @@ class QDashedStrokeProcessor public: QDashedStrokeProcessor(); - void process(const QVectorPath &path, const QPen &pen); + void process(const QVectorPath &path, const QPen &pen, const QRectF &clip); inline void addElement(QPainterPath::ElementType type, qreal x, qreal y) { m_points.add(x); -- cgit v0.12 From 9b016ce33e4d63725239945a2fcf19a8d6af14cf Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 10 Mar 2010 15:55:23 +0100 Subject: Re-enable tst_QGL::glWidgetRenderPixmap on X11/EGL QGLWidget::renderPixmap now works under X11/EGL. Tested on both Fremantle and Harmattan. Reviewed-By: TrustMe --- tests/auto/qgl/tst_qgl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 15c0b66..8ee494f 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1402,8 +1402,8 @@ void tst_QGL::glWidgetRenderPixmap() QImage reference(fb.size(), QImage::Format_RGB32); reference.fill(0xffff0000); -#ifdef QGL_EGL - QSKIP("renderPixmap() not yet supported under EGL", SkipAll); +#if defined(QGL_EGL) && !defined(Q_WS_X11) + QSKIP("renderPixmap() not yet supported under EGL on your platform", SkipAll); #endif QFUZZY_COMPARE_IMAGES(fb, reference); -- cgit v0.12