summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAnders Bakken <anders.bakken@nokia.com>2009-08-24 17:39:50 (GMT)
committerAnders Bakken <anders.bakken@nokia.com>2009-08-24 17:43:23 (GMT)
commit2487b9d0e183047a26dcbeb87f58b771a8e12348 (patch)
tree813411b9a25a7d3b33e82184b59df54576bad188 /src/plugins
parentc03f50f7ef086bbc9f9f05b45eaea808953f6d11 (diff)
downloadQt-2487b9d0e183047a26dcbeb87f58b771a8e12348.zip
Qt-2487b9d0e183047a26dcbeb87f58b771a8e12348.tar.gz
Qt-2487b9d0e183047a26dcbeb87f58b771a8e12348.tar.bz2
Optimize createDFBSurface
When possible do a single memcpy instead of one per scan-line. Reviewed-by: Donald Carr <donald.carr@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index f7b3e08..bb614a2 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -188,17 +188,18 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &image, QImage:
return 0;
}
if (doMemCopy) {
- int bpl;
- uchar *mem = QDirectFBScreen::lockSurface(surface, DSLF_WRITE, &bpl);
+ int bplDFB;
+ uchar *mem = QDirectFBScreen::lockSurface(surface, DSLF_WRITE, &bplDFB);
if (mem) {
- const int h = image.height();
- const int w = image.bytesPerLine();
- // ### Could probably do a single memcpy here since I know
- // ### image.bytesPerLine() == bpl == (image.width() *
- // ### image.depth() / 8)
- for (int i = 0; i < h; ++i) {
- memcpy(mem, image.scanLine(i), w);
- mem += bpl;
+ const int height = image.height();
+ const int bplQt = image.bytesPerLine();
+ if (bplQt == bplDFB && bplQt == (image.width() * image.depth() / 8)) {
+ memcpy(mem, image.bits(), image.numBytes());
+ } else {
+ for (int i=0; i<height; ++i) {
+ memcpy(mem, image.scanLine(i), bplQt);
+ mem += bplDFB;
+ }
}
surface->Unlock(surface);
}