1 | #include <QDebug>
|
---|
2 |
|
---|
3 | #include <QtGui>
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * This test calculates the roundtrip speed of copy offscreen buffer to window
|
---|
7 | * operations. Besides the time necessary for copying pixels, this also includes
|
---|
8 | * the time necessary to fill 2D rectangles in the offscreen buffer, deliver
|
---|
9 | * paint and timer messages and so on.
|
---|
10 | *
|
---|
11 | * To also get the speed of only the copy operatoins themselves, add
|
---|
12 | *
|
---|
13 | * #define QT_LOG_BLITSPEED
|
---|
14 | *
|
---|
15 | * to the beginning of qapplication_pm.cpp and qwindowsurface_raster.cpp.
|
---|
16 | *
|
---|
17 | * Hint: in order to get the most realistic numbers, let the test run until the
|
---|
18 | * average speed printed in the window title stabilizes (i.e. stops to grow).
|
---|
19 | **/
|
---|
20 |
|
---|
21 | ////////////////////////////////////////////////////////////////////////////////
|
---|
22 |
|
---|
23 | class MyWidget : public QWidget
|
---|
24 | {
|
---|
25 | public:
|
---|
26 |
|
---|
27 | MyWidget() : mUpdateTID(0), mStatTID(0), mNumPixels(0)
|
---|
28 | {
|
---|
29 | };
|
---|
30 |
|
---|
31 | ~MyWidget()
|
---|
32 | {
|
---|
33 | unsigned long long elapsed = mElapsedTimer.elapsed();
|
---|
34 | qWarning() << "Stats:";
|
---|
35 | qWarning() << " total pixels blitted :" << mNumPixels;
|
---|
36 | qWarning() << " total time, ms :" << elapsed;
|
---|
37 | qWarning() << " average roundtrip speed, px/ms :" << mNumPixels / elapsed;
|
---|
38 | }
|
---|
39 |
|
---|
40 | void startWork()
|
---|
41 | {
|
---|
42 | mElapsedTimer.start();
|
---|
43 | mUpdateTID = startTimer(0);
|
---|
44 | mStatTID = startTimer(500);
|
---|
45 | }
|
---|
46 |
|
---|
47 | void paintEvent(QPaintEvent *aE)
|
---|
48 | {
|
---|
49 | QPainter p(this);
|
---|
50 |
|
---|
51 | QRect r = aE->rect();
|
---|
52 |
|
---|
53 | #if 0
|
---|
54 | QColor c = QColor(rand() / (RAND_MAX / 255),
|
---|
55 | rand() / (RAND_MAX / 255),
|
---|
56 | rand() / (RAND_MAX / 255));
|
---|
|
---|