OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_FUNCTION_H_ | 5 #ifndef MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_FUNCTION_H_ |
6 #define MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_FUNCTION_H_ | 6 #define MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_FUNCTION_H_ |
7 | 7 |
| 8 #include "mojo/public/cpp/bindings/type_converter.h" |
8 #include "mojo/public/cpp/environment/logging.h" | 9 #include "mojo/public/cpp/environment/logging.h" |
9 #include "mojo/services/media/common/cpp/timeline_rate.h" | 10 #include "mojo/services/media/common/cpp/timeline_rate.h" |
| 11 #include "mojo/services/media/common/interfaces/timelines.mojom.h" |
10 | 12 |
11 namespace mojo { | 13 namespace mojo { |
12 namespace media { | 14 namespace media { |
13 | 15 |
14 // TODO(dalesat): Consider always allowing inexact results. | 16 // TODO(dalesat): Consider always allowing inexact results. |
15 | 17 |
16 // A linear function from int64_t to int64_t with non-negative slope that | 18 // A linear function from int64_t to int64_t with non-negative slope that |
17 // translates reference timeline values into subject timeline values (the | 19 // translates reference timeline values into subject timeline values (the |
18 // 'subject' being the timeline that's represented by the function). The | 20 // 'subject' being the timeline that's represented by the function). The |
19 // representation is in point-slope form. The point is represented as two | 21 // representation is in point-slope form. The point is represented as two |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 123 } |
122 | 124 |
123 // Composes two timeline functions B->C and A->B producing A->C. DCHECKs on | 125 // Composes two timeline functions B->C and A->B producing A->C. DCHECKs on |
124 // loss of precision. | 126 // loss of precision. |
125 inline TimelineFunction operator*(const TimelineFunction& bc, | 127 inline TimelineFunction operator*(const TimelineFunction& bc, |
126 const TimelineFunction& ab) { | 128 const TimelineFunction& ab) { |
127 return TimelineFunction::Compose(bc, ab); | 129 return TimelineFunction::Compose(bc, ab); |
128 } | 130 } |
129 | 131 |
130 } // namespace media | 132 } // namespace media |
| 133 |
| 134 template <> |
| 135 struct TypeConverter<TimelineTransformPtr, media::TimelineFunction> { |
| 136 static TimelineTransformPtr Convert( |
| 137 const media::TimelineFunction& input); |
| 138 }; |
| 139 |
| 140 template <> |
| 141 struct TypeConverter<media::TimelineFunction, TimelineTransformPtr> { |
| 142 static media::TimelineFunction Convert( |
| 143 const TimelineTransformPtr& input); |
| 144 }; |
| 145 |
131 } // namespace mojo | 146 } // namespace mojo |
132 | 147 |
133 #endif // MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_FUNCTION_H_ | 148 #endif // MOJO_SERVICES_MEDIA_COMMON_CPP_TIMELINE_FUNCTION_H_ |
OLD | NEW |