diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2012-01-23 10:42:01 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-27 17:49:17 (GMT) |
commit | c9b18c882915b8f31c8c99bfc271a87800ba61ed (patch) | |
tree | 51243e747fd3ea132417e836d7a1b0c48b7e1043 /src/gui | |
parent | fcb241b874330a045e5ba4634598476706ca7fdc (diff) | |
download | Qt-c9b18c882915b8f31c8c99bfc271a87800ba61ed.zip Qt-c9b18c882915b8f31c8c99bfc271a87800ba61ed.tar.gz Qt-c9b18c882915b8f31c8c99bfc271a87800ba61ed.tar.bz2 |
blitter: Move the definition out of the class declaration
Cosmetic change to remove four spaces of indention from some of the
more deeply nested methods.
Change-Id: I9f09a0ce65d74d6dab59a293bb7fb172a5e47aef
Baed-On: I67fdd0ab722b7c7c67c4da7a0a0bd86459751700
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qpaintengine_blitter.cpp | 127 |
1 files changed, 68 insertions, 59 deletions
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp index e6b1060..635b568 100644 --- a/src/gui/painting/qpaintengine_blitter.cpp +++ b/src/gui/painting/qpaintengine_blitter.cpp @@ -195,65 +195,10 @@ public: raster.reset(new QRasterPaintEngine(p->buffer())); } - inline void lock() { - if (!pmData->blittable()->isLocked()) - raster->d_func()->rasterBuffer->prepare(pmData->buffer()); - } - - inline void unlock() { - pmData->blittable()->unlock(); - } - - void fillRect(const QRectF &rect, const QColor &color) { - Q_Q(QBlitterPaintEngine); - pmData->unmarkRasterOverlay(rect); - QRectF targetRect = rect; - if (hasXForm) - targetRect = q->state()->matrix.mapRect(rect); - const QClipData *clipData = q->clip(); - if (clipData) { - if (clipData->hasRectClip) { - unlock(); - pmData->blittable()->fillRect(targetRect & clipData->clipRect, color); - } else if (clipData->hasRegionClip) { - QVector<QRect> rects = clipData->clipRegion.rects(); - for (int i = 0; i < rects.size(); ++i) { - QRect intersectRect = rects.at(i).intersected(targetRect.toRect()); - if (!intersectRect.isEmpty()) { - unlock(); - pmData->blittable()->fillRect(intersectRect, color); - } - } - } - } else { - if (targetRect.x() >= 0 && targetRect.y() >= 0 - && targetRect.width() <= raster->paintDevice()->width() - && targetRect.height() <= raster->paintDevice()->height()) { - unlock(); - pmData->blittable()->fillRect(targetRect, color); - } else { - QRectF deviceRect(0, 0, raster->paintDevice()->width(), raster->paintDevice()->height()); - unlock(); - pmData->blittable()->fillRect(deviceRect & targetRect, color); - } - } - } - - void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr) { - QRectF intersectedRect = clip.intersected(target); - if (intersectedRect.isEmpty()) - return; - QRectF source = sr; - if (intersectedRect.size() != target.size()) { - qreal deltaTop = target.top() - intersectedRect.top(); - qreal deltaLeft = target.left() - intersectedRect.left(); - qreal deltaBottom = target.bottom() - intersectedRect.bottom(); - qreal deltaRight = target.right() - intersectedRect.right(); - source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom); - } - pmData->unmarkRasterOverlay(intersectedRect); - pmData->blittable()->drawPixmap(intersectedRect, pm, source); - } + void lock(); + void unlock(); + void fillRect(const QRectF& rect, const QColor&); + void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr); void updateClip() { Q_Q(QBlitterPaintEngine); @@ -273,6 +218,70 @@ public: uint hasXForm; }; +inline void QBlitterPaintEnginePrivate::lock() +{ + if (!pmData->blittable()->isLocked()) + raster->d_func()->rasterBuffer->prepare(pmData->buffer()); +} + +inline void QBlitterPaintEnginePrivate::unlock() +{ + pmData->blittable()->unlock(); +} + +void QBlitterPaintEnginePrivate::fillRect(const QRectF &rect, const QColor &color) +{ + Q_Q(QBlitterPaintEngine); + pmData->unmarkRasterOverlay(rect); + QRectF targetRect = rect; + if (hasXForm) + targetRect = q->state()->matrix.mapRect(rect); + const QClipData *clipData = q->clip(); + if (clipData) { + if (clipData->hasRectClip) { + unlock(); + pmData->blittable()->fillRect(targetRect & clipData->clipRect, color); + } else if (clipData->hasRegionClip) { + QVector<QRect> rects = clipData->clipRegion.rects(); + for (int i = 0; i < rects.size(); ++i) { + QRect intersectRect = rects.at(i).intersected(targetRect.toRect()); + if (!intersectRect.isEmpty()) { + unlock(); + pmData->blittable()->fillRect(intersectRect, color); + } + } + } + } else { + if (targetRect.x() >= 0 && targetRect.y() >= 0 + && targetRect.width() <= raster->paintDevice()->width() + && targetRect.height() <= raster->paintDevice()->height()) { + unlock(); + pmData->blittable()->fillRect(targetRect, color); + } else { + QRectF deviceRect(0, 0, raster->paintDevice()->width(), raster->paintDevice()->height()); + unlock(); + pmData->blittable()->fillRect(deviceRect & targetRect, color); + } + } +} + +void QBlitterPaintEnginePrivate::clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr) +{ + QRectF intersectedRect = clip.intersected(target); + if (intersectedRect.isEmpty()) + return; + QRectF source = sr; + if (intersectedRect.size() != target.size()) { + qreal deltaTop = target.top() - intersectedRect.top(); + qreal deltaLeft = target.left() - intersectedRect.left(); + qreal deltaBottom = target.bottom() - intersectedRect.bottom(); + qreal deltaRight = target.right() - intersectedRect.right(); + source.adjust(-deltaLeft, -deltaTop, -deltaRight, -deltaBottom); + } + pmData->unmarkRasterOverlay(intersectedRect); + pmData->blittable()->drawPixmap(intersectedRect, pm, source); +} + QBlitterPaintEngine::QBlitterPaintEngine(QBlittablePixmapData *p) : QPaintEngineEx(*(new QBlitterPaintEnginePrivate(p))) {} |