diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch) | |
tree | 5ac38a06f3dde268dc7927dc155896926aaf7012 /kdeui/tests/kgradienttest.cpp | |
download | tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdeui/tests/kgradienttest.cpp')
-rw-r--r-- | kdeui/tests/kgradienttest.cpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/kdeui/tests/kgradienttest.cpp b/kdeui/tests/kgradienttest.cpp new file mode 100644 index 000000000..9fad0bb46 --- /dev/null +++ b/kdeui/tests/kgradienttest.cpp @@ -0,0 +1,108 @@ +#include "kgradienttest.h" +#include <kapplication.h> +#include <kpixmapeffect.h> +#include <qpainter.h> +#include <qdatetime.h> +#include <qstring.h> + +int cols = 3, rows = 3; // how many + +void KGradientWidget::paintEvent(QPaintEvent */*ev*/) +{ + QTime time; + int it, ft; + QString say; + + QColor ca = Qt::black, cb = Qt::blue; + + int x = 0, y = 0; + + pix.resize(width()/cols, height()/rows); + QPainter p(this); + p.setPen(Qt::white); + + // draw once, so that the benchmarking be fair :-) + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::VerticalGradient); + + // vertical + time.start(); + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::VerticalGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Vertical"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5 + (x++)*width()/cols, 15+y*height()/rows, say); // augment x + + // horizontal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::HorizontalGradient); + ft = time.elapsed() ; + say.setNum( ft - it); say += " ms, Horizontal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // elliptic + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::EllipticGradient); + ft = time.elapsed() ; + say.setNum( ft - it); say += " ms, Elliptic"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + y++; // next row + x = 0; // reset the columns + + // diagonal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::DiagonalGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Diagonal"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // crossdiagonal + it = time.elapsed(); + KPixmapEffect::gradient(pix,ca, cb, KPixmapEffect::CrossDiagonalGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, CrossDiagonal"; + p.drawPixmap(width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + y++; // next row + x = 0; // reset the columns + + // pyramidal + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::PyramidGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Pyramid"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/cols, 15+y*height()/rows, say); + + // pattern + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::RectangleGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, Rectangle"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/rows, 15+y*height()/rows, say); + + // crosspipe + it = time.elapsed(); + KPixmapEffect::gradient(pix, ca, cb, KPixmapEffect::PipeCrossGradient); + ft = time.elapsed(); + say.setNum( ft - it); say += " ms, PipeCross"; + p.drawPixmap(x*width()/cols, y*height()/rows, pix); + p.drawText(5+(x++)*width()/rows, 15+y*height()/rows, say); +} + +int main(int argc, char **argv) +{ + KApplication *app = new KApplication(argc, argv, "KGradientTest"); + KGradientWidget w; + w.resize(250 * cols, 250 * rows); + app->setMainWidget(&w); + w.show(); + return(app->exec()); +} + |