diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-29 23:20:41 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-29 23:20:41 (GMT) |
commit | 3f2be090858165d291f27a39157f76aab25d1aaa (patch) | |
tree | 6fe076c9daf7dd20da31ed0f85e96b1077a90134 | |
parent | 91119eaa185934d568d0c83e25129b0028b5a607 (diff) | |
parent | ebbab30af417dfbf3df47dec15c0e2f8d6a30fa6 (diff) | |
download | Qt-3f2be090858165d291f27a39157f76aab25d1aaa.zip Qt-3f2be090858165d291f27a39157f76aab25d1aaa.tar.gz Qt-3f2be090858165d291f27a39157f76aab25d1aaa.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:
Fix the rendering of lines with the X11 paint engine
Fix the byte order in QImage::fill for 24bpp formats
QScript: remove JSC::JSLock
QScript: document/obsolete things that does not work since the move to JSC
-rw-r--r-- | src/gui/image/qimage.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_x11.cpp | 22 | ||||
-rw-r--r-- | src/script/api/qscriptcontext.cpp | 10 | ||||
-rw-r--r-- | src/script/api/qscriptcontextinfo.cpp | 11 | ||||
-rw-r--r-- | src/script/api/qscriptcontextinfo.h | 4 | ||||
-rw-r--r-- | src/script/api/qscriptengine.cpp | 15 | ||||
-rw-r--r-- | src/script/api/qscriptengineagent.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qimage/tst_qimage.cpp | 64 | ||||
-rw-r--r-- | tests/auto/qpainter/tst_qpainter.cpp | 65 |
9 files changed, 163 insertions, 37 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 30cf758..52ba2b9 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2010,7 +2010,7 @@ void QImage::fill(uint pixel) 0, 0, d->width, d->height, d->bytes_per_line); return; } else if (d->depth == 24) { - qt_rectfill<quint24>(reinterpret_cast<quint24*>(d->data), pixel, + qt_rectfill<qrgb888>(reinterpret_cast<qrgb888*>(d->data), pixel, 0, 0, d->width, d->height, d->bytes_per_line); return; } diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 910b2df..e521e01 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -696,11 +696,10 @@ void QX11PaintEngine::drawLines(const QLine *lines, int lineCount) linef = d->matrix.map(QLineF(lines[i])); } if (clipLine(&linef, d->polygonClipper.boundingRect())) { - int x1 = qRound(linef.x1() + aliasedCoordinateDelta); - int y1 = qRound(linef.y1() + aliasedCoordinateDelta); - int x2 = qRound(linef.x2() + aliasedCoordinateDelta); - int y2 = qRound(linef.y2() + aliasedCoordinateDelta); - + int x1 = qFloor(linef.x1() + aliasedCoordinateDelta); + int y1 = qFloor(linef.y1() + aliasedCoordinateDelta); + int x2 = qFloor(linef.x2() + aliasedCoordinateDelta); + int y2 = qFloor(linef.y2() + aliasedCoordinateDelta); XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2); } } @@ -730,11 +729,10 @@ void QX11PaintEngine::drawLines(const QLineF *lines, int lineCount) for (int i = 0; i < lineCount; ++i) { QLineF linef = d->matrix.map(lines[i]); if (clipLine(&linef, d->polygonClipper.boundingRect())) { - int x1 = qRound(linef.x1() + aliasedCoordinateDelta); - int y1 = qRound(linef.y1() + aliasedCoordinateDelta); - int x2 = qRound(linef.x2() + aliasedCoordinateDelta); - int y2 = qRound(linef.y2() + aliasedCoordinateDelta); - + int x1 = qFloor(linef.x1() + aliasedCoordinateDelta); + int y1 = qFloor(linef.y1() + aliasedCoordinateDelta); + int x2 = qFloor(linef.x2() + aliasedCoordinateDelta); + int y2 = qFloor(linef.y2() + aliasedCoordinateDelta); XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2); } } @@ -1690,8 +1688,8 @@ void QX11PaintEnginePrivate::strokePolygon_dev(const QPointF *polygonPoints, int if (clippedCount > 0) { QVarLengthArray<XPoint> xpoints(clippedCount); for (int i = 0; i < clippedCount; ++i) { - xpoints[i].x = qRound(clippedPoints[i].x + aliasedCoordinateDelta); - xpoints[i].y = qRound(clippedPoints[i].y + aliasedCoordinateDelta); + xpoints[i].x = qFloor(clippedPoints[i].x + aliasedCoordinateDelta); + xpoints[i].y = qFloor(clippedPoints[i].y + aliasedCoordinateDelta); } uint numberPoints = qMin(clippedCount, xlibMaxLinePoints); XPoint *pts = xpoints.data(); diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index 3f08e74..1a11100 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -323,6 +323,9 @@ QScriptValue QScriptContext::argumentsObject() const When a function is called as constructor, the thisObject() contains the newly constructed object to be initialized. + + \note This function is only guarenteed to work for a context + corresponding to native functions. */ bool QScriptContext::isCalledAsConstructor() const { @@ -413,6 +416,9 @@ void QScriptContext::setReturnValue(const QScriptValue &result) object provides access to the local variables associated with this context. + \note The activation object might not be available if there is no + active QScriptEngineAgent, as it might be optimized. + \sa argument(), argumentsObject() */ @@ -472,6 +478,10 @@ QScriptValue QScriptContext::activationObject() const activation. If \a activation is not an object, this function does nothing. + + \note For a context corresponding to a JavaScript function, this is only + guarenteed to work if there was an QScriptEngineAgent active on the + engine while the function was evaluated. */ void QScriptContext::setActivationObject(const QScriptValue &activation) { diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp index ebb1770..a90e014 100644 --- a/src/script/api/qscriptcontextinfo.cpp +++ b/src/script/api/qscriptcontextinfo.cpp @@ -53,8 +53,7 @@ QT_BEGIN_NAMESPACE current statement. If the called function is executing Qt Script code, you can obtain - the script location with the functions fileName(), lineNumber() and - columnNumber(). + the script location with the functions fileName() and lineNumber(). You can obtain the starting line number and ending line number of a Qt Script function definition with functionStartLineNumber() and @@ -317,13 +316,7 @@ int QScriptContextInfo::lineNumber() const } /*! - Returns the column number corresponding to the statement being - executed, or -1 if the column number is not available. - - The column number is only available if Qt Script code is being - executed. - - \sa lineNumber(), fileName() + \obsolete */ int QScriptContextInfo::columnNumber() const { diff --git a/src/script/api/qscriptcontextinfo.h b/src/script/api/qscriptcontextinfo.h index d0b3f21..64a1e15 100644 --- a/src/script/api/qscriptcontextinfo.h +++ b/src/script/api/qscriptcontextinfo.h @@ -69,7 +69,9 @@ public: qint64 scriptId() const; QString fileName() const; int lineNumber() const; - int columnNumber() const; +#ifdef QT_DEPRECATED + QT_DEPRECATED int columnNumber() const; +#endif QString functionName() const; FunctionType functionType() const; diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 26673f4..8560214 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -44,7 +44,6 @@ #include "CodeBlock.h" #include "Error.h" -#include "JSLock.h" #include "Interpreter.h" #include "PrototypeFunction.h" @@ -152,8 +151,7 @@ QT_BEGIN_NAMESPACE evaluation caused an exception by calling hasUncaughtException(). In that case, you can call toString() on the error object to obtain an error message. The current uncaught exception is also available - through uncaughtException(). You can obtain a human-readable - backtrace of the exception with uncaughtExceptionBacktrace(). + through uncaughtException(). Calling clearExceptions() will cause any uncaught exceptions to be cleared. @@ -1003,7 +1001,6 @@ QScriptEnginePrivate::~QScriptEnginePrivate() detachAllRegisteredScriptStrings(); qDeleteAll(m_qobjectData); qDeleteAll(m_typeInfos); - JSC::JSLock lock(false); globalData->heap.destroy(); globalData->deref(); while (freeScriptValues) { @@ -1292,7 +1289,6 @@ bool QScriptEnginePrivate::isCollecting() const void QScriptEnginePrivate::collectGarbage() { - JSC::JSLock lock(false); QScript::APIShim shim(this); globalData->heap.collectAllGarbage(); } @@ -1322,7 +1318,6 @@ JSC::JSValue QScriptEnginePrivate::evaluateHelper(JSC::ExecState *exec, intptr_t bool &compile) { Q_Q(QScriptEngine); - JSC::JSLock lock(false); // ### hmmm QBoolBlocker inEvalBlocker(inEval, true); q->currentContext()->activationObject(); //force the creation of a context for native function; @@ -2800,8 +2795,7 @@ void QScriptEnginePrivate::popContext() The exception state is cleared when evaluate() is called. - \sa uncaughtException(), uncaughtExceptionLineNumber(), - uncaughtExceptionBacktrace() + \sa uncaughtException(), uncaughtExceptionLineNumber() */ bool QScriptEngine::hasUncaughtException() const { @@ -2819,7 +2813,6 @@ bool QScriptEngine::hasUncaughtException() const message. \sa hasUncaughtException(), uncaughtExceptionLineNumber(), - uncaughtExceptionBacktrace() */ QScriptValue QScriptEngine::uncaughtException() const { @@ -2839,7 +2832,7 @@ QScriptValue QScriptEngine::uncaughtException() const Line numbers are 1-based, unless a different base was specified as the second argument to evaluate(). - \sa hasUncaughtException(), uncaughtExceptionBacktrace() + \sa hasUncaughtException() */ int QScriptEngine::uncaughtExceptionLineNumber() const { @@ -2851,7 +2844,7 @@ int QScriptEngine::uncaughtExceptionLineNumber() const /*! Returns a human-readable backtrace of the last uncaught exception. - Each line is of the form \c{<function-name>(<arguments>)@<file-name>:<line-number>}. + It is in the form \c{<function-name>()@<file-name>:<line-number>}. \sa uncaughtException() */ diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp index c3d1566..b1f131e 100644 --- a/src/script/api/qscriptengineagent.cpp +++ b/src/script/api/qscriptengineagent.cpp @@ -372,9 +372,8 @@ void QScriptEngineAgent::functionExit(qint64 scriptId, /*! This function is called when the engine is about to execute a new statement in the script identified by \a scriptId. The statement - begins on the line and column specified by \a lineNumber and \a - columnNumber. This event is not generated for native Qt Script - functions. + begins on the line and column specified by \a lineNumber + This event is not generated for native Qt Script functions. Reimplement this function to handle this event. For example, a debugger implementation could reimplement this function to provide @@ -383,6 +382,8 @@ void QScriptEngineAgent::functionExit(qint64 scriptId, The default implementation does nothing. + \note \a columnNumber is undefined + \sa scriptLoad(), functionEntry() */ void QScriptEngineAgent::positionChange(qint64 scriptId, diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 1330d96..62deb5ae 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -103,6 +103,9 @@ private slots: void copy(); + void fill_data(); + void fill(); + void setPixel_data(); void setPixel(); @@ -1015,6 +1018,67 @@ void tst_QImage::copy() } } +void tst_QImage::fill_data() +{ + QTest::addColumn<int>("format"); + QTest::addColumn<uint>("input"); + QTest::addColumn<uint>("expectedResult"); + + QTest::newRow("ARGB32") << int(QImage::Format_ARGB32) << 0x33557799u << 0x33557799u; + QTest::newRow("RGB888") << int(QImage::Format_RGB888) << 0x335577u << 0x335577u; + QTest::newRow("RGB16") << int(QImage::Format_RGB16) << 0x3355u << 0x3355u; + QTest::newRow("Indexed8") << int(QImage::Format_Indexed8) << 0x55u << 0x55u; + QTest::newRow("Mono") << int(QImage::Format_Mono) << 1u << 1u; + QTest::newRow("Mono_LSB") << int(QImage::Format_MonoLSB) << 0u << 0u; +} + +void tst_QImage::fill() +{ + QFETCH(int, format); + QFETCH(uint, input); + QFETCH(uint, expectedResult); + + QImage img(13, 15, (QImage::Format)format); + img.fill(input); + + const int bpp = img.depth(); + for (int y = 0; y < img.height(); ++y) { + uchar *line = img.scanLine(y); + for (int x = 0; x < img.width(); ++x) { + uint value; + switch (bpp) { + case 32: + value = *((uint*)line); + line += 4; + break; + case 24: + value = ((uint)line[0] << 16) | ((uint)line[1] << 8) | line[2]; + line += 3; + break; + case 16: + value = *((quint16*)line); + line += 2; + break; + case 8: + value = *line; + line++; + break; + case 1: + if (format == QImage::Format_Mono) + value = (*line >> (7- (x & 7))) & 1; + else if (format == QImage::Format_MonoLSB) + value = (*line >> (x & 7)) & 1; + + if (x && !(x & 7)) + ++line; + break; + } + + QCOMPARE(value, expectedResult); + } + } +} + void tst_QImage::setPixel_data() { QTest::addColumn<int>("format"); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index f358681..2cbb9b2 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -118,10 +118,12 @@ private slots: void drawLine_task190634(); void drawLine_task229459(); void drawLine_task234891(); + void drawHorizontalLineF(); void drawRect_data() { fillData(); } void drawRect(); void drawRect2(); + void drawRectFHorizontalLine(); void fillRect(); void fillRect2(); @@ -251,6 +253,7 @@ private slots: void setPenColorOnPixmap(); void QTBUG5939_attachPainterPrivate(); + void drawHorizontalLine(); private: void fillData(); @@ -1218,6 +1221,26 @@ void tst_QPainter::drawLine_task234891() QCOMPARE(expected, img); } +void tst_QPainter::drawHorizontalLineF() +{ + QPixmap pixmap(100, 3); + pixmap.fill(); + + { + QPainter painter(&pixmap); + painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f)); + } + + QImage refImage(100, 3, QImage::Format_ARGB32); + refImage.fill(0xFFFFFFFF); + { + QPainter painter(&refImage); + painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f)); + } + + QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); +} + void tst_QPainter::drawLine_task216948() { QImage img(1, 10, QImage::Format_ARGB32_Premultiplied); @@ -1302,6 +1325,26 @@ void tst_QPainter::drawRect2() } } +void tst_QPainter::drawRectFHorizontalLine() +{ + QPixmap pixmap(100, 3); + pixmap.fill(); + + { + QPainter painter(&pixmap); + painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f)); + } + + QImage refImage(100, 3, QImage::Format_ARGB32); + refImage.fill(0xFFFFFFFF); + { + QPainter painter(&refImage); + painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f)); + } + + QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); +} + void tst_QPainter::fillRect() { QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); @@ -4522,6 +4565,28 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate() QCOMPARE(widget->deviceTransform, proxy->deviceTransform); } +void tst_QPainter::drawHorizontalLine() +{ + QPixmap pixmap(100, 3); + pixmap.fill(); + + { + QPainter painter(&pixmap); + painter.translate(0.3, 0.3); + painter.drawLine(QLine(1, 1, 99, 1)); + } + + QImage refImage(100, 3, QImage::Format_ARGB32); + refImage.fill(0xFFFFFFFF); + { + QPainter painter(&refImage); + painter.translate(0.3, 0.3); + painter.drawLine(QLine(1, 1, 99, 1)); + } + + QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" |