summaryrefslogtreecommitdiff
path: root/libsowatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-17 02:29:28 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-17 02:29:28 +0200
commit9c44782c5eab5635ca6adf4717409bf2ffb6c694 (patch)
tree99f774bccb6e964864168b346155bbd5a52bf3b2 /libsowatch
parentf9ac9d207025fb8d40d1be753cde78beb77aa202 (diff)
downloadsowatch-9c44782c5eab5635ca6adf4717409bf2ffb6c694.tar.gz
sowatch-9c44782c5eab5635ca6adf4717409bf2ffb6c694.zip
new nekowatchlet and minor graphics/performance changes
Diffstat (limited to 'libsowatch')
-rw-r--r--libsowatch/graphicswatchlet.cpp28
-rw-r--r--libsowatch/graphicswatchlet.h6
-rw-r--r--libsowatch/watchpaintengine.cpp19
-rw-r--r--libsowatch/watchserver.cpp5
4 files changed, 50 insertions, 8 deletions
diff --git a/libsowatch/graphicswatchlet.cpp b/libsowatch/graphicswatchlet.cpp
index 2d58ff6..08441b0 100644
--- a/libsowatch/graphicswatchlet.cpp
+++ b/libsowatch/graphicswatchlet.cpp
@@ -7,8 +7,10 @@
using namespace sowatch;
-GraphicsWatchlet::GraphicsWatchlet(WatchServer* server, const QString& id) :
- Watchlet(server, id), _scene(0), _frameTimer(), _damaged()
+GraphicsWatchlet::GraphicsWatchlet(WatchServer* server, const QString& id)
+ : Watchlet(server, id),
+ _scene(0), _frameTimer(),
+ _fullUpdateMode(false), _damaged()
{
_frameTimer.setSingleShot(true);
connect(&_frameTimer, SIGNAL(timeout()), SLOT(frameTimeout()));
@@ -35,6 +37,16 @@ void GraphicsWatchlet::setScene(QGraphicsScene *scene)
}
}
+bool GraphicsWatchlet::fullUpdateMode() const
+{
+ return _fullUpdateMode;
+}
+
+void GraphicsWatchlet::setFullUpdateMode(bool fullUpdateMode)
+{
+ _fullUpdateMode = fullUpdateMode;
+}
+
QRectF GraphicsWatchlet::sceneRect() const
{
if (_scene) {
@@ -56,12 +68,16 @@ QRect GraphicsWatchlet::viewportRect() const
void GraphicsWatchlet::sceneChanged(const QList<QRectF> &rects)
{
+ // Only consider scene updates if the watchlet is active
if (_active) {
- // Only consider scene updates if the watchlet is active
QRect viewport = viewportRect();
- foreach(const QRectF& frect, rects) {
- QRect rect = frect.toAlignedRect() & viewport;
- _damaged += rect;
+ if (_fullUpdateMode) {
+ _damaged += viewport;
+ } else {
+ foreach(const QRectF& frect, rects) {
+ QRect rect = frect.toAlignedRect() & viewport;
+ _damaged += rect;
+ }
}
// Start frame timer if we got new data
diff --git a/libsowatch/graphicswatchlet.h b/libsowatch/graphicswatchlet.h
index 34f69cb..24413da 100644
--- a/libsowatch/graphicswatchlet.h
+++ b/libsowatch/graphicswatchlet.h
@@ -13,6 +13,8 @@ namespace sowatch
class SOWATCH_EXPORT GraphicsWatchlet : public Watchlet
{
Q_OBJECT
+ Q_PROPERTY(bool fullUpdateMode READ fullUpdateMode WRITE setFullUpdateMode)
+
public:
explicit GraphicsWatchlet(WatchServer* server, const QString& id);
~GraphicsWatchlet();
@@ -20,6 +22,9 @@ public:
QGraphicsScene* scene();
void setScene(QGraphicsScene* scene);
+ bool fullUpdateMode() const;
+ void setFullUpdateMode(bool fullUpdateMode);
+
QRectF sceneRect() const;
QRect viewportRect() const;
@@ -38,6 +43,7 @@ private slots:
void frameTimeout();
private:
+ bool _fullUpdateMode;
QRegion _damaged;
};
diff --git a/libsowatch/watchpaintengine.cpp b/libsowatch/watchpaintengine.cpp
index 78e6dfd..ea0dad8 100644
--- a/libsowatch/watchpaintengine.cpp
+++ b/libsowatch/watchpaintengine.cpp
@@ -5,8 +5,13 @@
using namespace sowatch;
+#define ENABLE_TRACE 0
+
+#if ENABLE_TRACE
+#define TRACE(x) x
+#else
#define TRACE(x)
-//#define TRACE(x) x
+#endif
WatchPaintEngine::WatchPaintEngine()
: QPaintEngine(QPaintEngine::AllFeatures),
@@ -31,19 +36,26 @@ bool WatchPaintEngine::begin(QPaintDevice *pdev)
_clipRegion = _area;
_transform = QTransform();
+ TRACE(qDebug() << " -- BEGIN FRAME -----");
+
return _painter.begin(pdev);
}
bool WatchPaintEngine::end()
{
+ TRACE(qDebug() << " -- END FRAME -------");
+ TRACE(qDebug() << _damaged << "------");
+
return _painter.end();
}
void WatchPaintEngine::damageMappedRect(const QRect &r)
{
if (_clipEnabled) {
+ TRACE(qDebug() << "Damaging" << _clipRegion.intersected(r));
_damaged += _clipRegion.intersected(r);
} else {
+ TRACE(qDebug() << "Damaging" << r);
_damaged += r;
}
}
@@ -152,12 +164,14 @@ void WatchPaintEngine::drawPath(const QPainterPath &path)
void WatchPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
{
+ TRACE(qDebug() << __func__ << r << pm << sr);
damageRect(r);
_painter.drawPixmap(r, pm, sr);
}
void WatchPaintEngine::drawPoints(const QPointF *points, int pointCount)
{
+ TRACE(qDebug() << __func__ << points);
int i;
for (i = 0; i < pointCount; i++) {
const QPointF& p = points[i];
@@ -169,6 +183,7 @@ void WatchPaintEngine::drawPoints(const QPointF *points, int pointCount)
void WatchPaintEngine::drawPoints(const QPoint *points, int pointCount)
{
+ TRACE(qDebug() << __func__ << points);
int i;
for (i = 0; i < pointCount; i++) {
const QPoint& p = points[i];
@@ -180,6 +195,7 @@ void WatchPaintEngine::drawPoints(const QPoint *points, int pointCount)
void WatchPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
{
+ TRACE(qDebug() << __func__ << points);
QPolygonF p(pointCount);
int i;
for (i = 0; i < pointCount; i++) {
@@ -192,6 +208,7 @@ void WatchPaintEngine::drawPolygon(const QPointF *points, int pointCount, Polygo
void WatchPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
{
+ TRACE(qDebug() << __func__ << points);
QPolygon p(pointCount);
int i;
for (i = 0; i < pointCount; i++) {
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index 511c2c5..3d9db24 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -58,13 +58,16 @@ void WatchServer::setNextWatchletButton(const QString& value)
void WatchServer::addWatchlet(Watchlet *watchlet)
{
+ Q_ASSERT(watchlet);
insertWatchlet(_watchlets.size(), watchlet);
}
void WatchServer::insertWatchlet(int position, Watchlet *watchlet)
{
- const QString id = watchlet->id();
+ Q_ASSERT(watchlet);
Q_ASSERT(watchlet->_server == this);
+
+ const QString id = watchlet->id();
Q_ASSERT(!_watchletIds.contains(id));
_watchlets.insert(position, watchlet);