diff options
author | Anders Bakken <anders.bakken@nokia.com> | 2009-07-22 18:54:01 (GMT) |
---|---|---|
committer | Anders Bakken <anders.bakken@nokia.com> | 2009-07-22 18:55:14 (GMT) |
commit | e38aed0bf5ea35db7dc82a943dfffcd31cca4700 (patch) | |
tree | cea1fe5140303a53510d12f2dc2ef29d0db70b3e /src/plugins | |
parent | 18728d2ddd725199017a36cb290c30d6e8c9e647 (diff) | |
download | Qt-e38aed0bf5ea35db7dc82a943dfffcd31cca4700.zip Qt-e38aed0bf5ea35db7dc82a943dfffcd31cca4700.tar.gz Qt-e38aed0bf5ea35db7dc82a943dfffcd31cca4700.tar.bz2 |
Use BatchBlit in flush/exposeRegion
Minor optimization.
Also make sure cursor is drawn in flush even if we're not in Offscreen
mode.
Reviewed-by: TrustMe
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 25 | ||||
-rw-r--r-- | src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 57 |
2 files changed, 47 insertions, 35 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index ae2e38b..1efebd9 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1204,7 +1204,8 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) ? static_cast<QDirectFBWindowSurface*>(s) : 0; if (dfbWindowSurface) { IDirectFBSurface *surface = dfbWindowSurface->directFBSurface(); - if (d_ptr->directFBFlags & BoundingRectFlip || insideWindow.numRects() == 1) { + const int n = insideWindow.numRects(); + if (n == 1 || d_ptr->directFBFlags & BoundingRectFlip) { const QRect source = (insideWindow.boundingRect().intersected(windowGeometry)).translated(-windowGeometry.topLeft()); const DFBRectangle rect = { source.x(), source.y(), source.width(), source.height() @@ -1214,17 +1215,21 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing) windowGeometry.y() + source.y()); } else { const QVector<QRect> rects = insideWindow.rects(); - const int count = rects.size(); - Q_ASSERT(count > 1); - for (int i=0; i<count; ++i) { + QVarLengthArray<DFBRectangle, 16> dfbRectangles(n); + QVarLengthArray<DFBPoint, 16> dfbPoints(n); + + for (int i=0; i<n; ++i) { const QRect source = (rects.at(i).intersected(windowGeometry)).translated(-windowGeometry.topLeft()); - const DFBRectangle rect = { - source.x(), source.y(), source.width(), source.height() - }; - d_ptr->dfbSurface->Blit(d_ptr->dfbSurface, surface, &rect, - windowGeometry.x() + source.x(), - windowGeometry.y() + source.y()); + DFBRectangle &rect = dfbRectangles[i]; + rect.x = source.x(); + rect.y = source.y(); + rect.w = source.width(); + rect.h = source.height(); + dfbPoints[i].x = (windowGeometry.x() + source.x()); + dfbPoints[i].y = (windowGeometry.y() + source.y()); } + d_ptr->dfbSurface->BatchBlit(d_ptr->dfbSurface, surface, dfbRectangles.constData(), + dfbPoints.constData(), n); } } } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index ed4b2d9..a1009ac 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -356,12 +356,13 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, #endif } + const QRect windowGeometry = QDirectFBWindowSurface::geometry(); + IDirectFBSurface *primarySurface = screen->dfbSurface(); if (mode == Offscreen) { - IDirectFBSurface *primarySurface = screen->dfbSurface(); primarySurface->SetBlittingFlags(primarySurface, DSBLIT_NOFX); - const QRect windowGeometry = QDirectFBWindowSurface::geometry(); const QRect windowRect(0, 0, windowGeometry.width(), windowGeometry.height()); - if (boundingRectFlip || region.numRects() == 1) { + const int n = region.numRects(); + if (n == 1 || boundingRectFlip ) { const QRect regionBoundingRect = region.boundingRect().translated(offset); const QRect source = windowRect & regionBoundingRect; const DFBRectangle rect = { @@ -372,40 +373,46 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion ®ion, windowGeometry.y() + source.y()); } else { const QVector<QRect> rects = region.rects(); - const int count = rects.size(); - for (int i=0; i<count; ++i) { + QVarLengthArray<DFBRectangle, 16> dfbRectangles(n); + QVarLengthArray<DFBPoint, 16> dfbPoints(n); + + for (int i=0; i<n; ++i) { const QRect &r = rects.at(i).translated(offset); const QRect source = windowRect & r; - const DFBRectangle rect = { - source.x(), source.y(), source.width(), source.height() - }; - primarySurface->Blit(primarySurface, dfbSurface, &rect, - windowGeometry.x() + source.x(), - windowGeometry.y() + source.y()); + DFBRectangle &rect = dfbRectangles[i]; + rect.x = source.x(); + rect.y = source.y(); + rect.w = source.width(); + rect.h = source.height(); + dfbPoints[i].x = (windowGeometry.x() + source.x()); + dfbPoints[i].y = (windowGeometry.y() + source.y()); } + primarySurface->BatchBlit(primarySurface, dfbSurface, dfbRectangles.constData(), + dfbPoints.constData(), n); } - if (QScreenCursor *cursor = QScreenCursor::instance()) { - const QRect cursorRectangle = cursor->boundingRect(); - if (cursor->isVisible() && !cursor->isAccelerated() - && region.intersects(cursorRectangle.translated(-(offset + windowGeometry.topLeft())))) { - const QImage image = cursor->image(); - - IDirectFBSurface *surface = screen->createDFBSurface(image, QDirectFBScreen::DontTrackSurface); - primarySurface->SetBlittingFlags(primarySurface, DSBLIT_BLEND_ALPHACHANNEL); - primarySurface->Blit(primarySurface, surface, 0, cursorRectangle.x(), cursorRectangle.y()); - surface->Release(surface); + } + + if (QScreenCursor *cursor = QScreenCursor::instance()) { + const QRect cursorRectangle = cursor->boundingRect(); + if (cursor->isVisible() && !cursor->isAccelerated() + && region.intersects(cursorRectangle.translated(-(offset + windowGeometry.topLeft())))) { + const QImage image = cursor->image(); + + IDirectFBSurface *surface = screen->createDFBSurface(image, QDirectFBScreen::DontTrackSurface); + primarySurface->SetBlittingFlags(primarySurface, DSBLIT_BLEND_ALPHACHANNEL); + primarySurface->Blit(primarySurface, surface, 0, cursorRectangle.x(), cursorRectangle.y()); + surface->Release(surface); #if (Q_DIRECTFB_VERSION >= 0x010000) - primarySurface->ReleaseSource(primarySurface); + primarySurface->ReleaseSource(primarySurface); #endif - } } - + } + if (mode == Offscreen) { screen->flipSurface(primarySurface, flipFlags, region, offset + windowGeometry.topLeft()); } else { screen->flipSurface(dfbSurface, flipFlags, region, offset); } - #ifdef QT_DIRECTFB_TIMING enum { Secs = 3 }; ++frames; |