summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>2010-03-10 00:44:54 (GMT)
committerDmytro Poplavskiy <dmytro.poplavskiy@nokia.com>2010-03-10 00:44:54 (GMT)
commitd5190693e2b3ef203d4e010ac227172051e49c74 (patch)
treea99a2a81528a875f0d92fea46ec03b6a77409818 /src
parenta4ffe2d274cae2510d72d04f67b42f9448282fbd (diff)
parentd20e39eaad4699b0341b9232e0071fcb695b3ae7 (diff)
downloadQt-d5190693e2b3ef203d4e010ac227172051e49c74.zip
Qt-d5190693e2b3ef203d4e010ac227172051e49c74.tar.gz
Qt-d5190693e2b3ef203d4e010ac227172051e49c74.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging into 4.7
Diffstat (limited to 'src')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativeanchors_p_p.h40
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp377
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h27
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase.cpp11
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp21
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeparticles.cpp2
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp34
-rw-r--r--src/gui/egl/qegl_x11.cpp12
-rw-r--r--src/gui/itemviews/qtreeview.cpp6
-rw-r--r--src/gui/kernel/qmime_win.cpp2
-rw-r--r--src/gui/painting/qdrawutil.cpp4
-rw-r--r--src/gui/painting/qpaintengineex.cpp4
-rw-r--r--src/gui/painting/qpaintengineex_p.h3
-rw-r--r--src/gui/painting/qpainter.cpp45
-rw-r--r--src/gui/painting/qpainter.h12
-rw-r--r--src/gui/text/qtextengine_p.h1
-rw-r--r--src/gui/text/qtextlayout.cpp2
-rw-r--r--src/imports/multimedia/multimedia.pro4
-rw-r--r--src/imports/qimportbase.pri2
-rw-r--r--src/imports/webkit/webkit.pro4
-rw-r--r--src/imports/widgets/widgets.pro4
-rw-r--r--src/multimedia/effects/qsoundeffect.cpp2
-rw-r--r--src/multimedia/effects/qsoundeffect_pulse_p.cpp87
-rw-r--r--src/multimedia/effects/qsoundeffect_pulse_p.h4
-rw-r--r--src/multimedia/effects/qsoundeffect_qmedia_p.cpp2
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp7
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h6
-rw-r--r--src/opengl/qgl_x11egl.cpp1
-rw-r--r--src/openvg/qpaintengine_vg.cpp4
-rw-r--r--src/openvg/qpaintengine_vg_p.h3
-rw-r--r--src/src.pro2
-rw-r--r--src/svg/qsvggenerator.cpp27
-rw-r--r--src/svg/qsvggraphics.cpp178
-rw-r--r--src/svg/qsvggraphics_p.h40
-rw-r--r--src/svg/qsvgnode.cpp65
-rw-r--r--src/svg/qsvgnode_p.h14
-rw-r--r--src/svg/qsvgstructure.cpp13
-rw-r--r--src/svg/qsvgstructure_p.h3
-rw-r--r--src/svg/qsvgstyle.cpp46
-rw-r--r--src/svg/qsvgstyle_p.h28
-rw-r--r--src/svg/qsvgtinydocument.cpp7
-rw-r--r--src/svg/qsvgtinydocument_p.h5
47 files changed, 775 insertions, 404 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
index 274d778..dc1f09d 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeanchors.cpp
@@ -168,8 +168,7 @@ void QDeclarativeAnchorsPrivate::fillChanged()
} else if (fill->parentItem() == item->parentItem()) { //siblings
setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
}
- setItemWidth(fill->width()-leftMargin-rightMargin);
- setItemHeight(fill->height()-topMargin-bottomMargin);
+ setItemSize(QSizeF(fill->width()-leftMargin-rightMargin, fill->height()-topMargin-bottomMargin));
--updatingFill;
} else {
@@ -314,6 +313,13 @@ void QDeclarativeAnchorsPrivate::setItemPos(const QPointF &v)
updatingMe = false;
}
+void QDeclarativeAnchorsPrivate::setItemSize(const QSizeF &v)
+{
+ updatingMe = true;
+ item->setSize(v);
+ updatingMe = false;
+}
+
void QDeclarativeAnchorsPrivate::updateMe()
{
if (updatingMe) {
diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
index d9d7ffa..5840868 100644
--- a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h
@@ -59,12 +59,9 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeAnchorLine
+struct QDeclarativeAnchorLine
{
-public:
- QDeclarativeAnchorLine() : item(0), anchorLine(Invalid)
- {
- }
+ QDeclarativeAnchorLine() : item(0), anchorLine(Invalid) {}
enum AnchorLine {
Invalid = 0x0,
@@ -81,27 +78,22 @@ public:
QDeclarativeItem *item;
AnchorLine anchorLine;
-
- bool operator==(const QDeclarativeAnchorLine& other) const
- {
- return item == other.item && anchorLine == other.anchorLine;
- }
};
+inline bool operator==(const QDeclarativeAnchorLine& a, const QDeclarativeAnchorLine& b)
+{
+ return a.item == b.item && a.anchorLine == b.anchorLine;
+}
+
class QDeclarativeAnchorsPrivate : public QObjectPrivate, public QDeclarativeItemChangeListener
{
Q_DECLARE_PUBLIC(QDeclarativeAnchors)
public:
QDeclarativeAnchorsPrivate(QDeclarativeItem *i)
- : updatingMe(false), updatingHorizontalAnchor(0),
+ : componentComplete(true), updatingMe(false), updatingHorizontalAnchor(0),
updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0),
centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
- margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0),
- componentComplete(true)
- {
- }
-
- void init()
+ margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)
{
}
@@ -111,17 +103,19 @@ public:
void remDepend(QDeclarativeItem *);
bool isItemComplete() const;
- bool updatingMe;
- int updatingHorizontalAnchor;
- int updatingVerticalAnchor;
- int updatingFill;
- int updatingCenterIn;
+ bool componentComplete:1;
+ bool updatingMe:1;
+ uint updatingHorizontalAnchor:2;
+ uint updatingVerticalAnchor:2;
+ uint updatingFill:2;
+ uint updatingCenterIn:2;
void setItemHeight(qreal);
void setItemWidth(qreal);
void setItemX(qreal);
void setItemY(qreal);
void setItemPos(const QPointF &);
+ void setItemSize(const QSizeF &);
void updateOnComplete();
void updateMe();
@@ -163,8 +157,6 @@ public:
qreal vCenterOffset;
qreal hCenterOffset;
qreal baselineOffset;
-
- bool componentComplete;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 76ad9b7..60ffbe2 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -50,6 +50,8 @@
#include <qlistmodelinterface_p.h>
#include <QKeyEvent>
+#include <math.h>
+
QT_BEGIN_NAMESPACE
@@ -97,12 +99,13 @@ public:
: currentItem(0), flow(QDeclarativeGridView::LeftToRight)
, visiblePos(0), visibleIndex(0) , currentIndex(-1)
, cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1)
+ , highlightRangeStart(0), highlightRangeEnd(0), highlightRange(QDeclarativeGridView::NoHighlightRange)
, highlightComponent(0), highlight(0), trackedItem(0)
, moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0)
- , bufferMode(NoBuffer)
+ , bufferMode(NoBuffer), snapMode(QDeclarativeGridView::NoSnap)
, ownModel(false), wrap(false), autoHighlight(true)
, fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false)
- , deferredRelease(false) {}
+ , deferredRelease(false), haveHighlightRange(false) {}
void init();
void clear();
@@ -119,6 +122,7 @@ public:
void createHighlight();
void updateHighlight();
void updateCurrent(int modelIndex);
+ void fixupPosition();
FxGridItem *visibleItem(int modelIndex) const {
if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) {
@@ -236,7 +240,33 @@ public:
return -1; // Not in visibleList
}
- void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
+ qreal snapPosAt(qreal pos) {
+ qreal snapPos = 0;
+ if (!visibleItems.isEmpty()) {
+ pos += rowSize()/2;
+ snapPos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize();
+ snapPos = pos - fmodf(pos - snapPos, qreal(rowSize()));
+ }
+ return snapPos;
+ }
+
+ int snapIndex() {
+ int index = currentIndex;
+ for (int i = 0; i < visibleItems.count(); ++i) {
+ FxGridItem *item = visibleItems[i];
+ if (item->index == -1)
+ continue;
+ qreal itemTop = item->rowPos();
+ if (itemTop >= highlight->rowPos()-rowSize()/2 && itemTop < highlight->rowPos()+rowSize()/2) {
+ index = item->index;
+ if (item->colPos() >= highlight->colPos()-colSize()/2 && item->colPos() < highlight->colPos()+colSize()/2)
+ return item->index;
+ }
+ }
+ return index;
+ }
+
+ virtual void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
Q_Q(const QDeclarativeGridView);
QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry);
if (item == q) {
@@ -249,6 +279,11 @@ public:
}
}
}
+
+ virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent);
+ virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
+ QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity);
+
// for debugging only
void checkVisible() const {
int skip = 0;
@@ -277,6 +312,9 @@ public:
int cellHeight;
int columns;
int requestedIndex;
+ qreal highlightRangeStart;
+ qreal highlightRangeEnd;
+ QDeclarativeGridView::HighlightRangeMode highlightRange;
QDeclarativeComponent *highlightComponent;
FxGridItem *highlight;
FxGridItem *trackedItem;
@@ -287,6 +325,7 @@ public:
QDeclarativeEaseFollow *highlightYAnimator;
enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 };
BufferMode bufferMode;
+ QDeclarativeGridView::SnapMode snapMode;
bool ownModel : 1;
bool wrap : 1;
@@ -295,6 +334,7 @@ public:
bool lazyRelease : 1;
bool layoutScheduled : 1;
bool deferredRelease : 1;
+ bool haveHighlightRange : 1;
};
void QDeclarativeGridViewPrivate::init()
@@ -683,6 +723,122 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex)
releaseItem(oldCurrentItem);
}
+void QDeclarativeGridViewPrivate::fixupPosition()
+{
+ moveReason = Other;
+ if (flow == QDeclarativeGridView::LeftToRight)
+ fixupY();
+ else
+ fixupX();
+}
+
+void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)
+{
+ Q_Q(QDeclarativeGridView);
+
+ if ((&data == &vData && !q->yflick())
+ || (&data == &hData && !q->xflick())
+ || data.move.timeLine())
+ return;
+
+ int oldDuration = fixupDuration;
+ fixupDuration = moveReason == Mouse ? fixupDuration : 0;
+
+ if (haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) {
+ if (currentItem && currentItem->rowPos() - position() != highlightRangeStart) {
+ qreal pos = currentItem->rowPos() - highlightRangeStart;
+ timeline.reset(data.move);
+ if (fixupDuration)
+ timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
+ else
+ data.move.setValue(-pos);
+ vTime = timeline.time();
+ }
+ } else if (snapMode != QDeclarativeGridView::NoSnap) {
+ qreal pos = qMax(qMin(snapPosAt(position()) - highlightRangeStart, -maxExtent), -minExtent);
+ qreal dist = qAbs(data.move + pos);
+ if (dist > 0) {
+ timeline.reset(data.move);
+ if (fixupDuration)
+ timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2);
+ else
+ data.move.setValue(-pos);
+ vTime = timeline.time();
+ }
+ } else {
+ QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent);
+ }
+ fixupDuration = oldDuration;
+}
+
+void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
+ QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity)
+{
+ Q_Q(QDeclarativeGridView);
+
+ moveReason = Mouse;
+ if ((!haveHighlightRange || highlightRange != QDeclarativeGridView::StrictlyEnforceRange) && snapMode == QDeclarativeGridView::NoSnap) {
+ QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity);
+ return;
+ }
+ qreal maxDistance = -1;
+ // -ve velocity means list is moving up
+ if (velocity > 0) {
+ if (snapMode == QDeclarativeGridView::SnapOneRow) {
+ if (FxGridItem *item = firstVisibleItem())
+ maxDistance = qAbs(item->rowPos() + data.move.value());
+ } else if (data.move.value() < minExtent) {
+ maxDistance = qAbs(minExtent - data.move.value() + (overShoot?overShootDistance(velocity, vSize):0));
+ }
+ if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
+ data.flickTarget = minExtent;
+ } else {
+ if (snapMode == QDeclarativeGridView::SnapOneRow) {
+ qreal pos = snapPosAt(-data.move.value()) + rowSize();
+ maxDistance = qAbs(pos + data.move.value());
+ } else if (data.move.value() > maxExtent) {
+ maxDistance = qAbs(maxExtent - data.move.value()) + (overShoot?overShootDistance(velocity, vSize):0);
+ }
+ if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
+ data.flickTarget = maxExtent;
+ }
+ if (maxDistance > 0 && (snapMode != QDeclarativeGridView::NoSnap || highlightRange == QDeclarativeGridView::StrictlyEnforceRange)) {
+ // This mode requires the grid to stop exactly on a row boundary.
+ qreal v = velocity;
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
+ v = -maxVelocity;
+ else
+ v = maxVelocity;
+ }
+ qreal accel = deceleration;
+ qreal v2 = v * v;
+ qreal maxAccel = v2 / (2.0f * maxDistance);
+ qreal overshootDist = 0.0;
+ if (maxAccel < accel) {
+ qreal dist = v2 / (accel * 2.0);
+ if (v > 0)
+ dist = -dist;
+ data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart;
+ dist = -data.flickTarget + data.move.value();
+ accel = v2 / (2.0f * qAbs(dist));
+ } else {
+ data.flickTarget = velocity > 0 ? minExtent : maxExtent;
+ overshootDist = overShoot ? overShootDistance(v, vSize) : 0;
+ }
+ timeline.reset(data.move);
+ timeline.accel(data.move, v, accel, maxDistance + overshootDist);
+ timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this));
+ flicked = true;
+ emit q->flickingChanged();
+ emit q->flickStarted();
+ } else {
+ timeline.reset(data.move);
+ fixup(data, minExtent, maxExtent);
+ }
+}
+
+
//----------------------------------------------------------------------------
/*!
@@ -1031,6 +1187,87 @@ void QDeclarativeGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
}
/*!
+ \qmlproperty real GridView::preferredHighlightBegin
+ \qmlproperty real GridView::preferredHighlightEnd
+ \qmlproperty enumeration GridView::highlightRangeMode
+
+ These properties set the preferred range of the highlight (current item)
+ within the view.
+
+ Note that this is the correct way to influence where the
+ current item ends up when the view scrolls. For example, if you want the
+ currently selected item to be in the middle of the list, then set the
+ highlight range to be where the middle item would go. Then, when the view scrolls,
+ the currently selected item will be the item at that spot. This also applies to
+ when the currently selected item changes - it will scroll to within the preferred
+ highlight range. Furthermore, the behaviour of the current item index will occur
+ whether or not a highlight exists.
+
+ If highlightRangeMode is set to \e ApplyRange the view will
+ attempt to maintain the highlight within the range, however
+ the highlight can move outside of the range at the ends of the list
+ or due to a mouse interaction.
+
+ If highlightRangeMode is set to \e StrictlyEnforceRange the highlight will never
+ move outside of the range. This means that the current item will change
+ if a keyboard or mouse action would cause the highlight to move
+ outside of the range.
+
+ The default value is \e NoHighlightRange.
+
+ Note that a valid range requires preferredHighlightEnd to be greater
+ than or equal to preferredHighlightBegin.
+*/
+qreal QDeclarativeGridView::preferredHighlightBegin() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->highlightRangeStart;
+}
+
+void QDeclarativeGridView::setPreferredHighlightBegin(qreal start)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->highlightRangeStart == start)
+ return;
+ d->highlightRangeStart = start;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit preferredHighlightBeginChanged();
+}
+
+qreal QDeclarativeGridView::preferredHighlightEnd() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->highlightRangeEnd;
+}
+
+void QDeclarativeGridView::setPreferredHighlightEnd(qreal end)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->highlightRangeEnd == end)
+ return;
+ d->highlightRangeEnd = end;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit preferredHighlightEndChanged();
+}
+
+QDeclarativeGridView::HighlightRangeMode QDeclarativeGridView::highlightRangeMode() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->highlightRange;
+}
+
+void QDeclarativeGridView::setHighlightRangeMode(HighlightRangeMode mode)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->highlightRange == mode)
+ return;
+ d->highlightRange = mode;
+ d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd;
+ emit highlightRangeModeChanged();
+}
+
+
+/*!
\qmlproperty enumeration GridView::flow
This property holds the flow of the grid.
@@ -1153,6 +1390,36 @@ void QDeclarativeGridView::setCellHeight(int cellHeight)
d->layout();
}
}
+/*!
+ \qmlproperty enumeration GridView::snapMode
+
+ This property determines where the view will settle following a drag or flick.
+ The allowed values are:
+
+ \list
+ \o NoSnap (default) - the view will stop anywhere within the visible area.
+ \o SnapToRow - the view will settle with a row (or column for TopToBottom flow)
+ aligned with the start of the view.
+ \o SnapOneRow - the view will settle no more than one row (or column for TopToBottom flow)
+ away from the first visible row at the time the mouse button is released.
+ This mode is particularly useful for moving one page at a time.
+ \endlist
+
+*/
+QDeclarativeGridView::SnapMode QDeclarativeGridView::snapMode() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->snapMode;
+}
+
+void QDeclarativeGridView::setSnapMode(SnapMode mode)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->snapMode != mode) {
+ d->snapMode = mode;
+ emit snapModeChanged();
+ }
+}
void QDeclarativeGridView::viewportMoved()
{
@@ -1175,6 +1442,32 @@ void QDeclarativeGridView::viewportMoved()
}
}
refill();
+ if (isFlicking() || d->moving)
+ d->moveReason = QDeclarativeGridViewPrivate::Mouse;
+ if (d->moveReason != QDeclarativeGridViewPrivate::SetIndex) {
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) {
+ // reposition highlight
+ qreal pos = d->highlight->rowPos();
+ qreal viewPos = qRound(d->position());
+ if (pos > viewPos + d->highlightRangeEnd - 1 - d->rowSize())
+ pos = viewPos + d->highlightRangeEnd - 1 - d->rowSize();
+ if (pos < viewPos + d->highlightRangeStart)
+ pos = viewPos + d->highlightRangeStart;
+ d->highlight->setPosition(d->highlight->colPos(), pos);
+
+ // update current index
+ int idx = d->snapIndex();
+ if (idx >= 0 && idx != d->currentIndex) {
+ d->updateCurrent(idx);
+ if (d->currentItem && d->currentItem->colPos() != d->highlight->colPos() && d->autoHighlight) {
+ if (d->flow == LeftToRight)
+ d->highlightXAnimator->setSourceValue(d->currentItem->item->x());
+ else
+ d->highlightYAnimator->setSourceValue(d->currentItem->item->y());
+ }
+ }
+ }
+ }
}
qreal QDeclarativeGridView::minYExtent() const
@@ -1182,7 +1475,10 @@ qreal QDeclarativeGridView::minYExtent() const
Q_D(const QDeclarativeGridView);
if (d->flow == QDeclarativeGridView::TopToBottom)
return QDeclarativeFlickable::minYExtent();
- return -d->startPosition();
+ qreal extent = -d->startPosition();
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent += d->highlightRangeStart;
+ return extent;
}
qreal QDeclarativeGridView::maxYExtent() const
@@ -1190,7 +1486,11 @@ qreal QDeclarativeGridView::maxYExtent() const
Q_D(const QDeclarativeGridView);
if (d->flow == QDeclarativeGridView::TopToBottom)
return QDeclarativeFlickable::maxYExtent();
- qreal extent = -(d->endPosition() - height());
+ qreal extent;
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent = -(d->rowPosAt(count()-1) - d->highlightRangeEnd);
+ else
+ extent = -(d->endPosition() - height());
const qreal minY = minYExtent();
if (extent > minY)
extent = minY;
@@ -1202,7 +1502,10 @@ qreal QDeclarativeGridView::minXExtent() const
Q_D(const QDeclarativeGridView);
if (d->flow == QDeclarativeGridView::LeftToRight)
return QDeclarativeFlickable::minXExtent();
- return -d->startPosition();
+ qreal extent = -d->startPosition();
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent += d->highlightRangeStart;
+ return extent;
}
qreal QDeclarativeGridView::maxXExtent() const
@@ -1210,7 +1513,11 @@ qreal QDeclarativeGridView::maxXExtent() const
Q_D(const QDeclarativeGridView);
if (d->flow == QDeclarativeGridView::LeftToRight)
return QDeclarativeFlickable::maxXExtent();
- qreal extent = -(d->endPosition() - width());
+ qreal extent;
+ if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange)
+ extent = -(d->rowPosAt(count()-1) - d->highlightRangeEnd);
+ else
+ extent = -(d->endPosition() - height());
const qreal minX = minXExtent();
if (extent > minX)
extent = minX;
@@ -1381,6 +1688,7 @@ void QDeclarativeGridView::positionViewAtIndex(int index)
for (int i = 0; i < oldVisible.count(); ++i)
d->releaseItem(oldVisible.at(i));
}
+ d->fixupPosition();
}
@@ -1394,6 +1702,7 @@ void QDeclarativeGridView::componentComplete()
d->updateCurrent(0);
else
d->updateCurrent(d->currentIndex);
+ d->fixupPosition();
}
void QDeclarativeGridView::trackedPositionChanged()
@@ -1402,22 +1711,50 @@ void QDeclarativeGridView::trackedPositionChanged()
if (!d->trackedItem || !d->currentItem)
return;
if (!isFlicking() && !d->moving && d->moveReason == QDeclarativeGridViewPrivate::SetIndex) {
+ const qreal trackedPos = d->trackedItem->rowPos();
const qreal viewPos = d->position();
- if (d->trackedItem->rowPos() < viewPos && d->currentItem->rowPos() < viewPos) {
- d->setPosition(d->currentItem->rowPos() < d->trackedItem->rowPos() ? d->trackedItem->rowPos() : d->currentItem->rowPos());
- } else if (d->trackedItem->endRowPos() > viewPos + d->size()
- && d->currentItem->endRowPos() > viewPos + d->size()) {
- qreal pos;
- if (d->trackedItem->endRowPos() < d->currentItem->endRowPos()) {
- pos = d->trackedItem->endRowPos() - d->size();
- if (d->rowSize() > d->size())
- pos = d->trackedItem->rowPos();
+ if (d->haveHighlightRange) {
+ if (d->highlightRange == StrictlyEnforceRange) {
+ qreal pos = viewPos;
+ if (trackedPos > pos + d->highlightRangeEnd - d->rowSize())
+ pos = trackedPos - d->highlightRangeEnd + d->rowSize();
+ if (trackedPos < pos + d->highlightRangeStart)
+ pos = trackedPos - d->highlightRangeStart;
+ d->setPosition(pos);
} else {
- pos = d->currentItem->endRowPos() - d->size();
- if (d->rowSize() > d->size())
- pos = d->currentItem->rowPos();
+ qreal pos = viewPos;
+ if (trackedPos < d->startPosition() + d->highlightRangeStart) {
+ pos = d->startPosition();
+ } else if (d->trackedItem->endRowPos() > d->endPosition() - d->size() + d->highlightRangeEnd) {
+ pos = d->endPosition() - d->size();
+ if (pos < d->startPosition())
+ pos = d->startPosition();
+ } else {
+ if (trackedPos < viewPos + d->highlightRangeStart) {
+ pos = trackedPos - d->highlightRangeStart;
+ } else if (trackedPos > viewPos + d->highlightRangeEnd - d->rowSize()) {
+ pos = trackedPos - d->highlightRangeEnd + d->rowSize();
+ }
+ }
+ d->setPosition(pos);
+ }
+ } else {
+ if (trackedPos < viewPos && d->currentItem->rowPos() < viewPos) {
+ d->setPosition(d->currentItem->rowPos() < trackedPos ? trackedPos : d->currentItem->rowPos());
+ } else if (d->trackedItem->endRowPos() > viewPos + d->size()
+ && d->currentItem->endRowPos() > viewPos + d->size()) {
+ qreal pos;
+ if (d->trackedItem->endRowPos() < d->currentItem->endRowPos()) {
+ pos = d->trackedItem->endRowPos() - d->size();
+ if (d->rowSize() > d->size())
+ pos = trackedPos;
+ } else {
+ pos = d->currentItem->endRowPos() - d->size();
+ if (d->rowSize() > d->size())
+ pos = d->currentItem->rowPos();
+ }
+ d->setPosition(pos);
}
- d->setPosition(pos);
}
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index 7255d3d..787c04c 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -67,11 +67,20 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable
Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem)
+ Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
+ Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
+ Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
+
Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged)
Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
+
+ Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
+
+ Q_ENUMS(HighlightRangeMode)
+ Q_ENUMS(SnapMode)
Q_CLASSINFO("DefaultProperty", "data")
public:
@@ -97,6 +106,16 @@ public:
bool highlightFollowsCurrentItem() const;
void setHighlightFollowsCurrentItem(bool);
+ enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
+ HighlightRangeMode highlightRangeMode() const;
+ void setHighlightRangeMode(HighlightRangeMode mode);
+
+ qreal preferredHighlightBegin() const;
+ void setPreferredHighlightBegin(qreal);
+
+ qreal preferredHighlightEnd() const;
+ void setPreferredHighlightEnd(qreal);
+
Q_ENUMS(Flow)
enum Flow { LeftToRight, TopToBottom };
Flow flow() const;
@@ -114,6 +133,10 @@ public:
int cellHeight() const;
void setCellHeight(int);
+ enum SnapMode { NoSnap, SnapToRow, SnapOneRow };
+ SnapMode snapMode() const;
+ void setSnapMode(SnapMode mode);
+
static QDeclarativeGridViewAttached *qmlAttachedProperties(QObject *);
public Q_SLOTS:
@@ -130,11 +153,15 @@ Q_SIGNALS:
void cellHeightChanged();
void highlightChanged();
void highlightItemChanged();
+ void preferredHighlightBeginChanged();
+ void preferredHighlightEndChanged();
+ void highlightRangeModeChanged();
void modelChanged();
void delegateChanged();
void flowChanged();
void keyNavigationWrapsChanged();
void cacheBufferChanged();
+ void snapModeChanged();
protected:
virtual void viewportMoved();
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index a20d6bc..425976f 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -386,7 +386,7 @@ void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWi
void QDeclarativeImage::pixmapChange()
{
updatePaintedGeometry();
- QDeclarativeImageBase::pixmapChange();
+ emit pixmapChanged();
}
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h
index 7394774..da6cbd5 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h
@@ -79,6 +79,7 @@ public:
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
Q_SIGNALS:
+ void pixmapChanged();
void fillModeChanged();
void paintedGeometryChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index 0e9638d..e65c9d1 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -144,19 +144,19 @@ void QDeclarativeImageBase::load()
static int thisRequestProgress = -1;
static int thisRequestFinished = -1;
if (replyDownloadProgress == -1) {
- replyDownloadProgress =
+ replyDownloadProgress =
QDeclarativePixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)");
- replyFinished =
+ replyFinished =
QDeclarativePixmapReply::staticMetaObject.indexOfSignal("finished()");
- thisRequestProgress =
+ thisRequestProgress =
QDeclarativeImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");
thisRequestFinished =
QDeclarativeImageBase::staticMetaObject.indexOfSlot("requestFinished()");
}
- QMetaObject::connect(reply, replyFinished, this,
+ QMetaObject::connect(reply, replyFinished, this,
thisRequestFinished, Qt::DirectConnection);
- QMetaObject::connect(reply, replyDownloadProgress, this,
+ QMetaObject::connect(reply, replyDownloadProgress, this,
thisRequestProgress, Qt::DirectConnection);
} else {
//### should be unified with requestFinished
@@ -219,7 +219,6 @@ void QDeclarativeImageBase::componentComplete()
void QDeclarativeImageBase::pixmapChange()
{
- emit pixmapChanged();
}
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
index cfebdca..b215193 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p.h
@@ -75,7 +75,6 @@ Q_SIGNALS:
void sourceChanged(const QUrl &);
void statusChanged(Status);
void progressChanged(qreal progress);
- void pixmapChanged();
void asynchronousChanged();
protected:
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 59dd43d..9d6b2a0 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -2855,6 +2855,27 @@ bool QDeclarativeItem::heightValid() const
return d->heightValid;
}
+/*! \internal */
+void QDeclarativeItem::setSize(const QSizeF &size)
+{
+ Q_D(QDeclarativeItem);
+ d->heightValid = true;
+ d->widthValid = true;
+
+ if (d->height == size.height() && d->width == size.width())
+ return;
+
+ qreal oldHeight = d->height;
+ qreal oldWidth = d->width;
+
+ prepareGeometryChange();
+ d->height = size.height();
+ d->width = size.width();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, oldHeight));
+}
+
/*!
\qmlproperty bool Item::wantsFocus
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index f6fedc7..2053eba 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -143,6 +143,8 @@ public:
void resetHeight();
qreal implicitHeight() const;
+ void setSize(const QSizeF &size);
+
TransformOrigin transformOrigin() const;
void setTransformOrigin(TransformOrigin);
@@ -209,8 +211,6 @@ protected:
QDeclarativeItem(QDeclarativeItemPrivate &dd, QDeclarativeItem *parent = 0);
private:
- friend class QDeclarativeStatePrivate;
- friend class QDeclarativeAnchors;
Q_DISABLE_COPY(QDeclarativeItem)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem)
};
diff --git a/src/declarative/graphicsitems/qdeclarativeparticles.cpp b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
index ec0bf6c..593c80a 100644
--- a/src/declarative/graphicsitems/qdeclarativeparticles.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeparticles.cpp
@@ -1263,7 +1263,7 @@ void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphics
const int myY = y() + parentItem()->y();
#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0))
- QVarLengthArray<QPainter::Fragment, 256> pixmapData;
+ QVarLengthArray<QPainter::PixmapFragment, 256> pixmapData;
#else
QVarLengthArray<QDrawPixmaps::Data, 256> pixmapData;
#endif
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index 53e08b0..49dbb27 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -61,9 +61,6 @@
QT_BEGIN_NAMESPACE
-
-
-
typedef QPair<int, int> QDeclarativeXmlListRange;
/*!
@@ -114,9 +111,6 @@ class QDeclarativeXmlQuery : public QThread
{
Q_OBJECT
public:
- QDeclarativeXmlQuery(QObject *parent=0)
- : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) {
- }
~QDeclarativeXmlQuery() {
m_mutex.lock();
m_quit = true;
@@ -126,6 +120,11 @@ public:
wait();
}
+ static QDeclarativeXmlQuery *instance() {
+ static QDeclarativeXmlQuery *query = new QDeclarativeXmlQuery;
+ return query;
+ }
+
void abort() {
QMutexLocker locker(&m_mutex);
m_abort = true;
@@ -164,6 +163,11 @@ public:
return m_removedItemRanges;
}
+private:
+ QDeclarativeXmlQuery(QObject *parent=0)
+ : QThread(parent), m_quit(false), m_restart(false), m_abort(false), m_queryId(0) {
+ }
+
Q_SIGNALS:
void queryCompleted(int queryId, int size);
@@ -213,6 +217,8 @@ private:
QList<QDeclarativeXmlListRange> m_removedItemRanges;
};
+//Q_GLOBAL_STATIC(QDeclarativeXmlQuery, QDeclarativeXmlQuery::instance());
+
void QDeclarativeXmlQuery::doQueryJob()
{
QString r;
@@ -404,7 +410,6 @@ public:
QNetworkReply *reply;
QDeclarativeXmlListModel::Status status;
qreal progress;
- QDeclarativeXmlQuery qmlXmlQuery;
int queryId;
QList<QDeclarativeXmlListModelRole *> roleObjects;
static void append_role(QDeclarativeListProperty<QDeclarativeXmlListModelRole> *list, QDeclarativeXmlListModelRole *role);
@@ -488,8 +493,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
: QListModelInterface(*(new QDeclarativeXmlListModelPrivate), parent)
{
- Q_D(QDeclarativeXmlListModel);
- connect(&d->qmlXmlQuery, SIGNAL(queryCompleted(int,int)),
+ connect(QDeclarativeXmlQuery::instance(), SIGNAL(queryCompleted(int,int)),
this, SLOT(queryCompleted(int,int)));
}
@@ -722,7 +726,7 @@ void QDeclarativeXmlListModel::reload()
if (!d->isComponentComplete)
return;
- d->qmlXmlQuery.abort();
+ QDeclarativeXmlQuery::instance()->abort();
d->queryId = -1;
int count = d->size;
@@ -754,7 +758,7 @@ void QDeclarativeXmlListModel::reload()
}
if (!d->xml.isEmpty()) {
- d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects);
+ d->queryId = QDeclarativeXmlQuery::instance()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects);
d->progress = 1.0;
d->status = Ready;
emit progressChanged(d->progress);
@@ -785,7 +789,7 @@ void QDeclarativeXmlListModel::requestFinished()
} else {
d->status = Ready;
QByteArray data = d->reply->readAll();
- d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, data, &d->roleObjects);
+ d->queryId = QDeclarativeXmlQuery::instance()->doQuery(d->query, d->namespaces, data, &d->roleObjects);
disconnect(d->reply, 0, this, 0);
d->reply->deleteLater();
d->reply = 0;
@@ -811,10 +815,10 @@ void QDeclarativeXmlListModel::queryCompleted(int id, int size)
return;
bool sizeChanged = size != d->size;
d->size = size;
- d->data = d->qmlXmlQuery.modelData();
+ d->data = QDeclarativeXmlQuery::instance()->modelData();
- QList<QDeclarativeXmlListRange> removed = d->qmlXmlQuery.removedItemRanges();
- QList<QDeclarativeXmlListRange> inserted = d->qmlXmlQuery.insertedItemRanges();
+ QList<QDeclarativeXmlListRange> removed = QDeclarativeXmlQuery::instance()->removedItemRanges();
+ QList<QDeclarativeXmlListRange> inserted = QDeclarativeXmlQuery::instance()->insertedItemRanges();
for (int i=0; i<removed.count(); i++)
emit itemsRemoved(removed[i].first, removed[i].second);
diff --git a/src/gui/egl/qegl_x11.cpp b/src/gui/egl/qegl_x11.cpp
index 8608523..53c4711 100644
--- a/src/gui/egl/qegl_x11.cpp
+++ b/src/gui/egl/qegl_x11.cpp
@@ -41,18 +41,19 @@
#include <QtCore/qdebug.h>
-#include <private/qt_x11_p.h>
+#include <QtGui/private/qt_x11_p.h>
#include <QtGui/qx11info_x11.h>
-#include <private/qpixmapdata_p.h>
-#include <private/qpixmap_x11_p.h>
+#include <QtGui/private/qpixmapdata_p.h>
+#include <QtGui/private/qpixmap_x11_p.h>
+#include <QtGui/private/qimagepixmapcleanuphooks_p.h>
#include <QtGui/qpaintdevice.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qwidget.h>
#include <QtGui/qcolormap.h>
-#include "qegl_p.h"
-#include "qeglcontext_p.h"
+#include "QtGui/private/qegl_p.h"
+#include "QtGui/private/qeglcontext_p.h"
QT_BEGIN_NAMESPACE
@@ -408,6 +409,7 @@ EGLSurface QEgl::createSurface(QPaintDevice *device, EGLConfig config, const QEg
(EGLNativePixmapType) x11PixmapData->handle(),
surfaceAttribs.properties());
x11PixmapData->gl_surface = (Qt::HANDLE)surf;
+ QImagePixmapCleanupHooks::enableCleanupHooks(x11PixmapData);
return surf;
}
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 1145235..78184a9 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -679,16 +679,20 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto
d->defaultItemHeight = indexRowSizeHint(topLeft);
bool sizeChanged = false;
if (topViewIndex != -1) {
- if (topLeft == bottomRight) {
+ if (topLeft.row() == bottomRight.row()) {
int oldHeight = d->itemHeight(topViewIndex);
d->invalidateHeightCache(topViewIndex);
sizeChanged = (oldHeight != d->itemHeight(topViewIndex));
+ if (topLeft.column() == 0)
+ d->viewItems[topViewIndex].hasChildren = d->hasVisibleChildren(topLeft);
} else {
int bottomViewIndex = d->viewIndex(bottomRight);
for (int i = topViewIndex; i <= bottomViewIndex; ++i) {
int oldHeight = d->itemHeight(i);
d->invalidateHeightCache(i);
sizeChanged |= (oldHeight != d->itemHeight(i));
+ if (topLeft.column() == 0)
+ d->viewItems[i].hasChildren = d->hasVisibleChildren(d->viewItems.at(i).index);
}
}
}
diff --git a/src/gui/kernel/qmime_win.cpp b/src/gui/kernel/qmime_win.cpp
index 39633bf..2840843 100644
--- a/src/gui/kernel/qmime_win.cpp
+++ b/src/gui/kernel/qmime_win.cpp
@@ -952,6 +952,8 @@ bool QWindowsMimeImage::convertFromMime(const FORMATETC &formatetc, const QMimeD
QDataStream s(&ba, QIODevice::WriteOnly);
s.setByteOrder(QDataStream::LittleEndian);// Intel byte order ####
if (cf == CF_DIB) {
+ if (img.format() > QImage::Format_ARGB32)
+ img = img.convertToFormat(QImage::Format_RGB32);
if (qt_write_dib(s, img))
return setData(ba, pmedium);
} else {
diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp
index d76c709..a62f06b 100644
--- a/src/gui/painting/qdrawutil.cpp
+++ b/src/gui/painting/qdrawutil.cpp
@@ -1081,7 +1081,7 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs,
according to the \a margins structure.
*/
-typedef QVarLengthArray<QPainter::Fragment, 16> QPixmapFragmentsArray;
+typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray;
/*!
\since 4.6
@@ -1102,7 +1102,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
{
- QPainter::Fragment d;
+ QPainter::PixmapFragment d;
d.opacity = 1.0;
d.rotation = 0.0;
diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp
index 98762f0..1fd622d 100644
--- a/src/gui/painting/qpaintengineex.cpp
+++ b/src/gui/painting/qpaintengineex.cpp
@@ -970,8 +970,8 @@ void QPaintEngineEx::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, con
fill(path, brush);
}
-void QPaintEngineEx::drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount,
- const QPixmap &pixmap, QPainter::FragmentHints /*hints*/)
+void QPaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount,
+ const QPixmap &pixmap, QPainter::PixmapFragmentHints /*hints*/)
{
qreal oldOpacity = state()->opacity;
QTransform oldTransform = state()->matrix;
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index 2401b94..6c654bd 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -197,7 +197,8 @@ public:
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
- virtual void drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QFlags<QPainter::FragmentHint> hints);
+ virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
+ QFlags<QPainter::PixmapFragmentHint> hints);
virtual void updateState(const QPaintEngineState &state);
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 9d83718..c5ce76c 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -7994,10 +7994,11 @@ start_lengthVariant:
for (int i = 0; i < textLayout.lineCount(); i++) {
QTextLine line = textLayout.lineAt(i);
+ qreal advance = textLayout.engine()->lines[i].textAdvance.toReal();
if (tf & Qt::AlignRight)
- xoff = r.width() - line.naturalTextWidth();
+ xoff = r.width() - advance;
else if (tf & Qt::AlignHCenter)
- xoff = (r.width() - line.naturalTextWidth())/2;
+ xoff = (r.width() - advance)/2;
line.draw(painter, QPointF(r.x() + xoff + line.x(), r.y() + yoff));
}
@@ -8914,11 +8915,11 @@ QTransform QPainter::combinedTransform() const
This function is potentially faster than multiple calls to drawPixmap(),
since the backend can optimize state changes.
- \sa QPainter::Fragment, QPainter::FragmentHint
+ \sa QPainter::PixmapFragment, QPainter::PixmapFragmentHint
*/
-void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount,
- const QPixmap &pixmap, FragmentHints hints)
+void QPainter::drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount,
+ const QPixmap &pixmap, PixmapFragmentHints hints)
{
Q_D(QPainter);
@@ -8959,7 +8960,7 @@ void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount,
/*!
\since 4.7
- \class QPainter::Fragment
+ \class QPainter::PixmapFragment
\brief This class is used in conjunction with the
QPainter::drawPixmapFragments() function to specify how a pixmap, or
@@ -8980,73 +8981,73 @@ void QPainter::drawPixmapFragments(const Fragment *fragments, int fragmentCount,
/*!
\since 4.7
- This is a convenience function that returns a QPainter::Fragment that is
+ This is a convenience function that returns a QPainter::PixmapFragment that is
initialized with the \a pos, \a sourceRect, \a scaleX, \a scaleY, \a
rotation, \a opacity parameters.
*/
-QPainter::Fragment QPainter::Fragment::create(const QPointF &pos, const QRectF &sourceRect,
+QPainter::PixmapFragment QPainter::PixmapFragment::create(const QPointF &pos, const QRectF &sourceRect,
qreal scaleX, qreal scaleY, qreal rotation,
qreal opacity)
{
- Fragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(),
- sourceRect.height(), scaleX, scaleY, rotation, opacity};
+ PixmapFragment fragment = {pos.x(), pos.y(), sourceRect.x(), sourceRect.y(), sourceRect.width(),
+ sourceRect.height(), scaleX, scaleY, rotation, opacity};
return fragment;
}
/*!
- \variable QPainter::Fragment::x
+ \variable QPainter::PixmapFragment::x
\brief the x coordinate of center point in the target rectangle.
*/
/*!
- \variable QPainter::Fragment::y
+ \variable QPainter::PixmapFragment::y
\brief the y coordinate of the center point in the target rectangle.
*/
/*!
- \variable QPainter::Fragment::sourceLeft
+ \variable QPainter::PixmapFragment::sourceLeft
\brief the left coordinate of the source rectangle.
*/
/*!
- \variable QPainter::Fragment::sourceTop
+ \variable QPainter::PixmapFragment::sourceTop
\brief the top coordinate of the source rectangle.
*/
/*!
- \variable QPainter::Fragment::width
+ \variable QPainter::PixmapFragment::width
\brief the width of the source rectangle and is used to calculate the width
of the target rectangle.
*/
/*!
- \variable QPainter::Fragment::height
+ \variable QPainter::PixmapFragment::height
\brief the height of the source rectangle and is used to calculate the
height of the target rectangle.
*/
/*!
- \variable QPainter::Fragment::scaleX
+ \variable QPainter::PixmapFragment::scaleX
\brief the horizontal scale of the target rectangle.
*/
/*!
- \variable QPainter::Fragment::scaleY
+ \variable QPainter::PixmapFragment::scaleY
\brief the vertical scale of the target rectangle.
*/
/*!
- \variable QPainter::Fragment::rotation
+ \variable QPainter::PixmapFragment::rotation
\brief the rotation of the target rectangle in degrees. The target
rectangle is rotated after it has been scaled.
*/
/*!
- \variable QPainter::Fragment::opacity
+ \variable QPainter::PixmapFragment::opacity
\brief the opacity of the target rectangle, where 0.0 is fully transparent
and 1.0 is fully opaque.
@@ -9055,12 +9056,12 @@ QPainter::Fragment QPainter::Fragment::create(const QPointF &pos, const QRectF &
/*!
\since 4.7
- \enum QPainter::FragmentHint
+ \enum QPainter::PixmapFragmentHint
\value OpaqueHint Indicates that the pixmap fragments to be drawn are
opaque. Opaque fragments are potentially faster to draw.
- \sa QPainter::drawPixmapFragments(), QPainter::Fragment
+ \sa QPainter::drawPixmapFragments(), QPainter::PixmapFragment
*/
void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation)
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index bcb0b50..443925b 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -99,7 +99,7 @@ public:
Q_DECLARE_FLAGS(RenderHints, RenderHint)
- class Fragment {
+ class PixmapFragment {
public:
qreal x;
qreal y;
@@ -111,16 +111,16 @@ public:
qreal scaleY;
qreal rotation;
qreal opacity;
- static Fragment Q_GUI_EXPORT create(const QPointF &pos, const QRectF &sourceRect,
+ static PixmapFragment Q_GUI_EXPORT create(const QPointF &pos, const QRectF &sourceRect,
qreal scaleX = 1, qreal scaleY = 1,
qreal rotation = 0, qreal opacity = 1);
};
- enum FragmentHint {
+ enum PixmapFragmentHint {
OpaqueHint = 0x01
};
- Q_DECLARE_FLAGS(FragmentHints, FragmentHint)
+ Q_DECLARE_FLAGS(PixmapFragmentHints, PixmapFragmentHint)
QPainter();
explicit QPainter(QPaintDevice *);
@@ -375,8 +375,8 @@ public:
inline void drawPixmap(const QRect &r, const QPixmap &pm);
inline void drawPixmap(int x, int y, int w, int h, const QPixmap &pm);
- void drawPixmapFragments(const Fragment *fragments, int fragmentCount,
- const QPixmap &pixmap, FragmentHints hints = 0);
+ void drawPixmapFragments(const PixmapFragment *fragments, int fragmentCount,
+ const QPixmap &pixmap, PixmapFragmentHints hints = 0);
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect,
Qt::ImageConversionFlags flags = Qt::AutoColor);
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index f36cbd2..5054b66 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -382,6 +382,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine
QFixed y;
QFixed width;
QFixed textWidth;
+ QFixed textAdvance;
int from;
signed int length : 29;
mutable uint justified : 1;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index af91603..cc6793d 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1875,6 +1875,7 @@ void QTextLine::layout_helper(int maxGlyphs)
line.textWidth += lbh.softHyphenWidth;
}
+ line.textAdvance = line.textWidth;
line.textWidth += lbh.rightBearing;
goto found;
@@ -1885,6 +1886,7 @@ void QTextLine::layout_helper(int maxGlyphs)
}
LB_DEBUG("reached end of line");
lbh.checkFullOtherwiseExtend(line);
+ line.textAdvance = line.textWidth;
line.textWidth += lbh.rightBearing;
found:
diff --git a/src/imports/multimedia/multimedia.pro b/src/imports/multimedia/multimedia.pro
index 117aa9b..f7a1d1b 100644
--- a/src/imports/multimedia/multimedia.pro
+++ b/src/imports/multimedia/multimedia.pro
@@ -1,5 +1,5 @@
TARGET = multimedia
-TARGETPATH = $$[QT_INSTALL_IMPORTS]/Qt/multimedia
+TARGETPATH = Qt/multimedia
include(../qimportbase.pri)
QT += multimedia declarative
@@ -21,6 +21,6 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/Qt/multimedia
target.path = $$TARGETPATH
qmldir.files += $$QT_BUILD_TREE/imports/Qt/multimedia/qmldir
-qmldir.path += $$TARGETPATH
+qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
INSTALLS += target qmldir
diff --git a/src/imports/qimportbase.pri b/src/imports/qimportbase.pri
index 363dd88..5433059 100644
--- a/src/imports/qimportbase.pri
+++ b/src/imports/qimportbase.pri
@@ -12,7 +12,7 @@ isEmpty(TARGET) {
QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir
copy2build.input = QMLDIRFILE
-copy2build.output = $$TARGETPATH/qmldir
+copy2build.output = $$QT_BUILD_TREE/imports/$$TARGETPATH/qmldir
isEmpty(vcproj):copy2build.variable_out = PRE_TARGETDEPS
copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
copy2build.name = COPY ${QMAKE_FILE_IN}
diff --git a/src/imports/webkit/webkit.pro b/src/imports/webkit/webkit.pro
index 76b46f1..fdc12cc 100644
--- a/src/imports/webkit/webkit.pro
+++ b/src/imports/webkit/webkit.pro
@@ -1,5 +1,5 @@
TARGET = webkitqmlplugin
-TARGETPATH = $$[QT_INSTALL_IMPORTS]/org/webkit
+TARGETPATH = org/webkit
include(../qimportbase.pri)
QT += webkit declarative
@@ -14,6 +14,6 @@ QTDIR_build:DESTDIR = $$TARGETPATH
target.path = $$TARGETPATH
qmldir.files += $$QT_BUILD_TREE/imports/org/webkit/qmldir
-qmldir.path += $$TARGETPATH
+qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
INSTALLS += target qmldir
diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro
index b98be59..02223d7 100644
--- a/src/imports/widgets/widgets.pro
+++ b/src/imports/widgets/widgets.pro
@@ -1,5 +1,5 @@
TARGET = widgets
-TARGETPATH = $$[QT_INSTALL_IMPORTS]/Qt/widgets
+TARGETPATH = Qt/widgets
include(../qimportbase.pri)
QT += declarative
@@ -17,6 +17,6 @@ target.path = $$TARGETPATH
# install qmldir file
qmldir.files += qmldir
-qmldir.path = $$TARGETPATH
+qmldir.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
INSTALLS += target qmldir
diff --git a/src/multimedia/effects/qsoundeffect.cpp b/src/multimedia/effects/qsoundeffect.cpp
index f64d9ee..548ec74 100644
--- a/src/multimedia/effects/qsoundeffect.cpp
+++ b/src/multimedia/effects/qsoundeffect.cpp
@@ -134,7 +134,7 @@ QSoundEffect::QSoundEffect(QObject *parent) :
QSoundEffect::~QSoundEffect()
{
- delete d;
+ d->deleteLater();
}
QUrl QSoundEffect::source() const
diff --git a/src/multimedia/effects/qsoundeffect_pulse_p.cpp b/src/multimedia/effects/qsoundeffect_pulse_p.cpp
index c322722..e379259 100644
--- a/src/multimedia/effects/qsoundeffect_pulse_p.cpp
+++ b/src/multimedia/effects/qsoundeffect_pulse_p.cpp
@@ -234,6 +234,7 @@ Q_GLOBAL_STATIC(PulseDaemon, daemon)
QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
QObject(parent),
+ m_retry(false),
m_muted(false),
m_playQueued(false),
m_sampleLoaded(false),
@@ -250,7 +251,7 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
QSoundEffectPrivate::~QSoundEffectPrivate()
{
- delete m_reply;
+ m_reply->deleteLater();
unloadSample();
}
@@ -310,6 +311,12 @@ void QSoundEffectPrivate::setMuted(bool muted)
void QSoundEffectPrivate::play()
{
+ if (m_retry) {
+ m_retry = false;
+ setSource(m_source);
+ return;
+ }
+
if (!m_sampleLoaded) {
m_playQueued = true;
return;
@@ -338,6 +345,7 @@ void QSoundEffectPrivate::decoderReady()
pa_stream_set_state_callback(stream, stream_state_callback, this);
pa_stream_set_write_callback(stream, stream_write_callback, this);
pa_stream_connect_upload(stream, (size_t)m_waveDecoder->size());
+ m_pulseStream = stream;
daemon()->unlock();
}
@@ -377,6 +385,52 @@ void QSoundEffectPrivate::unloadSample()
m_sampleLoaded = false;
}
+void QSoundEffectPrivate::uploadSample()
+{
+ daemon()->lock();
+
+ size_t bufferSize = qMin(pa_stream_writable_size(m_pulseStream),
+ size_t(m_waveDecoder->bytesAvailable()));
+ char buffer[bufferSize];
+
+ size_t len = 0;
+ while (len < (m_waveDecoder->size())) {
+ qint64 read = m_waveDecoder->read(buffer, qMin((int)bufferSize,
+ (int)(m_waveDecoder->size()-len)));
+ if (read > 0) {
+ if (pa_stream_write(m_pulseStream, buffer, size_t(read), 0, 0, PA_SEEK_RELATIVE) == 0)
+ len += size_t(read);
+ else
+ break;
+ }
+ }
+
+ m_dataUploaded += len;
+ pa_stream_set_write_callback(m_pulseStream, NULL, NULL);
+
+ if (m_waveDecoder->size() == m_dataUploaded) {
+ int err = pa_stream_finish_upload(m_pulseStream);
+ if(err != 0) {
+ qWarning("pa_stream_finish_upload() err=%d",err);
+ pa_stream_disconnect(m_pulseStream);
+ m_retry = true;
+ m_playQueued = false;
+ QMetaObject::invokeMethod(this, "play");
+ daemon()->unlock();
+ return;
+ }
+ m_duration = m_waveDecoder->duration();
+ m_waveDecoder->deleteLater();
+ m_stream->deleteLater();
+ m_sampleLoaded = true;
+ if (m_playQueued) {
+ m_playQueued = false;
+ QMetaObject::invokeMethod(this, "play");
+ }
+ }
+ daemon()->unlock();
+}
+
void QSoundEffectPrivate::playSample()
{
pa_volume_t volume = PA_VOLUME_NORM;
@@ -412,36 +466,7 @@ void QSoundEffectPrivate::stream_write_callback(pa_stream *s, size_t length, voi
QSoundEffectPrivate *self = reinterpret_cast<QSoundEffectPrivate*>(userdata);
- size_t bufferSize = qMin(pa_stream_writable_size(s),
- size_t(self->m_waveDecoder->bytesAvailable()));
- char buffer[bufferSize];
-
- size_t len = 0;
- while (len < length) {
- qint64 read = self->m_waveDecoder->read(buffer, qMin(bufferSize, length -len));
- if (read > 0) {
- if (pa_stream_write(s, buffer, size_t(read), 0, 0, PA_SEEK_RELATIVE) == 0)
- len += size_t(read);
- else
- break;
- }
- }
- self->m_dataUploaded += len;
-
- if (self->m_waveDecoder->size() == self->m_dataUploaded) {
- pa_stream_finish_upload(s);
-
- self->m_duration = self->m_waveDecoder->duration();
-
- self->m_waveDecoder->deleteLater();
- self->m_stream->deleteLater();
-
- self->m_sampleLoaded = true;
- if (self->m_playQueued) {
- self->m_playQueued = false;
- QMetaObject::invokeMethod(self, "play");
- }
- }
+ QMetaObject::invokeMethod(self, "uploadSample", Qt::QueuedConnection);
}
void QSoundEffectPrivate::stream_state_callback(pa_stream *s, void *userdata)
diff --git a/src/multimedia/effects/qsoundeffect_pulse_p.h b/src/multimedia/effects/qsoundeffect_pulse_p.h
index 3aed018..aff729c 100644
--- a/src/multimedia/effects/qsoundeffect_pulse_p.h
+++ b/src/multimedia/effects/qsoundeffect_pulse_p.h
@@ -97,6 +97,7 @@ private Q_SLOTS:
void decoderReady();
void decoderError();
void checkPlayTime();
+ void uploadSample();
private:
void loadSample();
@@ -109,6 +110,9 @@ private:
static void stream_state_callback(pa_stream *s, void *userdata);
static void play_callback(pa_context *c, int success, void *userdata);
+ pa_stream *m_pulseStream;
+
+ bool m_retry;
bool m_muted;
bool m_playQueued;
bool m_sampleLoaded;
diff --git a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp
index 43ba22f..36c36dd 100644
--- a/src/multimedia/effects/qsoundeffect_qmedia_p.cpp
+++ b/src/multimedia/effects/qsoundeffect_qmedia_p.cpp
@@ -67,8 +67,6 @@ QSoundEffectPrivate::QSoundEffectPrivate(QObject* parent):
m_player(0)
{
m_player = new QMediaPlayer(this, QMediaPlayer::LowLatency);
- connect(m_player, SIGNAL(volumeChanged(int)), SIGNAL(volumeChanged()));
- connect(m_player, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged()));
connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(stateChanged(QMediaPlayer::State)));
}
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 8eb72b0..2b5f2f4 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1641,7 +1641,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
s->matrix = old;
}
-void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::FragmentHints hints)
+void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
+ QPainter::PixmapFragmentHints hints)
{
Q_D(QGL2PaintEngineEx);
// Use fallback for extended composition modes.
@@ -1655,9 +1656,9 @@ void QGL2PaintEngineEx::drawPixmapFragments(const QPainter::Fragment *fragments,
}
-void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::Fragment *fragments,
+void QGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFragment *fragments,
int fragmentCount, const QPixmap &pixmap,
- QPainter::FragmentHints hints)
+ QPainter::PixmapFragmentHints hints)
{
GLfloat dx = 1.0f / pixmap.size().width();
GLfloat dy = 1.0f / pixmap.size().height();
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 5d3608b..ed8fbbc 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -125,7 +125,8 @@ public:
virtual void drawTexture(const QRectF &r, GLuint textureId, const QSize &size, const QRectF &sr);
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- virtual void drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::FragmentHints hints);
+ virtual void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
+ QPainter::PixmapFragmentHints hints);
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
Qt::ImageConversionFlags flags = Qt::AutoColor);
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem);
@@ -196,7 +197,8 @@ public:
void fill(const QVectorPath &path);
void stroke(const QVectorPath &path, const QPen &pen);
void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false);
- void drawPixmapFragments(const QPainter::Fragment *fragments, int fragmentCount, const QPixmap &pixmap, QPainter::FragmentHints hints);
+ void drawPixmapFragments(const QPainter::PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap,
+ QPainter::PixmapFragmentHints hints);
void drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, QStaticTextItem *staticTextItem,
bool includeMatrixInCache);
diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp
index 5ffecc5..fdcc412 100644
--- a/src/opengl/qgl_x11egl.cpp
+++ b/src/opengl/qgl_x11egl.cpp
@@ -42,7 +42,6 @@
#include "qgl.h"
#include <private/qt_x11_p.h>
#include <private/qpixmap_x11_p.h>
-#include <private/qimagepixmapcleanuphooks_p.h>
#include <private/qgl_p.h>
#include <private/qpaintengine_opengl_p.h>
#include "qgl_egl_p.h"
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 4df894a..2c850c9 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3041,8 +3041,8 @@ void QVGPaintEngine::drawTiledPixmap
// (i.e. no opacity), no rotation or scaling, and drawing the full
// pixmap rather than parts of the pixmap. Even having just one of
// these conditions will improve performance.
-void QVGPaintEngine::drawPixmapFragments(const QPainter::Fragment *drawingData, int dataCount,
- const QPixmap &pixmap, QFlags<QPainter::FragmentHint> hints)
+void QVGPaintEngine::drawPixmapFragments(const QPainter::PixmapFragment *drawingData, int dataCount,
+ const QPixmap &pixmap, QFlags<QPainter::PixmapFragmentHint> hints)
{
#if !defined(QT_SHIVAVG)
Q_D(QVGPaintEngine);
diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h
index 1203af5..1e7e26c 100644
--- a/src/openvg/qpaintengine_vg_p.h
+++ b/src/openvg/qpaintengine_vg_p.h
@@ -137,7 +137,8 @@ public:
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
- void drawPixmapFragments(const QPainter::Fragment *drawingData, int dataCount, const QPixmap &pixmap, QFlags<QPainter::FragmentHint> hints);
+ void drawPixmapFragments(const QPainter::PixmapFragment *drawingData, int dataCount, const QPixmap &pixmap,
+ QFlags<QPainter::PixmapFragmentHint> hints);
void drawTextItem(const QPointF &p, const QTextItem &textItem);
void drawStaticTextItem(QStaticTextItem *staticTextItem);
diff --git a/src/src.pro b/src/src.pro
index 8c21ef7..403ffe1 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -112,7 +112,7 @@ src_declarative.target = sub-declarative
contains(QT_CONFIG, phonon):src_webkit.depends += src_phonon
contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns
contains(QT_CONFIG, declarative):src_declarative.depends += src_webkit
- src_imports.depends += webkit
+ src_imports.depends += src_webkit
#exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): src_webkit.depends += src_javascriptcore
}
contains(QT_CONFIG, qt3support): src_plugins.depends += src_qt3support
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp
index 4a8fc0b..cb9086c 100644
--- a/src/svg/qsvggenerator.cpp
+++ b/src/svg/qsvggenerator.cpp
@@ -310,7 +310,6 @@ public:
{
*d_func()->stream << QLatin1String("fill=\"none\" ");
*d_func()->stream << QLatin1String("stroke=\"black\" ");
- *d_func()->stream << QLatin1String("vector-effect=\"non-scaling-stroke\" ");
*d_func()->stream << QLatin1String("stroke-width=\"1\" ");
*d_func()->stream << QLatin1String("fill-rule=\"evenodd\" ");
*d_func()->stream << QLatin1String("stroke-linecap=\"square\" ");
@@ -380,13 +379,10 @@ public:
break;
}
- if (spen.widthF() == 0) {
- width = QLatin1String("1");
- stream() << "vector-effect=\"non-scaling-stroke\" ";
- }
+ if (spen.widthF() == 0)
+ stream() <<"stroke-width=\"1\" ";
else
- width = QString::number(spen.widthF());
- stream() <<"stroke-width=\""<<width<<"\" ";
+ stream() <<"stroke-width=\"" << spen.widthF() << "\" ";
switch (spen.capStyle()) {
case Qt::FlatCap:
@@ -983,14 +979,11 @@ void QSvgPaintEngine::drawPath(const QPainterPath &p)
{
Q_D(QSvgPaintEngine);
- *d->stream << "<path "
- "fill-rule=";
- if (p.fillRule() == Qt::OddEvenFill)
- *d->stream << "\"evenodd\" ";
- else
- *d->stream << "\"nonzero\" ";
-
- *d->stream << "d=\"";
+ *d->stream << "<path vector-effect=\""
+ << (state->pen().isCosmetic() ? "non-scaling-stroke" : "none")
+ << "\" fill-rule=\""
+ << (p.fillRule() == Qt::OddEvenFill ? "evenodd" : "nonzero")
+ << "\" d=\"";
for (int i=0; i<p.elementCount(); ++i) {
const QPainterPath::Element &e = p.elementAt(i);
@@ -1038,7 +1031,9 @@ void QSvgPaintEngine::drawPolygon(const QPointF *points, int pointCount,
path.lineTo(points[i]);
if (mode == PolylineMode) {
- stream() << "<polyline fill=\"none\" points=\"";
+ stream() << "<polyline fill=\"none\" vector-effect=\""
+ << (state->pen().isCosmetic() ? "non-scaling-stroke" : "none")
+ << "\" points=\"";
for (int i = 0; i < pointCount; ++i) {
const QPointF &pt = points[i];
stream() << pt.x() << ',' << pt.y() << ' ';
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp
index cd0e1ac..a29764a 100644
--- a/src/svg/qsvggraphics.cpp
+++ b/src/svg/qsvggraphics.cpp
@@ -78,33 +78,29 @@ void QSvgAnimation::draw(QPainter *, QSvgExtraStates &)
qWarning("<animation> no implemented");
}
-static inline QRectF boundsOnStroke(const QPainterPath &path, qreal width)
+static inline QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, qreal width)
{
QPainterPathStroker stroker;
stroker.setWidth(width);
QPainterPath stroke = stroker.createStroke(path);
- return stroke.boundingRect();
+ return p->transform().map(stroke).boundingRect();
}
-QSvgCircle::QSvgCircle(QSvgNode *parent, const QRectF &rect)
+QSvgEllipse::QSvgEllipse(QSvgNode *parent, const QRectF &rect)
: QSvgNode(parent), m_bounds(rect)
{
}
-QRectF QSvgCircle::bounds() const
+QRectF QSvgEllipse::bounds(QPainter *p, QSvgExtraStates &) const
{
- qreal sw = strokeWidth();
- if (qFuzzyIsNull(sw))
- return m_bounds;
- else {
- QPainterPath path;
- path.addRect(m_bounds);
- return boundsOnStroke(path, sw);
- }
+ QPainterPath path;
+ path.addEllipse(m_bounds);
+ qreal sw = strokeWidth(p);
+ return qFuzzyIsNull(sw) ? p->transform().map(path).boundingRect() : boundsOnStroke(p, path, sw);
}
-void QSvgCircle::draw(QPainter *p, QSvgExtraStates &states)
+void QSvgEllipse::draw(QPainter *p, QSvgExtraStates &states)
{
applyStyle(p, states);
QT_SVG_DRAW_SHAPE(p->drawEllipse(m_bounds));
@@ -112,9 +108,8 @@ void QSvgCircle::draw(QPainter *p, QSvgExtraStates &states)
}
QSvgArc::QSvgArc(QSvgNode *parent, const QPainterPath &path)
- : QSvgNode(parent), cubic(path)
+ : QSvgNode(parent), m_path(path)
{
- m_cachedBounds = path.boundingRect();
}
void QSvgArc::draw(QPainter *p, QSvgExtraStates &states)
@@ -123,36 +118,12 @@ void QSvgArc::draw(QPainter *p, QSvgExtraStates &states)
if (p->pen().widthF() != 0) {
qreal oldOpacity = p->opacity();
p->setOpacity(oldOpacity * states.strokeOpacity);
- p->drawPath(cubic);
+ p->drawPath(m_path);
p->setOpacity(oldOpacity);
}
revertStyle(p, states);
}
-QSvgEllipse::QSvgEllipse(QSvgNode *parent, const QRectF &rect)
- : QSvgNode(parent), m_bounds(rect)
-{
-}
-
-QRectF QSvgEllipse::bounds() const
-{
- qreal sw = strokeWidth();
- if (qFuzzyIsNull(sw))
- return m_bounds;
- else {
- QPainterPath path;
- path.addEllipse(m_bounds);
- return boundsOnStroke(path, sw);
- }
-}
-
-void QSvgEllipse::draw(QPainter *p, QSvgExtraStates &states)
-{
- applyStyle(p, states);
- QT_SVG_DRAW_SHAPE(p->drawEllipse(m_bounds));
- revertStyle(p, states);
-}
-
QSvgImage::QSvgImage(QSvgNode *parent, const QImage &image,
const QRect &bounds)
: QSvgNode(parent), m_image(image),
@@ -173,7 +144,7 @@ void QSvgImage::draw(QPainter *p, QSvgExtraStates &states)
QSvgLine::QSvgLine(QSvgNode *parent, const QLineF &line)
- : QSvgNode(parent), m_bounds(line)
+ : QSvgNode(parent), m_line(line)
{
}
@@ -184,7 +155,7 @@ void QSvgLine::draw(QPainter *p, QSvgExtraStates &states)
if (p->pen().widthF() != 0) {
qreal oldOpacity = p->opacity();
p->setOpacity(oldOpacity * states.strokeOpacity);
- p->drawLine(m_bounds);
+ p->drawLine(m_line);
p->setOpacity(oldOpacity);
}
revertStyle(p, states);
@@ -203,19 +174,11 @@ void QSvgPath::draw(QPainter *p, QSvgExtraStates &states)
revertStyle(p, states);
}
-QRectF QSvgPath::bounds() const
+QRectF QSvgPath::bounds(QPainter *p, QSvgExtraStates &) const
{
- qreal sw = strokeWidth();
- if (qFuzzyIsNull(sw)) {
- if (m_cachedBounds.isNull())
- //m_cachedBounds = m_path.controlPointRect();
- m_cachedBounds = m_path.boundingRect();
-
- return m_cachedBounds;
- }
- else {
- return boundsOnStroke(m_path, sw);
- }
+ qreal sw = strokeWidth(p);
+ return qFuzzyIsNull(sw) ? p->transform().map(m_path).boundingRect()
+ : boundsOnStroke(p, m_path, sw);
}
QSvgPolygon::QSvgPolygon(QSvgNode *parent, const QPolygonF &poly)
@@ -223,15 +186,15 @@ QSvgPolygon::QSvgPolygon(QSvgNode *parent, const QPolygonF &poly)
{
}
-QRectF QSvgPolygon::bounds() const
+QRectF QSvgPolygon::bounds(QPainter *p, QSvgExtraStates &) const
{
- qreal sw = strokeWidth();
- if (qFuzzyIsNull(sw))
- return m_poly.boundingRect();
- else {
+ qreal sw = strokeWidth(p);
+ if (qFuzzyIsNull(sw)) {
+ return p->transform().map(m_poly).boundingRect();
+ } else {
QPainterPath path;
path.addPolygon(m_poly);
- return boundsOnStroke(path, sw);
+ return boundsOnStroke(p, path, sw);
}
}
@@ -274,15 +237,15 @@ QSvgRect::QSvgRect(QSvgNode *node, const QRectF &rect, int rx, int ry)
{
}
-QRectF QSvgRect::bounds() const
+QRectF QSvgRect::bounds(QPainter *p, QSvgExtraStates &) const
{
- qreal sw = strokeWidth();
- if (qFuzzyIsNull(sw))
- return m_rect;
- else {
+ qreal sw = strokeWidth(p);
+ if (qFuzzyIsNull(sw)) {
+ return p->transform().mapRect(m_rect);
+ } else {
QPainterPath path;
path.addRect(m_rect);
- return boundsOnStroke(path, sw);
+ return boundsOnStroke(p, path, sw);
}
}
@@ -322,7 +285,7 @@ void QSvgText::setTextArea(const QSizeF &size)
m_type = TEXTAREA;
}
-//QRectF QSvgText::bounds() const {}
+//QRectF QSvgText::bounds(QPainter *p, QSvgExtraStates &) const {}
void QSvgText::draw(QPainter *p, QSvgExtraStates &states)
{
@@ -593,80 +556,57 @@ QSvgNode::Type QSvgVideo::type() const
return VIDEO;
}
-QRectF QSvgUse::bounds() const
-{
- if (m_link && m_bounds.isEmpty()) {
- m_bounds = m_link->bounds();
- m_bounds = QRectF(m_bounds.x()+m_start.x(),
- m_bounds.y()+m_start.y(),
- m_bounds.width(),
- m_bounds.height());
-
- return m_bounds;
- }
- return m_bounds;
-}
-
-QRectF QSvgUse::transformedBounds(const QTransform &transform) const
+QRectF QSvgUse::bounds(QPainter *p, QSvgExtraStates &states) const
{
QRectF bounds;
- QTransform t = transform;
-
- if (m_link) {
- QSvgTransformStyle *transStyle = m_style.transform;
- if (transStyle) {
- t = transStyle->qtransform() * t;
- }
- t.translate(m_start.x(), m_start.y());
-
- bounds = m_link->transformedBounds(t);
-
- return bounds;
+ if (m_link) {
+ p->translate(m_start);
+ bounds = m_link->transformedBounds(p, states);
+ p->translate(-m_start);
}
return bounds;
}
-QRectF QSvgPolyline::bounds() const
+QRectF QSvgPolyline::bounds(QPainter *p, QSvgExtraStates &) const
{
- qreal sw = strokeWidth();
- if (qFuzzyIsNull(sw))
- return m_poly.boundingRect();
- else {
+ qreal sw = strokeWidth(p);
+ if (qFuzzyIsNull(sw)) {
+ return p->transform().map(m_poly).boundingRect();
+ } else {
QPainterPath path;
path.addPolygon(m_poly);
- return boundsOnStroke(path, sw);
+ return boundsOnStroke(p, path, sw);
}
}
-QRectF QSvgArc::bounds() const
+QRectF QSvgArc::bounds(QPainter *p, QSvgExtraStates &) const
{
- qreal sw = strokeWidth();
- if (qFuzzyIsNull(sw))
- return m_cachedBounds;
- else {
- return boundsOnStroke(cubic, sw);
- }
+ qreal sw = strokeWidth(p);
+ return qFuzzyIsNull(sw) ? p->transform().map(m_path).boundingRect()
+ : boundsOnStroke(p, m_path, sw);
}
-QRectF QSvgImage::bounds() const
+QRectF QSvgImage::bounds(QPainter *p, QSvgExtraStates &) const
{
- return m_bounds;
+ return p->transform().mapRect(m_bounds);
}
-QRectF QSvgLine::bounds() const
+QRectF QSvgLine::bounds(QPainter *p, QSvgExtraStates &) const
{
- qreal sw = strokeWidth();
+ qreal sw = strokeWidth(p);
if (qFuzzyIsNull(sw)) {
- qreal minX = qMin(m_bounds.x1(), m_bounds.x2());
- qreal minY = qMin(m_bounds.y1(), m_bounds.y2());
- qreal maxX = qMax(m_bounds.x1(), m_bounds.x2());
- qreal maxY = qMax(m_bounds.y1(), m_bounds.y2());
- return QRectF(minX, minY, maxX-minX, maxY-minY);
+ QPointF p1 = p->transform().map(m_line.p1());
+ QPointF p2 = p->transform().map(m_line.p2());
+ qreal minX = qMin(p1.x(), p2.x());
+ qreal minY = qMin(p1.y(), p2.y());
+ qreal maxX = qMax(p1.x(), p2.x());
+ qreal maxY = qMax(p1.y(), p2.y());
+ return QRectF(minX, minY, maxX - minX, maxY - minY);
} else {
QPainterPath path;
- path.moveTo(m_bounds.x1(), m_bounds.y1());
- path.lineTo(m_bounds.x2(), m_bounds.y2());
- return boundsOnStroke(path, sw);
+ path.moveTo(m_line.p1());
+ path.lineTo(m_line.p2());
+ return boundsOnStroke(p, path, sw);
}
}
diff --git a/src/svg/qsvggraphics_p.h b/src/svg/qsvggraphics_p.h
index ca06777..fdc770a 100644
--- a/src/svg/qsvggraphics_p.h
+++ b/src/svg/qsvggraphics_p.h
@@ -80,32 +80,27 @@ public:
QSvgArc(QSvgNode *parent, const QPainterPath &path);
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
- QPainterPath cubic;
- QRectF m_cachedBounds;
+ QPainterPath m_path;
};
-class QSvgCircle : public QSvgNode
+class QSvgEllipse : public QSvgNode
{
public:
- QSvgCircle(QSvgNode *parent, const QRectF &rect);
+ QSvgEllipse(QSvgNode *parent, const QRectF &rect);
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
QRectF m_bounds;
};
-class QSvgEllipse : public QSvgNode
+class QSvgCircle : public QSvgEllipse
{
public:
- QSvgEllipse(QSvgNode *parent, const QRectF &rect);
- virtual void draw(QPainter *p, QSvgExtraStates &states);
+ QSvgCircle(QSvgNode *parent, const QRectF &rect) : QSvgEllipse(parent, rect) { }
virtual Type type() const;
- virtual QRectF bounds() const;
-private:
- QRectF m_bounds;
};
class QSvgImage : public QSvgNode
@@ -115,7 +110,7 @@ public:
const QRect &bounds);
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
QImage m_image;
QRect m_bounds;
@@ -127,9 +122,9 @@ public:
QSvgLine(QSvgNode *parent, const QLineF &line);
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
- QLineF m_bounds;
+ QLineF m_line;
};
class QSvgPath : public QSvgNode
@@ -138,14 +133,13 @@ public:
QSvgPath(QSvgNode *parent, const QPainterPath &qpath);
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
QPainterPath *qpath() {
return &m_path;
}
private:
QPainterPath m_path;
- mutable QRectF m_cachedBounds;
};
class QSvgPolygon : public QSvgNode
@@ -154,7 +148,7 @@ public:
QSvgPolygon(QSvgNode *parent, const QPolygonF &poly);
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
QPolygonF m_poly;
};
@@ -165,7 +159,7 @@ public:
QSvgPolyline(QSvgNode *parent, const QPolygonF &poly);
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
QPolygonF m_poly;
};
@@ -176,7 +170,7 @@ public:
QSvgRect(QSvgNode *paren, const QRectF &rect, int rx=0, int ry=0);
virtual Type type() const;
virtual void draw(QPainter *p, QSvgExtraStates &states);
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
QRectF m_rect;
int m_rx, m_ry;
@@ -205,7 +199,7 @@ public:
void addLineBreak() {m_tspans.append(LINEBREAK);}
void setWhitespaceMode(WhitespaceMode mode) {m_mode = mode;}
- //virtual QRectF bounds() const;
+ //virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
static QSvgTspan * const LINEBREAK;
@@ -248,13 +242,11 @@ public:
QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *link);
virtual void draw(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
- virtual QRectF bounds() const;
- virtual QRectF transformedBounds(const QTransform &transform) const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
private:
QSvgNode *m_link;
QPointF m_start;
- mutable QRectF m_bounds;
};
class QSvgVideo : public QSvgNode
diff --git a/src/svg/qsvgnode.cpp b/src/svg/qsvgnode.cpp
index 86f2af5..f6bc1c0 100644
--- a/src/svg/qsvgnode.cpp
+++ b/src/svg/qsvgnode.cpp
@@ -45,6 +45,7 @@
#ifndef QT_NO_SVG
#include "qdebug.h"
+#include "qstack.h"
QT_BEGIN_NAMESPACE
@@ -114,12 +115,12 @@ void QSvgNode::appendStyleProperty(QSvgStyleProperty *prop, const QString &id)
}
}
-void QSvgNode::applyStyle(QPainter *p, QSvgExtraStates &states)
+void QSvgNode::applyStyle(QPainter *p, QSvgExtraStates &states) const
{
- m_style.apply(p, bounds(), this, states);
+ m_style.apply(p, this, states);
}
-void QSvgNode::revertStyle(QPainter *p, QSvgExtraStates &states)
+void QSvgNode::revertStyle(QPainter *p, QSvgExtraStates &states) const
{
m_style.revert(p, states);
}
@@ -195,11 +196,40 @@ QSvgFillStyleProperty * QSvgNode::styleProperty(const QString &id) const
return doc ? doc->namedStyle(rid) : 0;
}
-QRectF QSvgNode::bounds() const
+QRectF QSvgNode::bounds(QPainter *, QSvgExtraStates &) const
{
return QRectF(0, 0, 0, 0);
}
+QRectF QSvgNode::transformedBounds() const
+{
+ if (!m_cachedBounds.isEmpty())
+ return m_cachedBounds;
+
+ QImage dummy(1, 1, QImage::Format_RGB32);
+ QPainter p(&dummy);
+ QSvgExtraStates states;
+
+ QPen pen(Qt::NoBrush, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+ pen.setMiterLimit(4);
+ p.setPen(pen);
+
+ QStack<QSvgNode*> parentApplyStack;
+ QSvgNode *parent = m_parent;
+ while (parent) {
+ parentApplyStack.push(parent);
+ parent = parent->parent();
+ }
+
+ for (int i = parentApplyStack.size() - 1; i >= 0; --i)
+ parentApplyStack[i]->applyStyle(&p, states);
+
+ p.setWorldTransform(QTransform());
+
+ m_cachedBounds = transformedBounds(&p, states);
+ return m_cachedBounds;
+}
+
QSvgTinyDocument * QSvgNode::document() const
{
QSvgTinyDocument *doc = 0;
@@ -274,19 +304,11 @@ void QSvgNode::setVisible(bool visible)
m_visible = visible;
}
-QRectF QSvgNode::transformedBounds(const QTransform &transform) const
+QRectF QSvgNode::transformedBounds(QPainter *p, QSvgExtraStates &states) const
{
- QTransform t = transform;
-
- QSvgTransformStyle *transStyle = m_style.transform;
- if (transStyle) {
- t = transStyle->qtransform() * t;
- }
-
- QRectF rect = bounds();
-
- rect = t.mapRect(rect);
-
+ applyStyle(p, states);
+ QRectF rect = bounds(p, states);
+ revertStyle(p, states);
return rect;
}
@@ -310,15 +332,12 @@ QSvgNode::DisplayMode QSvgNode::displayMode() const
return m_displayMode;
}
-qreal QSvgNode::strokeWidth() const
+qreal QSvgNode::strokeWidth(QPainter *p)
{
- QSvgStrokeStyle *stroke = static_cast<QSvgStrokeStyle*>(
- styleProperty(QSvgStyleProperty::STROKE));
- if (!stroke)
- return 0;
- if (stroke->stroke().brush().style() == Qt::NoBrush)
+ QPen pen = p->pen();
+ if (pen.style() == Qt::NoPen || pen.brush().style() == Qt::NoBrush || pen.isCosmetic())
return 0;
- return stroke->width();
+ return pen.widthF();
}
QT_END_NAMESPACE
diff --git a/src/svg/qsvgnode_p.h b/src/svg/qsvgnode_p.h
index 15466f2..a34c7c0 100644
--- a/src/svg/qsvgnode_p.h
+++ b/src/svg/qsvgnode_p.h
@@ -118,16 +118,17 @@ public:
QSvgNode *parent() const;
void appendStyleProperty(QSvgStyleProperty *prop, const QString &id);
- void applyStyle(QPainter *p, QSvgExtraStates &states);
- void revertStyle(QPainter *p, QSvgExtraStates &states);
+ void applyStyle(QPainter *p, QSvgExtraStates &states) const;
+ void revertStyle(QPainter *p, QSvgExtraStates &states) const;
QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const;
QSvgFillStyleProperty *styleProperty(const QString &id) const;
QSvgTinyDocument *document() const;
virtual Type type() const =0;
- virtual QRectF bounds() const;
- virtual QRectF transformedBounds(const QTransform &transform) const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
+ virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const;
+ QRectF transformedBounds() const;
void setRequiredFeatures(const QStringList &lst);
const QStringList & requiredFeatures() const;
@@ -156,9 +157,9 @@ public:
QString xmlClass() const;
void setXmlClass(const QString &str);
protected:
- QSvgStyle m_style;
+ mutable QSvgStyle m_style;
- qreal strokeWidth() const;
+ static qreal strokeWidth(QPainter *p);
private:
QSvgNode *m_parent;
@@ -174,6 +175,7 @@ private:
QString m_class;
DisplayMode m_displayMode;
+ mutable QRectF m_cachedBounds;
friend class QSvgTinyDocument;
};
diff --git a/src/svg/qsvgstructure.cpp b/src/svg/qsvgstructure.cpp
index 34426b7..db5cb9e 100644
--- a/src/svg/qsvgstructure.cpp
+++ b/src/svg/qsvgstructure.cpp
@@ -357,15 +357,12 @@ void QSvgSwitch::init()
m_systemLanguagePrefix = m_systemLanguage.mid(0, idx);
}
-QRectF QSvgStructureNode::bounds() const
+QRectF QSvgStructureNode::bounds(QPainter *p, QSvgExtraStates &states) const
{
- if (m_bounds.isEmpty()) {
- foreach(QSvgNode *node, m_renderers) {
- m_bounds |= node->transformedBounds(QTransform());
- }
- }
-
- return m_bounds;
+ QRectF bounds;
+ foreach(QSvgNode *node, m_renderers)
+ bounds |= node->transformedBounds(p, states);
+ return bounds;
}
QSvgNode * QSvgStructureNode::previousSiblingNode(QSvgNode *n) const
diff --git a/src/svg/qsvgstructure_p.h b/src/svg/qsvgstructure_p.h
index fd6eb0a..dd82fc0 100644
--- a/src/svg/qsvgstructure_p.h
+++ b/src/svg/qsvgstructure_p.h
@@ -74,14 +74,13 @@ public:
~QSvgStructureNode();
QSvgNode *scopeNode(const QString &id) const;
void addChild(QSvgNode *child, const QString &id);
- virtual QRectF bounds() const;
+ virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
QSvgNode *previousSiblingNode(QSvgNode *n) const;
QList<QSvgNode*> renderers() const { return m_renderers; }
protected:
QList<QSvgNode*> m_renderers;
QHash<QString, QSvgNode*> m_scope;
QList<QSvgStructureNode*> m_linkedScopes;
- mutable QRectF m_bounds;
};
class QSvgG : public QSvgStructureNode
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index 2b12c49..0d1bad9 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -73,7 +73,7 @@ QSvgStyleProperty::~QSvgStyleProperty()
{
}
-void QSvgFillStyleProperty::apply(QPainter *, const QRectF &, QSvgNode *, QSvgExtraStates &)
+void QSvgFillStyleProperty::apply(QPainter *, const QSvgNode *, QSvgExtraStates &)
{
Q_ASSERT(!"This should not be called!");
}
@@ -89,7 +89,7 @@ QSvgQualityStyle::QSvgQualityStyle(int color)
{
}
-void QSvgQualityStyle::apply(QPainter *, const QRectF &, QSvgNode *, QSvgExtraStates &)
+void QSvgQualityStyle::apply(QPainter *, const QSvgNode *, QSvgExtraStates &)
{
}
@@ -136,7 +136,7 @@ void QSvgFillStyle::setBrush(QBrush brush)
m_fillSet = 1;
}
-void QSvgFillStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
+void QSvgFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
{
m_oldFill = p->brush();
m_oldFillRule = states.fillRule;
@@ -169,7 +169,7 @@ QSvgViewportFillStyle::QSvgViewportFillStyle(const QBrush &brush)
{
}
-void QSvgViewportFillStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
+void QSvgViewportFillStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
{
m_oldFill = p->brush();
p->setBrush(m_viewportFill);
@@ -224,7 +224,7 @@ int QSvgFontStyle::SVGToQtWeight(int weight) {
return QFont::Normal;
}
-void QSvgFontStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
+void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
{
m_oldQFont = p->font();
m_oldSvgFont = states.svgFont;
@@ -292,7 +292,7 @@ QSvgStrokeStyle::QSvgStrokeStyle()
{
}
-void QSvgStrokeStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &states)
+void QSvgStrokeStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
{
m_oldStroke = p->pen();
m_oldStrokeOpacity = states.strokeOpacity;
@@ -443,7 +443,7 @@ QSvgTransformStyle::QSvgTransformStyle(const QTransform &trans)
{
}
-void QSvgTransformStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
+void QSvgTransformStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
{
m_oldWorldTransform = p->worldTransform();
p->setWorldTransform(m_transform, true);
@@ -501,7 +501,7 @@ QSvgCompOpStyle::QSvgCompOpStyle(QPainter::CompositionMode mode)
}
-void QSvgCompOpStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
+void QSvgCompOpStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
{
m_oldMode = p->compositionMode();
p->setCompositionMode(m_mode);
@@ -521,34 +521,34 @@ QSvgStyle::~QSvgStyle()
{
}
-void QSvgStyle::apply(QPainter *p, const QRectF &rect, QSvgNode *node, QSvgExtraStates &states)
+void QSvgStyle::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)
{
if (quality) {
- quality->apply(p, rect, node, states);
+ quality->apply(p, node, states);
}
if (fill) {
- fill->apply(p, rect, node, states);
+ fill->apply(p, node, states);
}
if (viewportFill) {
- viewportFill->apply(p, rect, node, states);
+ viewportFill->apply(p, node, states);
}
if (font) {
- font->apply(p, rect, node, states);
+ font->apply(p, node, states);
}
if (stroke) {
- stroke->apply(p, rect, node, states);
+ stroke->apply(p, node, states);
}
if (transform) {
- transform->apply(p, rect, node, states);
+ transform->apply(p, node, states);
}
if (animateColor) {
- animateColor->apply(p, rect, node, states);
+ animateColor->apply(p, node, states);
}
//animated transforms have to be applied
@@ -572,16 +572,16 @@ void QSvgStyle::apply(QPainter *p, const QRectF &rect, QSvgNode *node, QSvgExtra
// Apply the animateTransforms after and including the last one with additive="replace".
for (; itr != animateTransforms.constEnd(); ++itr) {
if ((*itr)->animActive(totalTimeElapsed))
- (*itr)->apply(p, rect, node, states);
+ (*itr)->apply(p, node, states);
}
}
if (opacity) {
- opacity->apply(p, rect, node, states);
+ opacity->apply(p, node, states);
}
if (compop) {
- compop->apply(p, rect, node, states);
+ compop->apply(p, node, states);
}
}
@@ -655,7 +655,7 @@ void QSvgAnimateTransform::setArgs(TransformType type, Additive additive, const
m_count = args.count() / 3;
}
-void QSvgAnimateTransform::apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &)
+void QSvgAnimateTransform::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &)
{
m_oldWorldTransform = p->worldTransform();
resolveMatrix(node);
@@ -669,7 +669,7 @@ void QSvgAnimateTransform::revert(QPainter *p, QSvgExtraStates &)
m_transformApplied = false;
}
-void QSvgAnimateTransform::resolveMatrix(QSvgNode *node)
+void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node)
{
static const qreal deg2rad = qreal(0.017453292519943295769);
qreal totalTimeElapsed = node->document()->currentElapsed();
@@ -834,7 +834,7 @@ void QSvgAnimateColor::setRepeatCount(qreal repeatCount)
m_repeatCount = repeatCount;
}
-void QSvgAnimateColor::apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &)
+void QSvgAnimateColor::apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &)
{
qreal totalTimeElapsed = node->document()->currentElapsed();
if (totalTimeElapsed < m_from || m_finished)
@@ -912,7 +912,7 @@ QSvgOpacityStyle::QSvgOpacityStyle(qreal opacity)
}
-void QSvgOpacityStyle::apply(QPainter *p, const QRectF &, QSvgNode *, QSvgExtraStates &)
+void QSvgOpacityStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &)
{
m_oldOpacity = p->opacity();
p->setOpacity(m_opacity * m_oldOpacity);
diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h
index 202de93..af3b4e5 100644
--- a/src/svg/qsvgstyle_p.h
+++ b/src/svg/qsvgstyle_p.h
@@ -172,7 +172,7 @@ public:
};
public:
virtual ~QSvgStyleProperty();
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states) =0;
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states) = 0;
virtual void revert(QPainter *p, QSvgExtraStates &states) =0;
virtual Type type() const=0;
};
@@ -181,7 +181,7 @@ class QSvgFillStyleProperty : public QSvgStyleProperty
{
public:
virtual QBrush brush(QPainter *p, QSvgExtraStates &states) = 0;
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
};
@@ -189,7 +189,7 @@ class QSvgQualityStyle : public QSvgStyleProperty
{
public:
QSvgQualityStyle(int color);
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
private:
@@ -221,7 +221,7 @@ class QSvgOpacityStyle : public QSvgStyleProperty
{
public:
QSvgOpacityStyle(qreal opacity);
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
private:
@@ -233,7 +233,7 @@ class QSvgFillStyle : public QSvgStyleProperty
{
public:
QSvgFillStyle();
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
@@ -306,7 +306,7 @@ class QSvgViewportFillStyle : public QSvgStyleProperty
{
public:
QSvgViewportFillStyle(const QBrush &brush);
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
@@ -330,7 +330,7 @@ public:
QSvgFontStyle(QSvgFont *font, QSvgTinyDocument *doc);
QSvgFontStyle();
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
@@ -410,7 +410,7 @@ class QSvgStrokeStyle : public QSvgStyleProperty
{
public:
QSvgStrokeStyle();
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
@@ -617,7 +617,7 @@ class QSvgTransformStyle : public QSvgStyleProperty
{
public:
QSvgTransformStyle(const QTransform &transform);
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
@@ -654,7 +654,7 @@ public:
void setArgs(TransformType type, Additive additive, const QVector<qreal> &args);
void setFreeze(bool freeze);
void setRepeatCount(qreal repeatCount);
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
QSvgAnimateTransform::Additive additiveType() const
@@ -688,7 +688,7 @@ public:
}
protected:
- void resolveMatrix(QSvgNode *node);
+ void resolveMatrix(const QSvgNode *node);
private:
qreal m_from, m_to, m_by;
qreal m_totalRunningTime;
@@ -712,7 +712,7 @@ public:
void setArgs(bool fill, const QList<QColor> &colors);
void setFreeze(bool freeze);
void setRepeatCount(qreal repeatCount);
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
private:
@@ -732,7 +732,7 @@ class QSvgCompOpStyle : public QSvgStyleProperty
{
public:
QSvgCompOpStyle(QPainter::CompositionMode mode);
- virtual void apply(QPainter *p, const QRectF &, QSvgNode *node, QSvgExtraStates &states);
+ virtual void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
virtual void revert(QPainter *p, QSvgExtraStates &states);
virtual Type type() const;
@@ -766,7 +766,7 @@ public:
{}
~QSvgStyle();
- void apply(QPainter *p, const QRectF &rect, QSvgNode *node, QSvgExtraStates &states);
+ void apply(QPainter *p, const QSvgNode *node, QSvgExtraStates &states);
void revert(QPainter *p, QSvgExtraStates &states);
QSvgRefCounter<QSvgQualityStyle> quality;
QSvgRefCounter<QSvgFillStyle> fill;
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
index 17618f7..b21b99f 100644
--- a/src/svg/qsvgtinydocument.cpp
+++ b/src/svg/qsvgtinydocument.cpp
@@ -277,7 +277,7 @@ void QSvgTinyDocument::draw(QPainter *p, const QString &id,
p->save();
- const QRectF elementBounds = node->transformedBounds(QTransform());
+ const QRectF elementBounds = node->transformedBounds();
mapSourceToTarget(p, bounds, elementBounds);
QTransform originalTransform = p->worldTransform();
@@ -299,7 +299,7 @@ void QSvgTinyDocument::draw(QPainter *p, const QString &id,
for (int i = parentApplyStack.size() - 1; i >= 0; --i)
parentApplyStack[i]->applyStyle(p, m_states);
-
+
// Reset the world transform so that our parents don't affect
// the position
QTransform currentTransform = p->worldTransform();
@@ -432,8 +432,7 @@ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
const QSvgNode *node = scopeNode(id);
if (!node)
node = this;
-
- return node->transformedBounds(QTransform());
+ return node->transformedBounds();
}
bool QSvgTinyDocument::elementExists(const QString &id) const
diff --git a/src/svg/qsvgtinydocument_p.h b/src/svg/qsvgtinydocument_p.h
index c03c798..3b40770 100644
--- a/src/svg/qsvgtinydocument_p.h
+++ b/src/svg/qsvgtinydocument_p.h
@@ -173,9 +173,8 @@ inline bool QSvgTinyDocument::heightPercent() const
inline QRectF QSvgTinyDocument::viewBox() const
{
- if (m_viewBox.isNull()) {
- m_viewBox = transformedBounds(QTransform());
- }
+ if (m_viewBox.isNull())
+ m_viewBox = transformedBounds();
return m_viewBox;
}