Ignore:
Timestamp:
May 3, 2011, 4:49:08 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

vendor: Imported qt-everywhere-opensource-src-4.7.2 from Nokia (excluding doc/html and doc/qch dirs generated from doc/src, and imports and templates dirs which are emtpy).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/vendor/nokia/qt/current/tools/qttracereplay/main.cpp

    r649 r844  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    5050    Q_OBJECT
    5151public:
    52     ReplayWidget(const QString &filename);
     52    ReplayWidget(const QString &filename);
    5353
    5454    void paintEvent(QPaintEvent *event);
     
    6767
    6868    QList<uint> visibleUpdates;
    69     QList<uint> iterationTimes;
     69
     70    QVector<uint> iterationTimes;
    7071    QString filename;
     72
     73
     74
     75
     76
     77
     78
     79
    7180};
    7281
    7382void ReplayWidget::updateRect()
    7483{
    75     if (!visibleUpdates.isEmpty())
     84    if (frame >= 0 && !updates.isEmpty())
     85        update(updates.at(frame));
     86    else if (!visibleUpdates.isEmpty())
    7687        update(updates.at(visibleUpdates.at(currentFrame)));
    7788}
    7889
     90
     91
     92
    7993void ReplayWidget::paintEvent(QPaintEvent *)
    8094{
    8195    QPainter p(this);
    8296
     97
     98
    8399//    p.setClipRegion(frames.at(currentFrame).updateRegion);
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
    84158
    85159    buffer.draw(&p, visibleUpdates.at(currentFrame));
     
    89163        currentFrame = 0;
    90164        ++currentIteration;
     165
     166
     167
     168
     169
    91170
    92171        if (currentIteration == 3)
     
    129208        }
    130209    }
    131 
    132     QTimer::singleShot(0, this, SLOT(updateRect()));
    133 }
    134 
    135 void ReplayWidget::resizeEvent(QResizeEvent *event)
     210}
     211
     212void ReplayWidget::resizeEvent(QResizeEvent *)
    136213{
    137214    visibleUpdates.clear();
    138215
    139216    QRect bounds = rect();
    140     for (int i = 0; i < updates.size(); ++i) {
     217
     218    int first = qMax(0, from);
     219    int last = qMin(unsigned(to), unsigned(updates.size()));
     220    for (int i = first; i < last; ++i) {
    141221        if (updates.at(i).intersects(bounds))
    142222            visibleUpdates << i;
    143223    }
    144224
    145     if (visibleUpdates.size() != updates.size())
    146         printf("Warning: skipped %d frames due to limited resolution\n", updates.size() - visibleUpdates.size());
    147 
    148 }
    149 
    150 ReplayWidget::ReplayWidget(const QString &filename_)
     225    int range = last - first;
     226
     227    if (visibleUpdates.size() != range)
     228        printf("Warning: skipped %d frames due to limited resolution\n", range - visibleUpdates.size());
     229
     230}
     231
     232ReplayWidget::ReplayWidget(const QString &filename_, int from_, int to_, bool single_, int frame_)
    151233    : currentFrame(0)
    152234    , currentIteration(0)
    153235    , filename(filename_)
     236
     237
     238
     239
     240
    154241{
    155242    setWindowTitle(filename);
     
    166253    uint size;
    167254    in.readBytes(data, size);
    168     bool isTraceFile = size == 7 && qstrncmp(data, "qttrace", 7) == 0;
    169     delete [] data;
     255    bool isTraceFile = size >= 7 && qstrncmp(data, "qttrace", 7) == 0;
     256
     257    uint version = 0;
     258    if (size == 9 && qstrncmp(data, "qttraceV2", 9) == 0) {
     259        in.setFloatingPointPrecision(QDataStream::SinglePrecision);
     260        in >> version;
     261    }
     262
    170263    if (!isTraceFile) {
    171264        printf("File '%s' is not a trace file\n", qPrintable(filename_));
     
    174267
    175268    in >> buffer >> updates;
    176     printf("Read paint buffer with %d frames\n", buffer.numFrames());
     269    printf("Read paint buffer , buffer.numFrames());
    177270
    178271    resize(buffer.boundingRect().size().toSize());
     
    190283    if (argc <= 1 || qstrcmp(argv[1], "-h") == 0 || qstrcmp(argv[1], "--help") == 0) {
    191284        printf("Replays a tracefile generated with '-graphicssystem trace'\n");
    192         printf("Usage:\n  > %s [traceFile]\n", argv[0]);
     285        printf("Usage:\n  > %s [OPTIONS] [traceFile]\n", argv[0]);
     286        printf("OPTIONS\n"
     287               "   --range=from-to to specify a frame range.\n"
     288               "   --singlerun to do only one run (without statistics)\n"
     289               "   --instrumentframe=frame to instrument a single frame\n");
    193290        return 1;
    194291    }
    195292
    196     QFile file(argv[1]);
     293    QFile file(a);
    197294    if (!file.exists()) {
    198         printf("%s does not exist\n", argv[1]);
     295        printf("%s does not exist\n", );
    199296        return 1;
    200297    }
    201298
    202     ReplayWidget *widget = new ReplayWidget(argv[1]);
     299    bool single = false;
     300
     301    int frame = -1;
     302
     303    int from = 0;
     304    int to = -1;
     305    for (int i = 1; i < app.arguments().size() - 1; ++i) {
     306        QString arg = app.arguments().at(i);
     307        if (arg.startsWith(QLatin1String("--range="))) {
     308            QString rest = arg.mid(8);
     309            QStringList components = rest.split(QLatin1Char('-'));
     310
     311            bool ok1 = false;
     312            bool ok2 = false;
     313            int fromCandidate = 0;
     314            int toCandidate = 0;
     315            if (components.size() == 2) {
     316                fromCandidate = components.first().toInt(&ok1);
     317                toCandidate = components.last().toInt(&ok2);
     318            }
     319
     320            if (ok1 && ok2) {
     321                from = fromCandidate;
     322                to = toCandidate;
     323            } else {
     324                printf("ERROR: malformed syntax in argument %s\n", qPrintable(arg));
     325            }
     326        } else if (arg == QLatin1String("--singlerun")) {
     327            single = true;
     328        } else if (arg.startsWith(QLatin1String("--instrumentframe="))) {
     329            QString rest = arg.mid(18);
     330            bool ok = false;
     331            int frameCandidate = rest.toInt(&ok);
     332            if (ok) {
     333                frame = frameCandidate;
     334            } else {
     335                printf("ERROR: malformed syntax in argument %s\n", qPrintable(arg));
     336            }
     337        } else {
     338            printf("Unrecognized argument: %s\n", qPrintable(arg));
     339            return 1;
     340        }
     341    }
     342
     343    ReplayWidget *widget = new ReplayWidget(app.arguments().last(), from, to, single, frame);
    203344
    204345    if (!widget->updates.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.