summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Bakken <anders.bakken@nokia.com>2009-06-01 16:39:37 (GMT)
committerAnders Bakken <anders.bakken@nokia.com>2009-06-01 16:39:37 (GMT)
commit0ff7b68f2e3f184d809cf6fd13ff930efa493e9f (patch)
tree22085c3e962df94e9bfd76a5f1953a149f02f2c4
parent049619000c031964cf33ef351d3df619a6815f5e (diff)
downloadQt-0ff7b68f2e3f184d809cf6fd13ff930efa493e9f.zip
Qt-0ff7b68f2e3f184d809cf6fd13ff930efa493e9f.tar.gz
Qt-0ff7b68f2e3f184d809cf6fd13ff930efa493e9f.tar.bz2
Improve readability of QDFBWindowSurface::scroll
The batch-blits buys us nothing and this is much more readable. Reviewed-by: TrustMe
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index c7cae80..330eb88 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -239,31 +239,28 @@ void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
#endif
}
-bool QDirectFBWindowSurface::scroll(const QRegion &region, int dx, int dy)
+static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy)
{
- if (!dfbSurface || !(flipFlags & DSFLIP_BLIT))
- return false;
-
- const QVector<QRect> rects = region.rects();
- const int n = rects.size();
-
- QVarLengthArray<DFBRectangle, 8> dfbRects(n);
- QVarLengthArray<DFBPoint, 8> dfbPoints(n);
+ surface->SetBlittingFlags(surface, DSBLIT_NOFX);
+ const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() };
+ surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy);
+}
- for (int i = 0; i < n; ++i) {
- const QRect r = rects.at(i);
- dfbRects[i].x = r.x();
- dfbRects[i].y = r.y();
- dfbRects[i].w = r.width();
- dfbRects[i].h = r.height();
- dfbPoints[i].x = r.x() + dx;
- dfbPoints[i].y = r.y() + dy;
- }
+bool QDirectFBWindowSurface::scroll(const QRegion &region, int dx, int dy)
+{
+ if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.isEmpty())
+ return false;
dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- dfbSurface->BatchBlit(dfbSurface, dfbSurface,
- dfbRects.data(), dfbPoints.data(), n);
- dfbSurface->ReleaseSource(dfbSurface);
+ if (region.numRects() == 1) {
+ ::scrollSurface(dfbSurface, region.boundingRect(), dx, dy);
+ } else {
+ const QVector<QRect> rects = region.rects();
+ const int n = rects.size();
+ for (int i=0; i<n; ++i) {
+ ::scrollSurface(dfbSurface, rects.at(i), dx, dy);
+ }
+ }
return true;
}