From e38aed0bf5ea35db7dc82a943dfffcd31cca4700 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 22 Jul 2009 11:54:01 -0700 Subject: 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 --- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 25 ++++++---- .../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(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 rects = insideWindow.rects(); - const int count = rects.size(); - Q_ASSERT(count > 1); - for (int i=0; i dfbRectangles(n); + QVarLengthArray dfbPoints(n); + + for (int i=0; idfbSurface->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 rects = region.rects(); - const int count = rects.size(); - for (int i=0; i dfbRectangles(n); + QVarLengthArray dfbPoints(n); + + for (int i=0; iBlit(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; -- cgit v0.12