diff options
Diffstat (limited to 'metawatch/metawatchpaintengine.cpp')
-rw-r--r-- | metawatch/metawatchpaintengine.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/metawatch/metawatchpaintengine.cpp b/metawatch/metawatchpaintengine.cpp index 71ad452..58a7b9d 100644 --- a/metawatch/metawatchpaintengine.cpp +++ b/metawatch/metawatchpaintengine.cpp @@ -3,19 +3,37 @@ using namespace sowatch; -MetaWatchPaintEngine::MetaWatchPaintEngine(MetaWatch* watch, QImage* image) : - WatchPaintEngine(watch, image), _watch(watch), - _imageRect(image->rect()) +MetaWatchPaintEngine::MetaWatchPaintEngine(MetaWatch* watch) : + WatchPaintEngine(watch), _watch(watch), + _imageRect(0, 0, MetaWatch::screenWidth, MetaWatch::screenHeight) { } +bool MetaWatchPaintEngine::begin(QPaintDevice *pdev) +{ + _damaged = QRegion(); + _watch = static_cast<MetaWatch*>(pdev); + _mode = _watch->paintTargetMode(); + + return _painter.begin(_watch->imageFor(_mode)); +} + +bool MetaWatchPaintEngine::end() +{ + bool ret = _painter.end(); + if (ret) { + _watch->update(_mode, _damaged.rects().toList()); + } + return ret; +} + void MetaWatchPaintEngine::drawRects(const QRectF *rects, int rectCount) { int i; for (i = 0; i < rectCount; i++) { const QRectF& r = rects[i]; if (_hasBrush && fillsEntireImage(r.toRect()) && (_isBrushBlack | _isBrushWhite)) { - _watch->clear(_isBrushWhite); + _watch->clear(_mode, _isBrushBlack); _damaged = QRegion(); continue; } @@ -38,7 +56,7 @@ void MetaWatchPaintEngine::drawRects(const QRect *rects, int rectCount) for (i = 0; i < rectCount; i++) { const QRect& r = rects[i]; if (_hasBrush && fillsEntireImage(r) && (_isBrushBlack | _isBrushWhite)) { - _watch->clear(_isBrushWhite); + _watch->clear(_mode, _isBrushBlack); _damaged = QRegion(); continue; } |