[WTF] MediaTime should support round-tripping from and to doubles.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Dec 2014 20:51:02 +0000 (20:51 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Dec 2014 20:51:02 +0000 (20:51 +0000)
commit5450de99d415ce158a3fb029ba4978cab59c2211
tree8ec66fff958543cef1b5f1eef9fb76c1b9a5aa02
parent5d0a3efe018ddab888b913012dbf7f075c4e7a4d
[WTF] MediaTime should support round-tripping from and to doubles.
https://bugs.webkit.org/show_bug.cgi?id=139248

Reviewed by Eric Carlson.

Source/WebCore:

Check whether the MediaTime's underlying data is floating point before converting
to a CMTime or QTTime.

* platform/graphics/avfoundation/MediaTimeAVFoundation.cpp:
(WebCore::toCMTime):
* platform/graphics/mac/MediaTimeQTKit.mm:
(WebCore::toQTTime):

Source/WTF:

MediaTimes should be able to return precisely the same double value as was used
when the MediaTime was created, so long as that MediaTime was not modified in a
non-destructive way. This will allow API which accepts floating-point values to
return the exact same value when asked, but still be able to store that value
as a MediaTime.

* wtf/MediaTime.cpp:
(WTF::MediaTime::createWithFloat): Added; store the floating-point value in a union.
(WTF::MediaTime::createWithDouble): Ditto.
(WTF::MediaTime::toFloat): If the value is a double, just return it.
(WTF::MediaTime::toDouble): Ditto.
(WTF::MediaTime::operator+): Special case when one or both sides are doubles.
(WTF::MediaTime::operator-): Ditto.
(WTF::MediaTime::operator*): Ditto.
(WTF::MediaTime::compare): Ditto.
(WTF::abs): Ditto.
(WTF::MediaTime::setTimeScale): Convert the MediaTime from a double.

Tools:

Add API tests for new features of MediaTime. Update the LLDB python provider to correctly display
the MediaTimes after this change.

* TestWebKitAPI/Tests/WTF/MediaTime.cpp:
(WTF::operator<<):
(TestWebKitAPI::TEST):
* lldb/lldb_webkit.py:
(WTFMediaTime_SummaryProvider):
(WTFMediaTimeProvider.timeValueAsDouble):
(WTFMediaTimeProvider.isIndefinite):
(WTFMediaTimeProvider):
(WTFMediaTimeProvider.hasDoubleValue):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176863 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/MediaTime.cpp
Source/WTF/wtf/MediaTime.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/MediaTimeAVFoundation.cpp
Source/WebCore/platform/graphics/mac/MediaTimeQTKit.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp
Tools/lldb/lldb_webkit.py