| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 virtual ~EventDelegate() { }; | 67 virtual ~EventDelegate() { }; |
| 68 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Phas
e previousPhase, double previousIteration) = 0; | 68 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Phas
e previousPhase, double previousIteration) = 0; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 virtual ~TimedItem() { } | 71 virtual ~TimedItem() { } |
| 72 | 72 |
| 73 Phase phase() const { return ensureCalculated().phase; } | 73 Phase phase() const { return ensureCalculated().phase; } |
| 74 bool isCurrent() const { return ensureCalculated().isCurrent; } | 74 bool isCurrent() const { return ensureCalculated().isCurrent; } |
| 75 bool isInEffect() const { return ensureCalculated().isInEffect; } | 75 bool isInEffect() const { return ensureCalculated().isInEffect; } |
| 76 bool isInPlay() const { return ensureCalculated().isInPlay; } | 76 bool isInPlay() const { return ensureCalculated().isInPlay; } |
| 77 double timeToEffectChange() const { return ensureCalculated().timeToEffectCh
ange; } |
| 77 | 78 |
| 78 double startTime() const { return m_startTime; } | 79 double startTime() const { return m_startTime; } |
| 79 | 80 |
| 80 double currentIteration() const { return ensureCalculated().currentIteration
; } | 81 double currentIteration() const { return ensureCalculated().currentIteration
; } |
| 81 double activeDuration() const { return ensureCalculated().activeDuration; } | 82 double activeDuration() const { return ensureCalculated().activeDuration; } |
| 82 double timeFraction() const { return ensureCalculated().timeFraction; } | 83 double timeFraction() const { return ensureCalculated().timeFraction; } |
| 83 const Player* player() const { return m_player; } | 84 const Player* player() const { return m_player; } |
| 84 | 85 |
| 85 const Timing& specified() const { return m_specified; } | 86 const Timing& specified() const { return m_specified; } |
| 86 | 87 |
| 87 protected: | 88 protected: |
| 88 TimedItem(const Timing&, PassOwnPtr<EventDelegate> = nullptr); | 89 TimedItem(const Timing&, PassOwnPtr<EventDelegate> = nullptr); |
| 89 | 90 |
| 90 // When TimedItem receives a new inherited time via updateInheritedTime | 91 // When TimedItem receives a new inherited time via updateInheritedTime |
| 91 // it will (if necessary) recalculate timings and (if necessary) call | 92 // it will (if necessary) recalculate timings and (if necessary) call |
| 92 // updateChildrenAndEffects. | 93 // updateChildrenAndEffects. |
| 93 void updateInheritedTime(double inheritedTime) const; | 94 void updateInheritedTime(double inheritedTime) const; |
| 95 |
| 96 private: |
| 94 virtual void updateChildrenAndEffects(bool wasInEffect) const = 0; | 97 virtual void updateChildrenAndEffects(bool wasInEffect) const = 0; |
| 95 virtual double intrinsicIterationDuration() const { return 0; }; | 98 virtual double intrinsicIterationDuration() const { return 0; }; |
| 96 virtual void willDetach() = 0; | 99 virtual void willDetach() = 0; |
| 100 virtual double calculateTimeToEffectChange(double inheritedTime, double acti
veTime, Phase) const = 0; |
| 97 | 101 |
| 98 private: | |
| 99 void attach(Player* player) { m_player = player; }; | 102 void attach(Player* player) { m_player = player; }; |
| 100 void detach() | 103 void detach() |
| 101 { | 104 { |
| 102 ASSERT(m_player); | 105 ASSERT(m_player); |
| 103 willDetach(); | 106 willDetach(); |
| 104 m_player = 0; | 107 m_player = 0; |
| 105 }; | 108 }; |
| 106 | 109 |
| 107 // FIXME: m_parent and m_startTime are placeholders, they depend on timing g
roups. | 110 // FIXME: m_parent and m_startTime are placeholders, they depend on timing g
roups. |
| 108 TimedItem* const m_parent; | 111 TimedItem* const m_parent; |
| 109 const double m_startTime; | 112 const double m_startTime; |
| 110 Player* m_player; | 113 Player* m_player; |
| 111 Timing m_specified; | 114 Timing m_specified; |
| 112 OwnPtr<EventDelegate> m_eventDelegate; | 115 OwnPtr<EventDelegate> m_eventDelegate; |
| 113 | 116 |
| 114 // FIXME: Should be versioned by monotonic value on player. | 117 // FIXME: Should be versioned by monotonic value on player. |
| 115 mutable struct CalculatedTiming { | 118 mutable struct CalculatedTiming { |
| 116 double activeDuration; | 119 double activeDuration; |
| 117 Phase phase; | 120 Phase phase; |
| 118 double currentIteration; | 121 double currentIteration; |
| 119 double timeFraction; | 122 double timeFraction; |
| 120 bool isCurrent; | 123 bool isCurrent; |
| 121 bool isInEffect; | 124 bool isInEffect; |
| 122 bool isInPlay; | 125 bool isInPlay; |
| 126 double timeToEffectChange; |
| 123 } m_calculated; | 127 } m_calculated; |
| 124 mutable bool m_isFirstSample; | 128 mutable bool m_isFirstSample; |
| 125 | 129 |
| 126 // FIXME: Should check the version and reinherit time if inconsistent. | 130 // FIXME: Should check the version and reinherit time if inconsistent. |
| 127 const CalculatedTiming& ensureCalculated() const { return m_calculated; } | 131 const CalculatedTiming& ensureCalculated() const { return m_calculated; } |
| 128 }; | 132 }; |
| 129 | 133 |
| 130 } // namespace WebCore | 134 } // namespace WebCore |
| 131 | 135 |
| 132 #endif | 136 #endif |
| OLD | NEW |