From: Peter Penz Date: Sun, 21 Sep 2008 21:24:54 +0000 (+0000) Subject: Experimental patch provided by Fredrik Höglund: Use Xrender to scale the preview... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/f2c47d12386bf9edcbdc79ea31682a60f9d119a4 Experimental patch provided by Fredrik Höglund: Use Xrender to scale the preview pixmaps in the X server. This is accelerated in HW by the latest version of the NVidia driver and by the open source ATI, Intel and Nouveau drivers when they're using the EXA acceleration architecture. EXA will be the default in the upcoming 1.6 release of the server, which is scheduled for December. CCMAIL: fredrik@kde.org svn path=/trunk/KDE/kdebase/apps/; revision=863342 --- diff --git a/src/kfilepreviewgenerator.cpp b/src/kfilepreviewgenerator.cpp index f614aae63..cbbb861ec 100644 --- a/src/kfilepreviewgenerator.cpp +++ b/src/kfilepreviewgenerator.cpp @@ -36,6 +36,12 @@ #include #include +#ifdef Q_WS_X11 +# include +# include +# include +#endif + /** * If the passed item view is an instance of QListView, expensive * layout operations are blocked in the constructor and are unblocked @@ -575,7 +581,35 @@ bool KFilePreviewGenerator::Private::applyImageFrame(QPixmap& icon) void KFilePreviewGenerator::Private::limitToSize(QPixmap& icon, const QSize& maxSize) { if ((icon.width() > maxSize.width()) || (icon.height() > maxSize.height())) { +#ifdef Q_WS_X11 + // Assume that the texture size limit is 2048x2048 + if ((icon.width() <= 2048) && (icon.height() <= 2048)) { + QSize size = icon.size(); + size.scale(maxSize, Qt::KeepAspectRatio); + + const qreal factor = size.width() / qreal(icon.width()); + + XTransform xform = {{ + { XDoubleToFixed(1 / factor), 0, 0 }, + { 0, XDoubleToFixed(1 / factor), 0 }, + { 0, 0, XDoubleToFixed(1) } + }}; + + QPixmap pixmap(size); + pixmap.fill(Qt::transparent); + + Display *dpy = QX11Info::display(); + XRenderSetPictureFilter(dpy, icon.x11PictureHandle(), FilterBilinear, 0, 0); + XRenderSetPictureTransform(dpy, icon.x11PictureHandle(), &xform); + XRenderComposite(dpy, PictOpOver, icon.x11PictureHandle(), None, pixmap.x11PictureHandle(), + 0, 0, 0, 0, 0, 0, pixmap.width(), pixmap.height()); + icon = pixmap; + } else { + icon = icon.scaled(maxSize, Qt::KeepAspectRatio, Qt::FastTransformation); + } +#else icon = icon.scaled(maxSize, Qt::KeepAspectRatio, Qt::FastTransformation); +#endif } }