QMovie: move-enable QFrameInfo

All users of the QPixmap ctor can pass rvalues, so take by rvalue-ref
and move into place. Adapt callers to actually pass rvalues.

Change-Id: Iacff2ed893ceaa1665b270ce466ffdc21ba800f1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2019-07-11 23:38:47 +02:00
parent 8abef02777
commit a7de860cfd

View File

@ -207,8 +207,8 @@ public:
: pixmap(QPixmap()), delay(QMOVIE_INVALID_DELAY), endMark(false) : pixmap(QPixmap()), delay(QMOVIE_INVALID_DELAY), endMark(false)
{ } { }
inline QFrameInfo(const QPixmap &pixmap, int delay) inline QFrameInfo(QPixmap &&pixmap, int delay)
: pixmap(pixmap), delay(delay), endMark(false) : pixmap(std::move(pixmap)), delay(delay), endMark(false)
{ } { }
inline bool isValid() inline bool isValid()
@ -222,6 +222,7 @@ public:
static inline QFrameInfo endMarker() static inline QFrameInfo endMarker()
{ return QFrameInfo(true); } { return QFrameInfo(true); }
}; };
Q_DECLARE_TYPEINFO(QFrameInfo, Q_MOVABLE_TYPE);
class QMoviePrivate : public QObjectPrivate class QMoviePrivate : public QObjectPrivate
{ {
@ -380,9 +381,7 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber)
} }
if (frameNumber > greatestFrameNumber) if (frameNumber > greatestFrameNumber)
greatestFrameNumber = frameNumber; greatestFrameNumber = frameNumber;
QPixmap aPixmap = QPixmap::fromImage(std::move(anImage)); return QFrameInfo(QPixmap::fromImage(std::move(anImage)), reader->nextImageDelay());
int aDelay = reader->nextImageDelay();
return QFrameInfo(aPixmap, aDelay);
} else if (frameNumber != 0) { } else if (frameNumber != 0) {
// We've read all frames now. Return an end marker // We've read all frames now. Return an end marker
haveReadAll = true; haveReadAll = true;
@ -406,9 +405,7 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber)
return QFrameInfo(); // Invalid return QFrameInfo(); // Invalid
} }
greatestFrameNumber = i; greatestFrameNumber = i;
QPixmap aPixmap = QPixmap::fromImage(std::move(anImage)); QFrameInfo info(QPixmap::fromImage(std::move(anImage)), reader->nextImageDelay());
int aDelay = reader->nextImageDelay();
QFrameInfo info(aPixmap, aDelay);
// Cache it! // Cache it!
frameMap.insert(i, info); frameMap.insert(i, info);
if (i == frameNumber) { if (i == frameNumber) {