From 2487b9d0e183047a26dcbeb87f58b771a8e12348 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 24 Aug 2009 10:39:50 -0700 Subject: Optimize createDFBSurface When possible do a single memcpy instead of one per scan-line. Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 21 +++++++++++---------- 1 file 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; iUnlock(surface); } -- cgit v0.12