<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[176863] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/176863">176863</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2014-12-05 12:51:02 -0800 (Fri, 05 Dec 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[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):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfMediaTimecpp">trunk/Source/WTF/wtf/MediaTime.cpp</a></li>
<li><a href="#trunkSourceWTFwtfMediaTimeh">trunk/Source/WTF/wtf/MediaTime.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationMediaTimeAVFoundationcpp">trunk/Source/WebCore/platform/graphics/avfoundation/MediaTimeAVFoundation.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacMediaTimeQTKitmm">trunk/Source/WebCore/platform/graphics/mac/MediaTimeQTKit.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWTFMediaTimecpp">trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp</a></li>
<li><a href="#trunkToolslldblldb_webkitpy">trunk/Tools/lldb/lldb_webkit.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Source/WTF/ChangeLog        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-12-05 Jer Noble <jer.noble@apple.com>
+
+ [WTF] MediaTime should support round-tripping from and to doubles.
+ https://bugs.webkit.org/show_bug.cgi?id=139248
+
+ Reviewed by Eric Carlson.
+
+ 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.
+
</ins><span class="cx"> 2014-12-05 peavo@outlook.com <peavo@outlook.com>
</span><span class="cx">
</span><span class="cx"> [WinCairo] WTF project is missing a GStreamer source file.
</span></span></pre></div>
<a id="trunkSourceWTFwtfMediaTimecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MediaTime.cpp (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MediaTime.cpp        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Source/WTF/wtf/MediaTime.cpp        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -83,6 +83,22 @@
</span><span class="cx"> *this = rhs;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+MediaTime MediaTime::createWithFloat(float floatTime)
+{
+ if (floatTime != floatTime)
+ return invalidTime();
+ if (std::isinf(floatTime))
+ return std::signbit(floatTime) ? negativeInfiniteTime() : positiveInfiniteTime();
+ if (floatTime > std::numeric_limits<int64_t>::max())
+ return positiveInfiniteTime();
+ if (floatTime < std::numeric_limits<int64_t>::min())
+ return negativeInfiniteTime();
+
+ MediaTime value(0, DefaultTimeScale, Valid | DoubleValue);
+ value.m_timeValueAsDouble = floatTime;
+ return value;
+}
+
</ins><span class="cx"> MediaTime MediaTime::createWithFloat(float floatTime, int32_t timeScale)
</span><span class="cx"> {
</span><span class="cx"> if (floatTime != floatTime)
</span><span class="lines">@@ -99,6 +115,22 @@
</span><span class="cx"> return MediaTime(static_cast<int64_t>(floatTime * timeScale), timeScale, Valid);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+MediaTime MediaTime::createWithDouble(double doubleTime)
+{
+ if (doubleTime != doubleTime)
+ return invalidTime();
+ if (std::isinf(doubleTime))
+ return std::signbit(doubleTime) ? negativeInfiniteTime() : positiveInfiniteTime();
+ if (doubleTime > std::numeric_limits<int64_t>::max())
+ return positiveInfiniteTime();
+ if (doubleTime < std::numeric_limits<int64_t>::min())
+ return negativeInfiniteTime();
+
+ MediaTime value(0, DefaultTimeScale, Valid | DoubleValue);
+ value.m_timeValueAsDouble = doubleTime;
+ return value;
+}
+
</ins><span class="cx"> MediaTime MediaTime::createWithDouble(double doubleTime, int32_t timeScale)
</span><span class="cx"> {
</span><span class="cx"> if (doubleTime != doubleTime)
</span><span class="lines">@@ -123,6 +155,8 @@
</span><span class="cx"> return std::numeric_limits<float>::infinity();
</span><span class="cx"> if (isNegativeInfinite())
</span><span class="cx"> return -std::numeric_limits<float>::infinity();
</span><ins>+ if (hasDoubleValue())
+ return m_timeValueAsDouble;
</ins><span class="cx"> return static_cast<float>(m_timeValue) / m_timeScale;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -134,6 +168,8 @@
</span><span class="cx"> return std::numeric_limits<double>::infinity();
</span><span class="cx"> if (isNegativeInfinite())
</span><span class="cx"> return -std::numeric_limits<double>::infinity();
</span><ins>+ if (hasDoubleValue())
+ return m_timeValueAsDouble;
</ins><span class="cx"> return static_cast<double>(m_timeValue) / m_timeScale;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -165,11 +201,20 @@
</span><span class="cx"> if (isNegativeInfinite() || rhs.isNegativeInfinite())
</span><span class="cx"> return negativeInfiniteTime();
</span><span class="cx">
</span><ins>+ if (hasDoubleValue() && rhs.hasDoubleValue())
+ return MediaTime::createWithDouble(m_timeValueAsDouble + rhs.m_timeValueAsDouble);
+
+ MediaTime a = *this;
+ MediaTime b = rhs;
+
+ if (a.hasDoubleValue())
+ a.setTimeScale(DefaultTimeScale);
+ else if (b.hasDoubleValue())
+ b.setTimeScale(DefaultTimeScale);
+
</ins><span class="cx"> int32_t commonTimeScale;
</span><del>- if (!leastCommonMultiple(this->m_timeScale, rhs.m_timeScale, commonTimeScale) || commonTimeScale > MaximumTimeScale)
</del><ins>+ if (!leastCommonMultiple(a.m_timeScale, b.m_timeScale, commonTimeScale) || commonTimeScale > MaximumTimeScale)
</ins><span class="cx"> commonTimeScale = MaximumTimeScale;
</span><del>- MediaTime a = *this;
- MediaTime b = rhs;
</del><span class="cx"> a.setTimeScale(commonTimeScale);
</span><span class="cx"> b.setTimeScale(commonTimeScale);
</span><span class="cx"> while (!safeAdd(a.m_timeValue, b.m_timeValue, a.m_timeValue)) {
</span><span class="lines">@@ -202,11 +247,20 @@
</span><span class="cx"> if (isNegativeInfinite() || rhs.isPositiveInfinite())
</span><span class="cx"> return negativeInfiniteTime();
</span><span class="cx">
</span><ins>+ if (hasDoubleValue() && rhs.hasDoubleValue())
+ return MediaTime::createWithDouble(m_timeValueAsDouble - rhs.m_timeValueAsDouble);
+
+ MediaTime a = *this;
+ MediaTime b = rhs;
+
+ if (a.hasDoubleValue())
+ a.setTimeScale(DefaultTimeScale);
+ else if (b.hasDoubleValue())
+ b.setTimeScale(DefaultTimeScale);
+
</ins><span class="cx"> int32_t commonTimeScale;
</span><span class="cx"> if (!leastCommonMultiple(this->m_timeScale, rhs.m_timeScale, commonTimeScale) || commonTimeScale > MaximumTimeScale)
</span><span class="cx"> commonTimeScale = MaximumTimeScale;
</span><del>- MediaTime a = *this;
- MediaTime b = rhs;
</del><span class="cx"> a.setTimeScale(commonTimeScale);
</span><span class="cx"> b.setTimeScale(commonTimeScale);
</span><span class="cx"> while (!safeSub(a.m_timeValue, b.m_timeValue, a.m_timeValue)) {
</span><span class="lines">@@ -234,7 +288,10 @@
</span><span class="cx"> return positiveInfiniteTime();
</span><span class="cx">
</span><span class="cx"> MediaTime negativeTime = *this;
</span><del>- negativeTime.m_timeValue = -negativeTime.m_timeValue;
</del><ins>+ if (negativeTime.hasDoubleValue())
+ negativeTime.m_timeValueAsDouble = -negativeTime.m_timeValueAsDouble;
+ else
+ negativeTime.m_timeValue = -negativeTime.m_timeValue;
</ins><span class="cx"> return negativeTime;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -263,6 +320,11 @@
</span><span class="cx">
</span><span class="cx"> MediaTime a = *this;
</span><span class="cx">
</span><ins>+ if (a.hasDoubleValue()) {
+ a.m_timeValueAsDouble *= rhs;
+ return a;
+ }
+
</ins><span class="cx"> while (!safeMultiply(a.m_timeValue, rhs, a.m_timeValue)) {
</span><span class="cx"> if (a.m_timeScale == 1)
</span><span class="cx"> return signum(a.m_timeValue) == signum(rhs) ? positiveInfiniteTime() : negativeInfiniteTime();
</span><span class="lines">@@ -338,17 +400,33 @@
</span><span class="cx"> if (rhs.isIndefinite())
</span><span class="cx"> return LessThan;
</span><span class="cx">
</span><del>- int64_t rhsWhole = rhs.m_timeValue / rhs.m_timeScale;
- int64_t lhsWhole = m_timeValue / m_timeScale;
</del><ins>+ if (hasDoubleValue() && rhs.hasDoubleValue()) {
+ if (m_timeValueAsDouble == rhs.m_timeValueAsDouble)
+ return EqualTo;
+
+ return m_timeValueAsDouble < rhs.m_timeValueAsDouble ? LessThan : GreaterThan;
+ }
+
+ MediaTime a = *this;
+ MediaTime b = rhs;
+
+ if (a.hasDoubleValue())
+ a.setTimeScale(DefaultTimeScale);
+
+ if (b.hasDoubleValue())
+ b.setTimeScale(DefaultTimeScale);
+
+ int64_t rhsWhole = b.m_timeValue / b.m_timeScale;
+ int64_t lhsWhole = a.m_timeValue / a.m_timeScale;
</ins><span class="cx"> if (lhsWhole > rhsWhole)
</span><span class="cx"> return GreaterThan;
</span><span class="cx"> if (lhsWhole < rhsWhole)
</span><span class="cx"> return LessThan;
</span><span class="cx">
</span><del>- int64_t rhsRemain = rhs.m_timeValue % rhs.m_timeScale;
- int64_t lhsRemain = m_timeValue % m_timeScale;
- int64_t lhsFactor = lhsRemain * rhs.m_timeScale;
- int64_t rhsFactor = rhsRemain * m_timeScale;
</del><ins>+ int64_t rhsRemain = b.m_timeValue % b.m_timeScale;
+ int64_t lhsRemain = a.m_timeValue % a.m_timeScale;
+ int64_t lhsFactor = lhsRemain * b.m_timeScale;
+ int64_t rhsFactor = rhsRemain * a.m_timeScale;
</ins><span class="cx">
</span><span class="cx"> if (lhsFactor == rhsFactor)
</span><span class="cx"> return EqualTo;
</span><span class="lines">@@ -387,6 +465,11 @@
</span><span class="cx">
</span><span class="cx"> void MediaTime::setTimeScale(int32_t timeScale)
</span><span class="cx"> {
</span><ins>+ if (hasDoubleValue()) {
+ *this = MediaTime::createWithDouble(m_timeValueAsDouble, timeScale);
+ return;
+ }
+
</ins><span class="cx"> if (timeScale == m_timeScale)
</span><span class="cx"> return;
</span><span class="cx"> timeScale = std::min(MaximumTimeScale, timeScale);
</span><span class="lines">@@ -415,6 +498,9 @@
</span><span class="cx"> return MediaTime::invalidTime();
</span><span class="cx"> if (rhs.isNegativeInfinite() || rhs.isPositiveInfinite())
</span><span class="cx"> return MediaTime::positiveInfiniteTime();
</span><ins>+ if (rhs.hasDoubleValue())
+ return MediaTime::createWithDouble(fabs(rhs.m_timeValueAsDouble));
+
</ins><span class="cx"> MediaTime val = rhs;
</span><span class="cx"> val.m_timeValue *= signum(rhs.m_timeScale) * signum(rhs.m_timeValue);
</span><span class="cx"> return val;
</span></span></pre></div>
<a id="trunkSourceWTFwtfMediaTimeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/MediaTime.h (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/MediaTime.h        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Source/WTF/wtf/MediaTime.h        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> PositiveInfinite = 1 << 2,
</span><span class="cx"> NegativeInfinite = 1 << 3,
</span><span class="cx"> Indefinite = 1 << 4,
</span><ins>+ DoubleValue = 1 << 5,
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> MediaTime();
</span><span class="lines">@@ -56,8 +57,10 @@
</span><span class="cx"> MediaTime(const MediaTime& rhs);
</span><span class="cx"> ~MediaTime();
</span><span class="cx">
</span><del>- static MediaTime createWithFloat(float floatTime, int32_t timeScale = DefaultTimeScale);
- static MediaTime createWithDouble(double doubleTime, int32_t timeScale = DefaultTimeScale);
</del><ins>+ static MediaTime createWithFloat(float floatTime);
+ static MediaTime createWithFloat(float floatTime, int32_t timeScale);
+ static MediaTime createWithDouble(double doubleTime);
+ static MediaTime createWithDouble(double doubleTime, int32_t timeScale);
</ins><span class="cx">
</span><span class="cx"> float toFloat() const;
</span><span class="cx"> double toDouble() const;
</span><span class="lines">@@ -92,6 +95,7 @@
</span><span class="cx"> bool isPositiveInfinite() const { return m_timeFlags & PositiveInfinite; }
</span><span class="cx"> bool isNegativeInfinite() const { return m_timeFlags & NegativeInfinite; }
</span><span class="cx"> bool isIndefinite() const { return m_timeFlags & Indefinite; }
</span><ins>+ bool hasDoubleValue() const { return m_timeFlags & DoubleValue; }
</ins><span class="cx">
</span><span class="cx"> static const MediaTime& zeroTime();
</span><span class="cx"> static const MediaTime& invalidTime();
</span><span class="lines">@@ -111,13 +115,17 @@
</span><span class="cx"> MediaTime(int) = delete;
</span><span class="cx">
</span><span class="cx"> friend WTF_EXPORT_PRIVATE MediaTime abs(const MediaTime& rhs);
</span><del>-private:
</del><ins>+
</ins><span class="cx"> static const int32_t DefaultTimeScale = 10000000;
</span><span class="cx"> static const int32_t MaximumTimeScale;
</span><span class="cx">
</span><ins>+private:
</ins><span class="cx"> void setTimeScale(int32_t);
</span><span class="cx">
</span><del>- int64_t m_timeValue;
</del><ins>+ union {
+ int64_t m_timeValue;
+ double m_timeValueAsDouble;
+ };
</ins><span class="cx"> int32_t m_timeScale;
</span><span class="cx"> uint32_t m_timeFlags;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Source/WebCore/ChangeLog        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-12-05 Jer Noble <jer.noble@apple.com>
+
+ [WTF] MediaTime should support round-tripping from and to doubles.
+ https://bugs.webkit.org/show_bug.cgi?id=139248
+
+ Reviewed by Eric Carlson.
+
+ 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):
+
</ins><span class="cx"> 2014-12-05 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Add a private browsing mode to MiniBrowser
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationMediaTimeAVFoundationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaTimeAVFoundation.cpp (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaTimeAVFoundation.cpp        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaTimeAVFoundation.cpp        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -28,6 +28,16 @@
</span><span class="cx">
</span><span class="cx"> #if USE(AVFOUNDATION)
</span><span class="cx">
</span><ins>+#if PLATFORM(WIN)
+#include <CoreMedia/CoreMedia.h>
+#include "CoreMediaSoftLinking.h"
+#else
+#include "SoftLinking.h"
+SOFT_LINK_FRAMEWORK(CoreMedia)
+SOFT_LINK(CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
+SOFT_LINK(CoreMedia, CMTimeMake, CMTime, (int64_t value, int32_t timescale), (value, timescale))
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> static bool CMTimeHasFlags(const CMTime& cmTime, uint32_t flags)
</span><span class="lines">@@ -54,8 +64,13 @@
</span><span class="cx">
</span><span class="cx"> CMTime toCMTime(const MediaTime& mediaTime)
</span><span class="cx"> {
</span><del>- CMTime time = {mediaTime.timeValue(), mediaTime.timeScale(), 0, 0};
</del><ins>+ CMTime time;
</ins><span class="cx">
</span><ins>+ if (mediaTime.hasDoubleValue())
+ time = CMTimeMakeWithSeconds(mediaTime.toDouble(), mediaTime.timeScale());
+ else
+ time = CMTimeMake(mediaTime.timeValue(), mediaTime.timeScale());
+
</ins><span class="cx"> if (mediaTime.isValid())
</span><span class="cx"> time.flags |= kCMTimeFlags_Valid;
</span><span class="cx"> if (mediaTime.hasBeenRounded())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacMediaTimeQTKitmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/MediaTimeQTKit.mm (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/MediaTimeQTKit.mm        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Source/WebCore/platform/graphics/mac/MediaTimeQTKit.mm        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -31,11 +31,12 @@
</span><span class="cx"> #import "SoftLinking.h"
</span><span class="cx"> #import <QTKit/QTTime.h>
</span><span class="cx">
</span><del>-SOFT_LINK_FRAMEWORK(QTKit);
-SOFT_LINK_CONSTANT(QTKit, QTIndefiniteTime, QTTime);
-SOFT_LINK_CONSTANT(QTKit, QTZeroTime, QTTime);
-SOFT_LINK(QTKit, QTTimeCompare, NSComparisonResult, (QTTime time, QTTime otherTime), (time, otherTime));
-SOFT_LINK(QTKit, QTMakeTime, QTTime, (long long timeValue, long timeScale), (timeValue, timeScale));
</del><ins>+SOFT_LINK_FRAMEWORK(QTKit)
+SOFT_LINK_CONSTANT(QTKit, QTIndefiniteTime, QTTime)
+SOFT_LINK_CONSTANT(QTKit, QTZeroTime, QTTime)
+SOFT_LINK(QTKit, QTTimeCompare, NSComparisonResult, (QTTime time, QTTime otherTime), (time, otherTime))
+SOFT_LINK(QTKit, QTMakeTime, QTTime, (long long timeValue, long timeScale), (timeValue, timeScale))
+SOFT_LINK(QTKit, QTMakeTimeWithTimeInterval, QTTime, (NSTimeInterval timeInterval), (timeInterval))
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -55,6 +56,8 @@
</span><span class="cx">
</span><span class="cx"> #pragma clang diagnostic push
</span><span class="cx"> #pragma clang diagnostic ignored "-Wdeprecated-declarations"
</span><ins>+ if (mediaTime.hasDoubleValue())
+ return QTMakeTimeWithTimeInterval(mediaTime.toDouble());
</ins><span class="cx"> return QTMakeTime(mediaTime.timeValue(), mediaTime.timeScale());
</span><span class="cx"> #pragma clang diagnostic pop
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Tools/ChangeLog        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2014-12-05 Jer Noble <jer.noble@apple.com>
+
+ [WTF] MediaTime should support round-tripping from and to doubles.
+ https://bugs.webkit.org/show_bug.cgi?id=139248
+
+ Reviewed by Eric Carlson.
+
+ 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):
+
</ins><span class="cx"> 2014-12-05 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Add a private browsing mode to MiniBrowser
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWTFMediaTimecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -44,6 +44,8 @@
</span><span class="cx"> out << "+infinite";
</span><span class="cx"> else if (val.isNegativeInfinite())
</span><span class="cx"> out << "-infinite";
</span><ins>+ else if (val.hasDoubleValue())
+ out << "double: " << val.toDouble();
</ins><span class="cx"> else
</span><span class="cx"> out << "value: " << val.timeValue() << ", scale: " << val.timeScale();
</span><span class="cx"> return out << " }";
</span><span class="lines">@@ -177,6 +179,20 @@
</span><span class="cx"> EXPECT_EQ(MediaTime::createWithDouble(-INFINITY), MediaTime::negativeInfiniteTime());
</span><span class="cx"> EXPECT_EQ(MediaTime::createWithDouble(NAN), MediaTime::invalidTime());
</span><span class="cx">
</span><ins>+ // Floating Point Round Trip
+ EXPECT_EQ(10.0123456789f, MediaTime::createWithFloat(10.0123456789f).toFloat());
+ EXPECT_EQ(10.0123456789, MediaTime::createWithDouble(10.0123456789).toDouble());
+
+ // Floating Point Math
+ EXPECT_EQ(1.5 + 3.3, (MediaTime::createWithDouble(1.5) + MediaTime::createWithDouble(3.3)).toDouble());
+ EXPECT_EQ(1.5 - 3.3, (MediaTime::createWithDouble(1.5) - MediaTime::createWithDouble(3.3)).toDouble());
+ EXPECT_EQ(-3.3, (-MediaTime::createWithDouble(3.3)).toDouble());
+ EXPECT_EQ(3.3 * 2, (MediaTime::createWithDouble(3.3) * 2).toDouble());
+
+ // Floating Point and non-Floating Point math
+ EXPECT_EQ(2.0, (MediaTime::createWithDouble(1.5) + MediaTime(1, 2)).toDouble());
+ EXPECT_EQ(1.0, (MediaTime::createWithDouble(1.5) - MediaTime(1, 2)).toDouble());
+
</ins><span class="cx"> // Overflow Behavior
</span><span class="cx"> EXPECT_EQ(MediaTime::createWithFloat(pow(2.0f, 64.0f)), MediaTime::positiveInfiniteTime());
</span><span class="cx"> EXPECT_EQ(MediaTime::createWithFloat(-pow(2.0f, 64.0f)), MediaTime::negativeInfiniteTime());
</span></span></pre></div>
<a id="trunkToolslldblldb_webkitpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/lldb/lldb_webkit.py (176862 => 176863)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/lldb/lldb_webkit.py        2014-12-05 20:48:20 UTC (rev 176862)
+++ trunk/Tools/lldb/lldb_webkit.py        2014-12-05 20:51:02 UTC (rev 176863)
</span><span class="lines">@@ -83,6 +83,8 @@
</span><span class="cx"> return "{ -Infinity }"
</span><span class="cx"> if provider.isIndefinite():
</span><span class="cx"> return "{ Indefinite }"
</span><ins>+ if provider.hasDoubleValue():
+ return "{ %f }" % (provider.timeValueAsDouble())
</ins><span class="cx"> return "{ %d/%d, %f }" % (provider.timeValue(), provider.timeScale(), float(provider.timeValue()) / provider.timeScale())
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -407,6 +409,10 @@
</span><span class="cx"> def timeValue(self):
</span><span class="cx"> return self.valobj.GetChildMemberWithName('m_timeValue').GetValueAsSigned(0)
</span><span class="cx">
</span><ins>+ def timeValueAsDouble(self):
+ error = lldb.SBError()
+ return self.valobj.GetChildMemberWithName('m_timeValueAsDouble').GetData().GetDouble(error, 0)
+
</ins><span class="cx"> def timeScale(self):
</span><span class="cx"> return self.valobj.GetChildMemberWithName('m_timeScale').GetValueAsSigned(0)
</span><span class="cx">
</span><span class="lines">@@ -421,3 +427,6 @@
</span><span class="cx">
</span><span class="cx"> def isIndefinite(self):
</span><span class="cx"> return self.valobj.GetChildMemberWithName('m_timeFlags').GetValueAsSigned(0) & (1 << 4)
</span><ins>+
+ def hasDoubleValue(self):
+ return self.valobj.GetChildMemberWithName('m_timeFlags').GetValueAsSigned(0) & (1 << 5)
</ins></span></pre>
</div>
</div>
</body>
</html>