diff options
author | Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com> | 2011-11-28 15:00:26 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-28 11:56:42 +0100 |
commit | 3319639a6fd74d171224cb14c6e5bba0627621ba (patch) | |
tree | fba97b3abe6a84686f4983dbb9d2429ca7fe6baa /tests | |
parent | be7cc17cbfe2209c6da1ecd40f99df0149a2651d (diff) |
Allow nested read only maps of QVideoFrame.
It's useful when video frame is accessed from multiple places
like display and encoding.
Change-Id: I8af175c780783216d8b7717cdf0744ad9bc95348
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/unit/qvideoframe/tst_qvideoframe.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp index 595fbcf71..8206315a8 100644 --- a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp @@ -647,8 +647,27 @@ void tst_QVideoFrame::map() QVERIFY(frame.map(mode)); - // Mapping twice should fail, but leave it mapped (and the mode is ignored) - QVERIFY(!frame.map(mode)); + // Mapping multiple times is allowed in ReadOnly mode + if (mode == QAbstractVideoBuffer::ReadOnly) { + const uchar *bits = frame.bits(); + + QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly)); + QVERIFY(frame.isMapped()); + QCOMPARE(frame.bits(), bits); + + frame.unmap(); + //frame should still be mapped after the first nested unmap + QVERIFY(frame.isMapped()); + QCOMPARE(frame.bits(), bits); + + //re-mapping in Write or ReadWrite modes should fail + QVERIFY(!frame.map(QAbstractVideoBuffer::WriteOnly)); + QVERIFY(!frame.map(QAbstractVideoBuffer::ReadWrite)); + } else { + // Mapping twice in ReadWrite or WriteOnly modes should fail, but leave it mapped (and the mode is ignored) + QVERIFY(!frame.map(mode)); + QVERIFY(!frame.map(QAbstractVideoBuffer::ReadOnly)); + } QVERIFY(frame.bits()); QCOMPARE(frame.mappedBytes(), mappedBytes); |