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

Side by Side Diff: Source/core/svg/graphics/SVGImageChromeClient.cpp

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
« no previous file with comments | « Source/core/svg/graphics/SVGImage.cpp ('k') | no next file » | 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) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 14 matching lines...) Expand all
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/svg/graphics/SVGImageChromeClient.h" 30 #include "core/svg/graphics/SVGImageChromeClient.h"
31 31
32 #include "core/frame/FrameView.h" 32 #include "core/frame/FrameView.h"
33 #include "core/svg/graphics/SVGImage.h" 33 #include "core/svg/graphics/SVGImage.h"
34 #include "platform/graphics/ImageObserver.h" 34 #include "platform/graphics/ImageObserver.h"
35 #include "wtf/CurrentTime.h"
35 36
36 namespace WebCore { 37 namespace WebCore {
37 38
39 static const double animationFrameDelay = 0.025;
40
38 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image) 41 SVGImageChromeClient::SVGImageChromeClient(SVGImage* image)
39 : m_image(image) 42 : m_image(image)
40 , m_animationTimer(this, &SVGImageChromeClient::animationTimerFired) 43 , m_animationTimer(this, &SVGImageChromeClient::animationTimerFired)
41 { 44 {
42 } 45 }
43 46
44 bool SVGImageChromeClient::isSVGImageChromeClient() const 47 bool SVGImageChromeClient::isSVGImageChromeClient() const
45 { 48 {
46 return true; 49 return true;
47 } 50 }
(...skipping 12 matching lines...) Expand all
60 63
61 void SVGImageChromeClient::scheduleAnimation() 64 void SVGImageChromeClient::scheduleAnimation()
62 { 65 {
63 // Because a single SVGImage can be shared by multiple pages, we can't key 66 // Because a single SVGImage can be shared by multiple pages, we can't key
64 // our svg image layout on the page's real animation frame. Therefore, we 67 // our svg image layout on the page's real animation frame. Therefore, we
65 // run this fake animation timer to trigger layout in SVGImages. The name, 68 // run this fake animation timer to trigger layout in SVGImages. The name,
66 // "animationTimer", is to match the new requestAnimationFrame-based layout 69 // "animationTimer", is to match the new requestAnimationFrame-based layout
67 // approach. 70 // approach.
68 if (m_animationTimer.isActive()) 71 if (m_animationTimer.isActive())
69 return; 72 return;
70 m_animationTimer.startOneShot(0); 73 // Schedule the 'animation' ASAP if the image does not contain any
74 // animations, but prefer a fixed, jittery, frame-delay if there're any
75 // animations. Checking for pending/active animations could be more
76 // stringent.
77 double fireTime = m_image->hasAnimations() ? animationFrameDelay : 0;
78 m_animationTimer.startOneShot(fireTime);
71 } 79 }
72 80
73 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*) 81 void SVGImageChromeClient::animationTimerFired(Timer<SVGImageChromeClient>*)
74 { 82 {
75 // In principle, we should call requestAnimationFrame callbacks here, but 83 // In principle, we should call requestAnimationFrame callbacks here, but
76 // we know there aren't any because script is forbidden inside SVGImages. 84 // we know there aren't any because script is forbidden inside SVGImages.
77 if (m_image) { 85 if (m_image) {
78 m_image->frameView()->page()->animator().serviceScriptedAnimations(0); 86 m_image->frameView()->page()->animator().serviceScriptedAnimations(curre ntTime());
79 m_image->frameView()->updateLayoutAndStyleIfNeededRecursive(); 87 m_image->frameView()->updateLayoutAndStyleIfNeededRecursive();
80 } 88 }
81 } 89 }
82 90
83 } 91 }
OLDNEW
« no previous file with comments | « Source/core/svg/graphics/SVGImage.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698