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

Side by Side Diff: Source/core/svg/animation/SMILTimeContainer.h

Issue 190963003: Drive SVG Animations via requestAnimationFrame (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 20 matching lines...) Expand all
31 #include "platform/Timer.h" 31 #include "platform/Timer.h"
32 #include "wtf/HashMap.h" 32 #include "wtf/HashMap.h"
33 #include "wtf/HashSet.h" 33 #include "wtf/HashSet.h"
34 #include "wtf/PassRefPtr.h" 34 #include "wtf/PassRefPtr.h"
35 #include "wtf/RefCounted.h" 35 #include "wtf/RefCounted.h"
36 #include "wtf/text/StringHash.h" 36 #include "wtf/text/StringHash.h"
37 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 class AnimationClock;
42 class Document;
41 class SVGElement; 43 class SVGElement;
42 class SVGSMILElement; 44 class SVGSMILElement;
43 class SVGSVGElement; 45 class SVGSVGElement;
44 46
45 class SMILTimeContainer : public RefCounted<SMILTimeContainer> { 47 class SMILTimeContainer : public RefCounted<SMILTimeContainer> {
46 public: 48 public:
47 static PassRefPtr<SMILTimeContainer> create(SVGSVGElement* owner) { return a doptRef(new SMILTimeContainer(owner)); } 49 static PassRefPtr<SMILTimeContainer> create(SVGSVGElement* owner) { return a doptRef(new SMILTimeContainer(owner)); }
48 ~SMILTimeContainer(); 50 ~SMILTimeContainer();
49 51
50 void schedule(SVGSMILElement*, SVGElement*, const QualifiedName&); 52 void schedule(SVGSMILElement*, SVGElement*, const QualifiedName&);
51 void unschedule(SVGSMILElement*, SVGElement*, const QualifiedName&); 53 void unschedule(SVGSMILElement*, SVGElement*, const QualifiedName&);
52 void notifyIntervalsChanged(); 54 void notifyIntervalsChanged();
53 55
54 SMILTime elapsed() const; 56 SMILTime elapsed() const;
55 57
56 bool isPaused() const; 58 bool isPaused() const;
57 bool isStarted() const; 59 bool isStarted() const;
58 60
59 void begin(); 61 void begin();
60 void pause(); 62 void pause();
61 void resume(); 63 void resume();
62 void setElapsed(SMILTime); 64 void setElapsed(SMILTime);
63 65
66 void serviceAnimations(double monotonicAnimationStartTime);
67 bool hasAnimations() const;
68
64 void setDocumentOrderIndexesDirty() { m_documentOrderIndexesDirty = true; } 69 void setDocumentOrderIndexesDirty() { m_documentOrderIndexesDirty = true; }
65 70
66 private: 71 private:
67 SMILTimeContainer(SVGSVGElement* owner); 72 SMILTimeContainer(SVGSVGElement* owner);
68 73
74 enum FrameSchedulingState {
75 // No frame scheduled.
76 Idle,
77 // Scheduled a wakeup to update the animation values.
78 SynchronizeAnimations,
79 // Scheduled a animation frame for continuous update.
80 AnimationFrame
81 };
82
69 bool isTimelineRunning() const; 83 bool isTimelineRunning() const;
70 void scheduleAnimationFrame(SMILTime fireTime); 84 void scheduleAnimationFrame(SMILTime fireTime);
71 void scheduleAnimationFrame();
72 void cancelAnimationFrame(); 85 void cancelAnimationFrame();
73 void timerFired(Timer<SMILTimeContainer>*); 86 void wakeupTimerFired(Timer<SMILTimeContainer>*);
74 void updateAnimations(SMILTime elapsed, bool seekToTime = false); 87 void updateAnimationsAndScheduleFrameIfNeeded(SMILTime elapsed, bool seekToT ime = false);
88 SMILTime updateAnimations(SMILTime elapsed, bool seekToTime = false);
89 void serviceOnNextFrame();
90 void scheduleWakeUp(double delayTime, FrameSchedulingState);
75 91
76 void updateDocumentOrderIndexes(); 92 void updateDocumentOrderIndexes();
77 double lastResumeTime() const { return m_resumeTime ? m_resumeTime : m_begin Time; } 93 double lastResumeTime() const { return m_resumeTime ? m_resumeTime : m_begin Time; }
78 94
95 Document& document() const;
96 AnimationClock& animationClock() const;
97 double currentTime() const;
98
79 double m_beginTime; 99 double m_beginTime;
80 double m_pauseTime; 100 double m_pauseTime;
81 double m_resumeTime; 101 double m_resumeTime;
82 double m_accumulatedActiveTime; 102 double m_accumulatedActiveTime;
83 double m_presetStartTime; 103 double m_presetStartTime;
84 104
105 FrameSchedulingState m_frameSchedulingState;
85 bool m_documentOrderIndexesDirty; 106 bool m_documentOrderIndexesDirty;
86 107
87 Timer<SMILTimeContainer> m_timer; 108 OwnPtr<AnimationClock> m_animationClock;
109 Timer<SMILTimeContainer> m_wakeupTimer;
88 110
89 typedef pair<SVGElement*, QualifiedName> ElementAttributePair; 111 typedef pair<SVGElement*, QualifiedName> ElementAttributePair;
90 typedef Vector<SVGSMILElement*> AnimationsVector; 112 typedef Vector<SVGSMILElement*> AnimationsVector;
91 typedef HashMap<ElementAttributePair, OwnPtr<AnimationsVector> > GroupedAnim ationsMap; 113 typedef HashMap<ElementAttributePair, OwnPtr<AnimationsVector> > GroupedAnim ationsMap;
92 GroupedAnimationsMap m_scheduledAnimations; 114 GroupedAnimationsMap m_scheduledAnimations;
93 115
94 SVGSVGElement* m_ownerSVGElement; 116 SVGSVGElement* m_ownerSVGElement;
95 117
96 #ifndef NDEBUG 118 #ifndef NDEBUG
97 bool m_preventScheduledAnimationsChanges; 119 bool m_preventScheduledAnimationsChanges;
98 #endif 120 #endif
99 }; 121 };
100 } 122 }
101 123
102 #endif // SMILTimeContainer_h 124 #endif // SMILTimeContainer_h
OLDNEW
« no previous file with comments | « Source/core/svg/SVGDocumentExtensions.cpp ('k') | Source/core/svg/animation/SMILTimeContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698