| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qmovie.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count |
|---|---|---|
| 1 | - | |
| 2 | - | |
| 3 | - | |
| 4 | - | |
| 5 | - | |
| 6 | - | |
| 7 | - | |
| 8 | - | |
| 9 | class QFrameInfo | - |
| 10 | { | - |
| 11 | public: | - |
| 12 | QPixmap pixmap; | - |
| 13 | int delay; | - |
| 14 | bool endMark; | - |
| 15 | inline QFrameInfo(bool endMark) | - |
| 16 | : pixmap(QPixmap()), delay(-1), endMark(endMark) | - |
| 17 | { } | - |
| 18 | - | |
| 19 | inline QFrameInfo() | - |
| 20 | : pixmap(QPixmap()), delay(-1), endMark(false) | - |
| 21 | { } | - |
| 22 | - | |
| 23 | inline QFrameInfo(const QPixmap &pixmap, int delay) | - |
| 24 | : pixmap(pixmap), delay(delay), endMark(false) | - |
| 25 | { } | - |
| 26 | - | |
| 27 | inline bool isValid() | - |
| 28 | { | - |
| 29 | return endMark || !(pixmap.isNull() && (delay == -1)); | - |
| 30 | } | - |
| 31 | - | |
| 32 | inline bool isEndMarker() | - |
| 33 | { return endMark; } | - |
| 34 | - | |
| 35 | static inline QFrameInfo endMarker() | - |
| 36 | { return QFrameInfo(true); } | - |
| 37 | }; | - |
| 38 | - | |
| 39 | class QMoviePrivate : public QObjectPrivate | - |
| 40 | { | - |
| 41 | inline QMovie* q_func() { return static_cast<QMovie *>(q_ptr); } inline const QMovie* q_func() const { return static_cast<const QMovie *>(q_ptr); } friend class QMovie; | - |
| 42 | - | |
| 43 | public: | - |
| 44 | QMoviePrivate(QMovie *qq); | - |
| 45 | bool isDone(); | - |
| 46 | bool next(); | - |
| 47 | int speedAdjustedDelay(int delay) const; | - |
| 48 | bool isValid() const; | - |
| 49 | bool jumpToFrame(int frameNumber); | - |
| 50 | int frameCount() const; | - |
| 51 | bool jumpToNextFrame(); | - |
| 52 | QFrameInfo infoForFrame(int frameNumber); | - |
| 53 | void reset(); | - |
| 54 | - | |
| 55 | inline void enterState(QMovie::MovieState newState) { | - |
| 56 | movieState = newState; | - |
| 57 | q_func()->stateChanged(newState); | - |
| 58 | } | - |
| 59 | - | |
| 60 | - | |
| 61 | void _q_loadNextFrame(); | - |
| 62 | void _q_loadNextFrame(bool starting); | - |
| 63 | - | |
| 64 | QImageReader *reader; | - |
| 65 | int speed; | - |
| 66 | QMovie::MovieState movieState; | - |
| 67 | QRect frameRect; | - |
| 68 | QPixmap currentPixmap; | - |
| 69 | int currentFrameNumber; | - |
| 70 | int nextFrameNumber; | - |
| 71 | int greatestFrameNumber; | - |
| 72 | int nextDelay; | - |
| 73 | int playCounter; | - |
| 74 | qint64 initialDevicePos; | - |
| 75 | QMovie::CacheMode cacheMode; | - |
| 76 | bool haveReadAll; | - |
| 77 | bool isFirstIteration; | - |
| 78 | QMap<int, QFrameInfo> frameMap; | - |
| 79 | QString absoluteFilePath; | - |
| 80 | - | |
| 81 | QTimer nextImageTimer; | - |
| 82 | }; | - |
| 83 | - | |
| 84 | - | |
| 85 | - | |
| 86 | QMoviePrivate::QMoviePrivate(QMovie *qq) | - |
| 87 | : reader(0), speed(100), movieState(QMovie::NotRunning), | - |
| 88 | currentFrameNumber(-1), nextFrameNumber(0), greatestFrameNumber(-1), | - |
| 89 | nextDelay(0), playCounter(-1), | - |
| 90 | cacheMode(QMovie::CacheNone), haveReadAll(false), isFirstIteration(true) | - |
| 91 | { | - |
| 92 | q_ptr = qq; | - |
| 93 | nextImageTimer.setSingleShot(true); | - |
| 94 | } | - |
| 95 | - | |
| 96 | - | |
| 97 | - | |
| 98 | void QMoviePrivate::reset() | - |
| 99 | { | - |
| 100 | nextImageTimer.stop(); | - |
| 101 | if (reader->device()) | - |
| 102 | initialDevicePos = reader->device()->pos(); | - |
| 103 | currentFrameNumber = -1; | - |
| 104 | nextFrameNumber = 0; | - |
| 105 | greatestFrameNumber = -1; | - |
| 106 | nextDelay = 0; | - |
| 107 | playCounter = -1; | - |
| 108 | haveReadAll = false; | - |
| 109 | isFirstIteration = true; | - |
| 110 | frameMap.clear(); | - |
| 111 | } | - |
| 112 | - | |
| 113 | - | |
| 114 | - | |
| 115 | bool QMoviePrivate::isDone() | - |
| 116 | { | - |
| 117 | return (playCounter == 0); | - |
| 118 | } | - |
| 119 | int QMoviePrivate::speedAdjustedDelay(int delay) const | - |
| 120 | { | - |
| 121 | return int( (qint64(delay) * qint64(100) ) / qint64(speed) ); | - |
| 122 | } | - |
| 123 | QFrameInfo QMoviePrivate::infoForFrame(int frameNumber) | - |
| 124 | { | - |
| 125 | if (frameNumber < 0) | - |
| 126 | return QFrameInfo(); | - |
| 127 | - | |
| 128 | if (haveReadAll && (frameNumber > greatestFrameNumber)) { | - |
| 129 | if (frameNumber == greatestFrameNumber+1) | - |
| 130 | return QFrameInfo::endMarker(); | - |
| 131 | return QFrameInfo(); | - |
| 132 | } | - |
| 133 | - | |
| 134 | if (cacheMode == QMovie::CacheNone) { | - |
| 135 | if (frameNumber != currentFrameNumber+1) { | - |
| 136 | - | |
| 137 | if (!reader->jumpToImage(frameNumber)) { | - |
| 138 | if (frameNumber == 0) { | - |
| 139 | - | |
| 140 | - | |
| 141 | if (reader->device()->isSequential()) | - |
| 142 | return QFrameInfo(); | - |
| 143 | QString fileName = reader->fileName(); | - |
| 144 | QByteArray format = reader->format(); | - |
| 145 | QIODevice *device = reader->device(); | - |
| 146 | QColor bgColor = reader->backgroundColor(); | - |
| 147 | QSize scaledSize = reader->scaledSize(); | - |
| 148 | delete reader; | - |
| 149 | if (fileName.isEmpty()) | - |
| 150 | reader = new QImageReader(device, format); | - |
| 151 | else | - |
| 152 | reader = new QImageReader(absoluteFilePath, format); | - |
| 153 | (void)reader->canRead(); | - |
| 154 | reader->device()->seek(initialDevicePos); | - |
| 155 | reader->setBackgroundColor(bgColor); | - |
| 156 | reader->setScaledSize(scaledSize); | - |
| 157 | } else { | - |
| 158 | return QFrameInfo(); | - |
| 159 | } | - |
| 160 | } | - |
| 161 | } | - |
| 162 | if (reader->canRead()) { | - |
| 163 | - | |
| 164 | QImage anImage = reader->read(); | - |
| 165 | if (anImage.isNull()) { | - |
| 166 | - | |
| 167 | return QFrameInfo(); | - |
| 168 | } | - |
| 169 | if (frameNumber > greatestFrameNumber) | - |
| 170 | greatestFrameNumber = frameNumber; | - |
| 171 | QPixmap aPixmap = QPixmap::fromImage(anImage); | - |
| 172 | int aDelay = reader->nextImageDelay(); | - |
| 173 | return QFrameInfo(aPixmap, aDelay); | - |
| 174 | } else if (frameNumber != 0) { | - |
| 175 | - | |
| 176 | haveReadAll = true; | - |
| 177 | return QFrameInfo::endMarker(); | - |
| 178 | } else { | - |
| 179 | - | |
| 180 | haveReadAll = true; | - |
| 181 | return QFrameInfo(); | - |
| 182 | } | - |
| 183 | } | - |
| 184 | - | |
| 185 | - | |
| 186 | if (frameNumber > greatestFrameNumber) { | - |
| 187 | - | |
| 188 | for (int i = greatestFrameNumber + 1; i <= frameNumber; ++i) { | - |
| 189 | if (reader->canRead()) { | - |
| 190 | - | |
| 191 | QImage anImage = reader->read(); | - |
| 192 | if (anImage.isNull()) { | - |
| 193 | - | |
| 194 | return QFrameInfo(); | - |
| 195 | } | - |
| 196 | greatestFrameNumber = i; | - |
| 197 | QPixmap aPixmap = QPixmap::fromImage(anImage); | - |
| 198 | int aDelay = reader->nextImageDelay(); | - |
| 199 | QFrameInfo info(aPixmap, aDelay); | - |
| 200 | - | |
| 201 | frameMap.insert(i, info); | - |
| 202 | if (i == frameNumber) { | - |
| 203 | return info; | - |
| 204 | } | - |
| 205 | } else { | - |
| 206 | - | |
| 207 | haveReadAll = true; | - |
| 208 | return QFrameInfo::endMarker(); | - |
| 209 | } | - |
| 210 | } | - |
| 211 | } | - |
| 212 | - | |
| 213 | return frameMap.value(frameNumber); | - |
| 214 | } | - |
| 215 | bool QMoviePrivate::next() | - |
| 216 | { | - |
| 217 | QTime time; | - |
| 218 | time.start(); | - |
| 219 | QFrameInfo info = infoForFrame(nextFrameNumber); | - |
| 220 | if (!info.isValid()) | - |
| 221 | return false; | - |
| 222 | if (info.isEndMarker()) { | - |
| 223 | - | |
| 224 | if (isFirstIteration) { | - |
| 225 | if (nextFrameNumber == 0) { | - |
| 226 | - | |
| 227 | return false; | - |
| 228 | } | - |
| 229 | - | |
| 230 | playCounter = reader->loopCount(); | - |
| 231 | isFirstIteration = false; | - |
| 232 | } | - |
| 233 | - | |
| 234 | if (playCounter != 0) { | - |
| 235 | if (playCounter != -1) | - |
| 236 | playCounter--; | - |
| 237 | nextFrameNumber = 0; | - |
| 238 | return next(); | - |
| 239 | } | - |
| 240 | - | |
| 241 | return false; | - |
| 242 | } | - |
| 243 | - | |
| 244 | currentFrameNumber = nextFrameNumber++; | - |
| 245 | QSize scaledSize = reader->scaledSize(); | - |
| 246 | if (scaledSize.isValid() && (scaledSize != info.pixmap.size())) | - |
| 247 | currentPixmap = QPixmap::fromImage( info.pixmap.toImage().scaled(scaledSize) ); | - |
| 248 | else | - |
| 249 | currentPixmap = info.pixmap; | - |
| 250 | nextDelay = speedAdjustedDelay(info.delay); | - |
| 251 | - | |
| 252 | int processingTime = time.elapsed(); | - |
| 253 | if (processingTime > nextDelay) | - |
| 254 | nextDelay = 0; | - |
| 255 | else | - |
| 256 | nextDelay = nextDelay - processingTime; | - |
| 257 | return true; | - |
| 258 | } | - |
| 259 | - | |
| 260 | - | |
| 261 | - | |
| 262 | void QMoviePrivate::_q_loadNextFrame() | - |
| 263 | { | - |
| 264 | _q_loadNextFrame(false); | - |
| 265 | } | - |
| 266 | - | |
| 267 | void QMoviePrivate::_q_loadNextFrame(bool starting) | - |
| 268 | { | - |
| 269 | QMovie * const q = q_func(); | - |
| 270 | if (next()) { | - |
| 271 | if (starting && movieState == QMovie::NotRunning) { | - |
| 272 | enterState(QMovie::Running); | - |
| 273 | q->started(); | - |
| 274 | } | - |
| 275 | - | |
| 276 | if (frameRect.size() != currentPixmap.rect().size()) { | - |
| 277 | frameRect = currentPixmap.rect(); | - |
| 278 | q->resized(frameRect.size()); | - |
| 279 | } | - |
| 280 | - | |
| 281 | q->updated(frameRect); | - |
| 282 | q->frameChanged(currentFrameNumber); | - |
| 283 | - | |
| 284 | if (movieState == QMovie::Running) | - |
| 285 | nextImageTimer.start(nextDelay); | - |
| 286 | } else { | - |
| 287 | - | |
| 288 | if (!isDone()) { | - |
| 289 | q->error(reader->error()); | - |
| 290 | } | - |
| 291 | - | |
| 292 | - | |
| 293 | if (movieState != QMovie::Paused) { | - |
| 294 | nextFrameNumber = 0; | - |
| 295 | isFirstIteration = true; | - |
| 296 | playCounter = -1; | - |
| 297 | enterState(QMovie::NotRunning); | - |
| 298 | q->finished(); | - |
| 299 | } | - |
| 300 | } | - |
| 301 | } | - |
| 302 | - | |
| 303 | - | |
| 304 | - | |
| 305 | - | |
| 306 | bool QMoviePrivate::isValid() const | - |
| 307 | { | - |
| 308 | return (greatestFrameNumber >= 0) | - |
| 309 | || reader->canRead(); | - |
| 310 | } | - |
| 311 | - | |
| 312 | - | |
| 313 | - | |
| 314 | - | |
| 315 | bool QMoviePrivate::jumpToFrame(int frameNumber) | - |
| 316 | { | - |
| 317 | if (frameNumber < 0) | - |
| 318 | return false; | - |
| 319 | if (currentFrameNumber == frameNumber) | - |
| 320 | return true; | - |
| 321 | nextFrameNumber = frameNumber; | - |
| 322 | if (movieState == QMovie::Running) | - |
| 323 | nextImageTimer.stop(); | - |
| 324 | _q_loadNextFrame(); | - |
| 325 | return (nextFrameNumber == currentFrameNumber+1); | - |
| 326 | } | - |
| 327 | - | |
| 328 | - | |
| 329 | - | |
| 330 | - | |
| 331 | int QMoviePrivate::frameCount() const | - |
| 332 | { | - |
| 333 | int result; | - |
| 334 | if ((result = reader->imageCount()) != 0) | - |
| 335 | return result; | - |
| 336 | if (haveReadAll) | - |
| 337 | return greatestFrameNumber+1; | - |
| 338 | return 0; | - |
| 339 | } | - |
| 340 | - | |
| 341 | - | |
| 342 | - | |
| 343 | - | |
| 344 | bool QMoviePrivate::jumpToNextFrame() | - |
| 345 | { | - |
| 346 | return jumpToFrame(currentFrameNumber+1); | - |
| 347 | } | - |
| 348 | - | |
| 349 | - | |
| 350 | - | |
| 351 | - | |
| 352 | - | |
| 353 | - | |
| 354 | - | |
| 355 | QMovie::QMovie(QObject *parent) | - |
| 356 | : QObject(*new QMoviePrivate(this), parent) | - |
| 357 | { | - |
| 358 | QMoviePrivate * const d = d_func(); | - |
| 359 | d->reader = new QImageReader; | - |
| 360 | connect(&d->nextImageTimer, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "574""580"), this, qFlagLocation("1""_q_loadNextFrame()" "\0" __FILE__ ":" "574""580")); | - |
| 361 | } | - |
| 362 | QMovie::QMovie(QIODevice *device, const QByteArray &format, QObject *parent) | - |
| 363 | : QObject(*new QMoviePrivate(this), parent) | - |
| 364 | { | - |
| 365 | QMoviePrivate * const d = d_func(); | - |
| 366 | d->reader = new QImageReader(device, format); | - |
| 367 | d->initialDevicePos = device->pos(); | - |
| 368 | connect(&d->nextImageTimer, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "591""597"), this, qFlagLocation("1""_q_loadNextFrame()" "\0" __FILE__ ":" "591""597")); | - |
| 369 | } | - |
| 370 | QMovie::QMovie(const QString &fileName, const QByteArray &format, QObject *parent) | - |
| 371 | : QObject(*new QMoviePrivate(this), parent) | - |
| 372 | { | - |
| 373 | QMoviePrivate * const d = d_func(); | - |
| 374 | d->absoluteFilePath = QDir(fileName).absolutePath(); | - |
| 375 | d->reader = new QImageReader(fileName, format); | - |
| 376 | if (d->reader->device()) | - |
| 377 | d->initialDevicePos = d->reader->device()->pos(); | - |
| 378 | connect(&d->nextImageTimer, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "610""616"), this, qFlagLocation("1""_q_loadNextFrame()" "\0" __FILE__ ":" "610""616")); | - |
| 379 | } | - |
| 380 | - | |
| 381 | - | |
| 382 | - | |
| 383 | - | |
| 384 | QMovie::~QMovie() | - |
| 385 | { | - |
| 386 | QMoviePrivate * const d = d_func(); | - |
| 387 | delete d->reader; | - |
| 388 | } | - |
| 389 | - | |
| 390 | - | |
| 391 | - | |
| 392 | - | |
| 393 | - | |
| 394 | - | |
| 395 | - | |
| 396 | void QMovie::setDevice(QIODevice *device) | - |
| 397 | { | - |
| 398 | QMoviePrivate * const d = d_func(); | - |
| 399 | d->reader->setDevice(device); | - |
| 400 | d->reset(); | - |
| 401 | } | - |
| 402 | - | |
| 403 | - | |
| 404 | - | |
| 405 | - | |
| 406 | - | |
| 407 | - | |
| 408 | - | |
| 409 | QIODevice *QMovie::device() const | - |
| 410 | { | - |
| 411 | const QMoviePrivate * const d = d_func(); | - |
| 412 | return d->reader->device(); | - |
| 413 | } | - |
| 414 | - | |
| 415 | - | |
| 416 | - | |
| 417 | - | |
| 418 | - | |
| 419 | - | |
| 420 | - | |
| 421 | void QMovie::setFileName(const QString &fileName) | - |
| 422 | { | - |
| 423 | QMoviePrivate * const d = d_func(); | - |
| 424 | d->absoluteFilePath = QDir(fileName).absolutePath(); | - |
| 425 | d->reader->setFileName(fileName); | - |
| 426 | d->reset(); | - |
| 427 | } | - |
| 428 | QString QMovie::fileName() const | - |
| 429 | { | - |
| 430 | const QMoviePrivate * const d = d_func(); | - |
| 431 | return d->reader->fileName(); | - |
| 432 | } | - |
| 433 | void QMovie::setFormat(const QByteArray &format) | - |
| 434 | { | - |
| 435 | QMoviePrivate * const d = d_func(); | - |
| 436 | d->reader->setFormat(format); | - |
| 437 | } | - |
| 438 | - | |
| 439 | - | |
| 440 | - | |
| 441 | - | |
| 442 | - | |
| 443 | - | |
| 444 | - | |
| 445 | QByteArray QMovie::format() const | - |
| 446 | { | - |
| 447 | const QMoviePrivate * const d = d_func(); | - |
| 448 | return d->reader->format(); | - |
| 449 | } | - |
| 450 | - | |
| 451 | - | |
| 452 | - | |
| 453 | - | |
| 454 | - | |
| 455 | - | |
| 456 | - | |
| 457 | void QMovie::setBackgroundColor(const QColor &color) | - |
| 458 | { | - |
| 459 | QMoviePrivate * const d = d_func(); | - |
| 460 | d->reader->setBackgroundColor(color); | - |
| 461 | } | - |
| 462 | - | |
| 463 | - | |
| 464 | - | |
| 465 | - | |
| 466 | - | |
| 467 | - | |
| 468 | - | |
| 469 | QColor QMovie::backgroundColor() const | - |
| 470 | { | - |
| 471 | const QMoviePrivate * const d = d_func(); | - |
| 472 | return d->reader->backgroundColor(); | - |
| 473 | } | - |
| 474 | - | |
| 475 | - | |
| 476 | - | |
| 477 | - | |
| 478 | - | |
| 479 | - | |
| 480 | QMovie::MovieState QMovie::state() const | - |
| 481 | { | - |
| 482 | const QMoviePrivate * const d = d_func(); | - |
| 483 | return d->movieState; | - |
| 484 | } | - |
| 485 | - | |
| 486 | - | |
| 487 | - | |
| 488 | - | |
| 489 | - | |
| 490 | - | |
| 491 | - | |
| 492 | QRect QMovie::frameRect() const | - |
| 493 | { | - |
| 494 | const QMoviePrivate * const d = d_func(); | - |
| 495 | return d->frameRect; | - |
| 496 | } | - |
| 497 | - | |
| 498 | - | |
| 499 | - | |
| 500 | - | |
| 501 | - | |
| 502 | - | |
| 503 | QPixmap QMovie::currentPixmap() const | - |
| 504 | { | - |
| 505 | const QMoviePrivate * const d = d_func(); | - |
| 506 | return d->currentPixmap; | - |
| 507 | } | - |
| 508 | - | |
| 509 | - | |
| 510 | - | |
| 511 | - | |
| 512 | - | |
| 513 | - | |
| 514 | QImage QMovie::currentImage() const | - |
| 515 | { | - |
| 516 | const QMoviePrivate * const d = d_func(); | - |
| 517 | return d->currentPixmap.toImage(); | - |
| 518 | } | - |
| 519 | - | |
| 520 | - | |
| 521 | - | |
| 522 | - | |
| 523 | - | |
| 524 | bool QMovie::isValid() const | - |
| 525 | { | - |
| 526 | const QMoviePrivate * const d = d_func(); | - |
| 527 | return d->isValid(); | - |
| 528 | } | - |
| 529 | - | |
| 530 | - | |
| 531 | - | |
| 532 | - | |
| 533 | - | |
| 534 | - | |
| 535 | - | |
| 536 | int QMovie::frameCount() const | - |
| 537 | { | - |
| 538 | const QMoviePrivate * const d = d_func(); | - |
| 539 | return d->frameCount(); | - |
| 540 | } | - |
| 541 | - | |
| 542 | - | |
| 543 | - | |
| 544 | - | |
| 545 | - | |
| 546 | int QMovie::nextFrameDelay() const | - |
| 547 | { | - |
| 548 | const QMoviePrivate * const d = d_func(); | - |
| 549 | return d->nextDelay; | - |
| 550 | } | - |
| 551 | - | |
| 552 | - | |
| 553 | - | |
| 554 | - | |
| 555 | - | |
| 556 | int QMovie::currentFrameNumber() const | - |
| 557 | { | - |
| 558 | const QMoviePrivate * const d = d_func(); | - |
| 559 | return d->currentFrameNumber; | - |
| 560 | } | - |
| 561 | - | |
| 562 | - | |
| 563 | - | |
| 564 | - | |
| 565 | bool QMovie::jumpToNextFrame() | - |
| 566 | { | - |
| 567 | QMoviePrivate * const d = d_func(); | - |
| 568 | return d->jumpToNextFrame(); | - |
| 569 | } | - |
| 570 | - | |
| 571 | - | |
| 572 | - | |
| 573 | - | |
| 574 | - | |
| 575 | bool QMovie::jumpToFrame(int frameNumber) | - |
| 576 | { | - |
| 577 | QMoviePrivate * const d = d_func(); | - |
| 578 | return d->jumpToFrame(frameNumber); | - |
| 579 | } | - |
| 580 | int QMovie::loopCount() const | - |
| 581 | { | - |
| 582 | const QMoviePrivate * const d = d_func(); | - |
| 583 | return d->reader->loopCount(); | - |
| 584 | } | - |
| 585 | void QMovie::setPaused(bool paused) | - |
| 586 | { | - |
| 587 | QMoviePrivate * const d = d_func(); | - |
| 588 | if (paused) { | - |
| 589 | if (d->movieState == NotRunning) | - |
| 590 | return; | - |
| 591 | d->enterState(Paused); | - |
| 592 | d->nextImageTimer.stop(); | - |
| 593 | } else { | - |
| 594 | if (d->movieState == Running) | - |
| 595 | return; | - |
| 596 | d->enterState(Running); | - |
| 597 | d->nextImageTimer.start(nextFrameDelay()); | - |
| 598 | } | - |
| 599 | } | - |
| 600 | void QMovie::setSpeed(int percentSpeed) | - |
| 601 | { | - |
| 602 | QMoviePrivate * const d = d_func(); | - |
| 603 | d->speed = percentSpeed; | - |
| 604 | } | - |
| 605 | - | |
| 606 | int QMovie::speed() const | - |
| 607 | { | - |
| 608 | const QMoviePrivate * const d = d_func(); | - |
| 609 | return d->speed; | - |
| 610 | } | - |
| 611 | void QMovie::start() | - |
| 612 | { | - |
| 613 | QMoviePrivate * const d = d_func(); | - |
| 614 | if (d->movieState == NotRunning) { | - |
| 615 | d->_q_loadNextFrame(true); | - |
| 616 | } else if (d->movieState == Paused) { | - |
| 617 | setPaused(false); | - |
| 618 | } | - |
| 619 | } | - |
| 620 | void QMovie::stop() | - |
| 621 | { | - |
| 622 | QMoviePrivate * const d = d_func(); | - |
| 623 | if (d->movieState == NotRunning) | - |
| 624 | return; | - |
| 625 | d->enterState(NotRunning); | - |
| 626 | d->nextImageTimer.stop(); | - |
| 627 | d->nextFrameNumber = 0; | - |
| 628 | } | - |
| 629 | QSize QMovie::scaledSize() | - |
| 630 | { | - |
| 631 | QMoviePrivate * const d = d_func(); | - |
| 632 | return d->reader->scaledSize(); | - |
| 633 | } | - |
| 634 | void QMovie::setScaledSize(const QSize &size) | - |
| 635 | { | - |
| 636 | QMoviePrivate * const d = d_func(); | - |
| 637 | d->reader->setScaledSize(size); | - |
| 638 | } | - |
| 639 | QList<QByteArray> QMovie::supportedFormats() | - |
| 640 | { | - |
| 641 | QList<QByteArray> list = QImageReader::supportedImageFormats(); | - |
| 642 | - | |
| 643 | QMutableListIterator<QByteArray> it(list);QBuffer buffer; | - |
| 644 | buffer.open(QIODevice::ReadOnly); | - |
| 645 | - | |
| 646 | while (it.hasNext())const auto doesntSupportAnimation = | - |
| 647 | [&buffer](const QByteArray &format) { | - |
| 648 | return never executed: return !QImageReader(&buffer, format).supportsAnimation();never executed: !QImageReaderreader(&buffer, itformat).supportsAnimation();return !QImageReader(&buffer, format).supportsAnimation();never executed: return !QImageReader(&buffer, format).supportsAnimation(); | 0 |
| 649 | }; | - |
| 650 | - | |
| 651 | list.next()); | - |
| if (!readererase(std::remove_if(list.supportsAnimation()) | ||
| itbegin(), list.remove(); | ||
| }end(), doesntSupportAnimation), list.end()); | ||
| 652 | return never executed: list;return list;never executed: return list; | 0 |
| 653 | } | - |
| 654 | QMovie::CacheMode QMovie::cacheMode() const | - |
| 655 | { | - |
| 656 | const QMoviePrivate * const d = d_func(); | - |
| 657 | return d->cacheMode; | - |
| 658 | } | - |
| 659 | - | |
| 660 | void QMovie::setCacheMode(CacheMode cacheMode) | - |
| 661 | { | - |
| 662 | QMoviePrivate * const d = d_func(); | - |
| 663 | d->cacheMode = cacheMode; | - |
| 664 | } | - |
| 665 | - | |
| 666 | - | |
| 667 | - | |
| Switch to Source code | Preprocessed file |