author | Jean-Yves Avenard <jyavenard@mozilla.com> |
Mon, 25 May 2015 15:09:16 +1000 | |
changeset 245443 | 1773e7af4fb529562829fde76c622320ad74bdcd |
parent 245442 | a4faba53963d5d609d65247c58f3178bff1c5a39 |
child 245444 | 380baadfdd7060e1e2202d31dd406bbba65c5d37 |
push id | 60179 |
push user | jyavenard@mozilla.com |
push date | Mon, 25 May 2015 05:10:15 +0000 |
treeherder | mozilla-inbound@5c2429fd2699 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nfroyd |
bugs | 1166282 |
milestone | 41.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/media/Intervals.h +++ b/dom/media/Intervals.h @@ -6,16 +6,30 @@ #ifndef INTERVALS_H #define INTERVALS_H #include <algorithm> #include "mozilla/TypeTraits.h" #include "nsTArray.h" +// Specialization for nsTArray CopyChooser. +namespace mozilla { +namespace media { +template<class T> +class IntervalSet; +} +} + +template<class E> +struct nsTArray_CopyChooser<mozilla::media::IntervalSet<E>> +{ + typedef nsTArray_CopyWithConstructors<mozilla::media::IntervalSet<E>> Type; +}; + namespace mozilla { namespace media { /* Interval defines an interval between two points. Unlike a traditional interval [A,B] where A <= x <= B, the upper boundary B is exclusive: A <= x < B (e.g [A,B[ or [A,B) depending on where you're living) It provides basic interval arithmetic and fuzzy edges. The type T must provides a default constructor and +, -, <, <= and ==
--- a/dom/media/TimeUnits.h +++ b/dom/media/TimeUnits.h @@ -9,16 +9,28 @@ #include "Intervals.h" #include "mozilla/CheckedInt.h" #include "mozilla/FloatingPoint.h" #include "mozilla/dom/TimeRanges.h" namespace mozilla { namespace media { +class TimeIntervals; +} +} +// CopyChooser specalization for nsTArray +template<> +struct nsTArray_CopyChooser<mozilla::media::TimeIntervals> +{ + typedef nsTArray_CopyWithConstructors<mozilla::media::TimeIntervals> Type; +}; + +namespace mozilla { +namespace media { // Number of microseconds per second. 1e6. static const int64_t USECS_PER_S = 1000000; // Number of microseconds per millisecond. static const int64_t USECS_PER_MS = 1000; // Number of nanoseconds per second. 1e9.
--- a/dom/media/gtest/TestIntervalSet.cpp +++ b/dom/media/gtest/TestIntervalSet.cpp @@ -704,8 +704,17 @@ TEST(IntervalSet, FooIntervalSet) is += i; is.Add(i); is = is + i; is = i + is; EXPECT_EQ(1u, is.Length()); EXPECT_EQ(Foo<int>(), is[0].mStart); EXPECT_EQ(Foo<int>(4,5,6), is[0].mEnd); } + +TEST(IntervalSet, StaticAssert) +{ + typedef media::IntervalSet<int> IntIntervals; + media::Interval<int> i; + + static_assert(mozilla::IsSame<nsTArray_CopyChooser<IntIntervals>::Type, nsTArray_CopyWithConstructors<IntIntervals>>::value, "Must use copy constructor"); + static_assert(mozilla::IsSame<nsTArray_CopyChooser<media::TimeIntervals>::Type, nsTArray_CopyWithConstructors<media::TimeIntervals>>::value, "Must use copy constructor"); +}