Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: Source/core/animation/Player.h

Issue 48523004: Have Player take the DocumentTimeline object by reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/animation/DocumentTimeline.cpp ('k') | Source/core/animation/Player.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 #include "wtf/RefPtr.h" 35 #include "wtf/RefPtr.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 class DocumentTimeline; 39 class DocumentTimeline;
40 40
41 class Player FINAL : public RefCounted<Player> { 41 class Player FINAL : public RefCounted<Player> {
42 42
43 public: 43 public:
44 ~Player(); 44 ~Player();
45 static PassRefPtr<Player> create(DocumentTimeline*, TimedItem*); 45 static PassRefPtr<Player> create(DocumentTimeline&, TimedItem*);
46 46
47 // Returns whether this player is still current or in effect. 47 // Returns whether this player is still current or in effect.
48 // timeToEffectChange returns: 48 // timeToEffectChange returns:
49 // infinity - if this player is no longer in effect 49 // infinity - if this player is no longer in effect
50 // 0 - if this player requires an update on the next frame 50 // 0 - if this player requires an update on the next frame
51 // n - if this player requires an update after 'n' units of time 51 // n - if this player requires an update after 'n' units of time
52 bool update(double* timeToEffectChange = 0); 52 bool update(double* timeToEffectChange = 0);
53 53
54 void cancel(); 54 void cancel();
55 double currentTime() const; 55 double currentTime() const;
56 void setCurrentTime(double); 56 void setCurrentTime(double);
57 bool paused() const { return !m_isPausedForTesting && pausedInternal(); } 57 bool paused() const { return !m_isPausedForTesting && pausedInternal(); }
58 void setPaused(bool); 58 void setPaused(bool);
59 double playbackRate() const { return m_playbackRate; } 59 double playbackRate() const { return m_playbackRate; }
60 void setPlaybackRate(double); 60 void setPlaybackRate(double);
61 double startTime() const { return m_startTime; } 61 double startTime() const { return m_startTime; }
62 double timeDrift() const; 62 double timeDrift() const;
63 DocumentTimeline* timeline() { return m_timeline; } 63 DocumentTimeline& timeline() { return m_timeline; }
64 TimedItem* source() { return m_content.get(); } 64 TimedItem* source() { return m_content.get(); }
65 65
66 // Pausing via this method is not reflected in the value returned by 66 // Pausing via this method is not reflected in the value returned by
67 // paused() and must never overlap with pausing via setPaused(). 67 // paused() and must never overlap with pausing via setPaused().
68 void pauseForTesting(); 68 void pauseForTesting();
69 // Reflects all pausing, including via pauseForTesting(). 69 // Reflects all pausing, including via pauseForTesting().
70 bool pausedInternal() const { return !isNull(m_pauseStartTime); } 70 bool pausedInternal() const { return !isNull(m_pauseStartTime); }
71 71
72 private: 72 private:
73 Player(DocumentTimeline*, TimedItem*); 73 Player(DocumentTimeline&, TimedItem*);
74 static double effectiveTime(double time) { return isNull(time) ? 0 : time; } 74 static double effectiveTime(double time) { return isNull(time) ? 0 : time; }
75 inline double pausedTimeDrift() const; 75 inline double pausedTimeDrift() const;
76 inline double currentTimeBeforeDrift() const; 76 inline double currentTimeBeforeDrift() const;
77 77
78 void setPausedImpl(bool); 78 void setPausedImpl(bool);
79 79
80 double m_pauseStartTime; 80 double m_pauseStartTime;
81 double m_playbackRate; 81 double m_playbackRate;
82 double m_timeDrift; 82 double m_timeDrift;
83 const double m_startTime; 83 const double m_startTime;
84 84
85 RefPtr<TimedItem> m_content; 85 RefPtr<TimedItem> m_content;
86 DocumentTimeline* const m_timeline; 86 DocumentTimeline& m_timeline;
87 bool m_isPausedForTesting; 87 bool m_isPausedForTesting;
88 }; 88 };
89 89
90 } // namespace 90 } // namespace
91 91
92 #endif 92 #endif
OLDNEW
« no previous file with comments | « Source/core/animation/DocumentTimeline.cpp ('k') | Source/core/animation/Player.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698