From f2c47d12386bf9edcbdc79ea31682a60f9d119a4 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sun, 21 Sep 2008 21:24:54 +0000 Subject: [PATCH] =?utf8?q?Experimental=20patch=20provided=20by=20Fredrik?= =?utf8?q?=20H=C3=B6glund:=20Use=20Xrender=20to=20scale=20the=20preview=20?= =?utf8?q?pixmaps=20in=20the=20X=20server.=20This=20is=20accelerated=20in?= =?utf8?q?=20HW=20by=20the=20latest=20version=20of=20the=20NVidia=20driver?= =?utf8?q?=20and=20by=20the=20open=20source=20ATI,=20Intel=20and=20Nouveau?= =?utf8?q?=20drivers=20when=20they're=20using=20the=20EXA=20acceleration?= =?utf8?q?=20architecture.=20EXA=20will=20be=20the=20default=20in=20the=20?= =?utf8?q?upcoming=201.6=20release=20of=20the=20server,=20which=20is=20sch?= =?utf8?q?eduled=20for=20December.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit CCMAIL: fredrik@kde.org svn path=/trunk/KDE/kdebase/apps/; revision=863342 --- src/kfilepreviewgenerator.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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 } } -- 2.47.3