aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Guminiak <michal.guminiak@teleca.com>2010-08-10 08:46:23 +0200
committerDominik Kapusta <dominik.kapusta@teleca.com>2010-08-10 10:09:56 +0200
commitbb25ed49c33875a810bded45c58533f6815ff408 (patch)
tree4e7705197fca885a7b924f64ab48e090bf9355c0
parent2d20d449a765b858560e05abe5e02f9aed39593a (diff)
Fixes: Improving speed of taking screenshot for rotation animation.
RevBy: Marcin, Dominik Details: Rendering scene to an image and drawing this image in the rotation animation is quite slow. In some cases the fadeout animation of the snapshot could have finished before we were ready to display it.
-rw-r--r--src/corelib/animation/scene/mcrossfadedorientationanimation.cpp2
-rw-r--r--src/corelib/animation/scene/msnapshotitem.cpp26
-rw-r--r--src/corelib/animation/scene/msnapshotitem.h5
3 files changed, 9 insertions, 24 deletions
diff --git a/src/corelib/animation/scene/mcrossfadedorientationanimation.cpp b/src/corelib/animation/scene/mcrossfadedorientationanimation.cpp
index 3ef83853..66a7bf91 100644
--- a/src/corelib/animation/scene/mcrossfadedorientationanimation.cpp
+++ b/src/corelib/animation/scene/mcrossfadedorientationanimation.cpp
@@ -74,7 +74,7 @@ void MCrossFadedOrientationAnimationPrivate::createRootElementSnapshot()
// temporarily hide the scene background.
// hide scene background
- snapshot = new MSnapshotItem(scene, visibleSceneRect);
+ snapshot = new MSnapshotItem(visibleSceneRect);
// show scene background
scene->addItem(snapshot);
diff --git a/src/corelib/animation/scene/msnapshotitem.cpp b/src/corelib/animation/scene/msnapshotitem.cpp
index 86ee395a..fb04ac18 100644
--- a/src/corelib/animation/scene/msnapshotitem.cpp
+++ b/src/corelib/animation/scene/msnapshotitem.cpp
@@ -3,31 +3,17 @@
#include <QGraphicsScene>
#include <QImage>
#include <QPainter>
+#include <QApplication>
+#include <QDesktopWidget>
-MSnapshotItem::MSnapshotItem(QGraphicsScene *scene, const QRectF &sceneTargetRect, QGraphicsItem *parent)
+MSnapshotItem::MSnapshotItem(const QRectF &sceneTargetRect, QGraphicsItem *parent)
: QGraphicsObject(parent), m_boundingRect(sceneTargetRect)
{
- // Assumes that the resolution is one scene unit per pixel
- image = new QImage(sceneTargetRect.width(), sceneTargetRect.height(),
- QImage::Format_ARGB32_Premultiplied);
-
- QRectF targetRect;
- targetRect.setX(0.0f);
- targetRect.setY(0.0f);
- targetRect.setWidth(sceneTargetRect.width());
- targetRect.setHeight(sceneTargetRect.height());
-
- QRectF sourceRect;
- sourceRect = sceneTargetRect;
-
- QPainter painter(image);
- scene->render(&painter, targetRect, sourceRect);
+ pixmap = QPixmap::grabWindow(QApplication::desktop()->winId());
}
MSnapshotItem::~MSnapshotItem()
{
- delete image;
- image = 0;
}
QRectF MSnapshotItem::boundingRect() const
@@ -41,7 +27,5 @@ void MSnapshotItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
Q_UNUSED(option);
Q_UNUSED(widget);
- painter->setRenderHint(QPainter::Antialiasing, true);
- painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
- painter->drawImage(0, 0, *image);
+ painter->drawPixmap(0,0, pixmap);
}
diff --git a/src/corelib/animation/scene/msnapshotitem.h b/src/corelib/animation/scene/msnapshotitem.h
index 1a92ff10..82eaeb78 100644
--- a/src/corelib/animation/scene/msnapshotitem.h
+++ b/src/corelib/animation/scene/msnapshotitem.h
@@ -6,12 +6,13 @@
class QGraphicsScene;
class QRectF;
class QImage;
+class QPixmap;
class MSnapshotItem : public QGraphicsObject
{
Q_OBJECT
public:
- MSnapshotItem(QGraphicsScene *scene, const QRectF &targetRect,
+ MSnapshotItem(const QRectF &targetRect,
QGraphicsItem *parent = 0);
virtual ~MSnapshotItem();
@@ -23,7 +24,7 @@ public:
private:
QRectF m_boundingRect;
- QImage *image;
+ QPixmap pixmap;
};
#endif