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

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.h

Issue 2000483003: Rework timeline/frame scheduling logic for SVGImage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unittest Created 4 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef SVGImage_h 27 #ifndef SVGImage_h
28 #define SVGImage_h 28 #define SVGImage_h
29 29
30 #include "core/CoreExport.h"
30 #include "platform/graphics/Image.h" 31 #include "platform/graphics/Image.h"
31 #include "platform/heap/Handle.h" 32 #include "platform/heap/Handle.h"
32 #include "platform/weborigin/KURL.h" 33 #include "platform/weborigin/KURL.h"
33 #include "wtf/Allocator.h" 34 #include "wtf/Allocator.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 class Document; 38 class Document;
38 class FrameView;
39 class Page; 39 class Page;
40 class LayoutReplaced; 40 class LayoutReplaced;
41 class SVGImageChromeClient; 41 class SVGImageChromeClient;
42 class SVGImageForContainer; 42 class SVGImageForContainer;
43 43
44 class SVGImage final : public Image { 44 class CORE_EXPORT SVGImage final : public Image {
45 public: 45 public:
46 static PassRefPtr<SVGImage> create(ImageObserver* observer) 46 static PassRefPtr<SVGImage> create(ImageObserver* observer)
47 { 47 {
48 return adoptRef(new SVGImage(observer)); 48 return adoptRef(new SVGImage(observer));
49 } 49 }
50 50
51 static bool isInSVGImage(const Node*); 51 static bool isInSVGImage(const Node*);
52 52
53 LayoutReplaced* embeddedReplacedContent() const; 53 LayoutReplaced* embeddedReplacedContent() const;
54 54
55 bool isSVGImage() const override { return true; } 55 bool isSVGImage() const override { return true; }
56 bool isTextureBacked() override { return false; } 56 bool isTextureBacked() override { return false; }
57 IntSize size() const override { return m_intrinsicSize; } 57 IntSize size() const override { return m_intrinsicSize; }
58 58
59 bool currentFrameHasSingleSecurityOrigin() const override; 59 bool currentFrameHasSingleSecurityOrigin() const override;
60 60
61 void startAnimation(CatchUpAnimation = CatchUp) override; 61 void startAnimation(CatchUpAnimation = CatchUp) override;
62 void resetAnimation() override; 62 void resetAnimation() override;
63 63
64 // Advances an animated image. This will trigger an animation update for CSS 64 // Advances an animated image. This will trigger an animation update for CSS
65 // and advance the SMIL timeline by one frame. 65 // and advance the SMIL timeline by one frame.
66 void advanceAnimationForTesting() override; 66 void advanceAnimationForTesting() override;
67 SVGImageChromeClient& chromeClientForTesting();
67 68
68 PassRefPtr<SkImage> imageForCurrentFrame() override; 69 PassRefPtr<SkImage> imageForCurrentFrame() override;
69 70
70 // Returns the SVG image document's frame.
71 FrameView* frameView() const;
72
73 // Does the SVG image/document contain any animations? 71 // Does the SVG image/document contain any animations?
74 bool hasAnimations() const; 72 bool hasAnimations() const;
73 // Service CSS and SMIL animations.
74 void serviceAnimations(double monotonicAnimationStartTime);
75 75
76 void updateUseCounters(Document&) const; 76 void updateUseCounters(Document&) const;
77 77
78 // The defaultObjectSize is assumed to be unzoomed, i.e. it should 78 // The defaultObjectSize is assumed to be unzoomed, i.e. it should
79 // not have the effective zoom level applied. The returned size is 79 // not have the effective zoom level applied. The returned size is
80 // thus also independent of current zoom level. 80 // thus also independent of current zoom level.
81 FloatSize concreteObjectSize(const FloatSize& defaultObjectSize) const; 81 FloatSize concreteObjectSize(const FloatSize& defaultObjectSize) const;
82 82
83 bool hasIntrinsicDimensions() const; 83 bool hasIntrinsicDimensions() const;
84 84
85 private: 85 private:
86 friend class AXLayoutObject; 86 // Accesses m_page.
87 friend class SVGImageChromeClient; 87 friend class SVGImageChromeClient;
88 // Forwards calls to the various *ForContainer methods and other parts of
89 // the the Image interface.
88 friend class SVGImageForContainer; 90 friend class SVGImageForContainer;
89 91
90 ~SVGImage() override; 92 ~SVGImage() override;
91 93
92 String filenameExtension() const override; 94 String filenameExtension() const override;
93 95
94 IntSize containerSize() const; 96 IntSize containerSize() const;
95 bool usesContainerSize() const override { return true; } 97 bool usesContainerSize() const override { return true; }
96 98
97 bool dataChanged(bool allDataReceived) override; 99 bool dataChanged(bool allDataReceived) override;
98 100
99 // FIXME: SVGImages are underreporting decoded sizes and will be unable 101 // FIXME: SVGImages are underreporting decoded sizes and will be unable
100 // to prune because these functions are not implemented yet. 102 // to prune because these functions are not implemented yet.
101 void destroyDecodedData() override { } 103 void destroyDecodedData() override { }
102 104
103 // FIXME: Implement this to be less conservative. 105 // FIXME: Implement this to be less conservative.
104 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; } 106 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; }
105 107
106 SVGImage(ImageObserver*); 108 SVGImage(ImageObserver*);
107 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override; 109 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override;
108 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con st FloatRect&, const FloatRect&, const KURL&); 110 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con st FloatRect&, const FloatRect&, const KURL&);
109 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const FloatRect&, const FloatSize&, const FloatPoint&, 111 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const FloatRect&, const FloatSize&, const FloatPoint&,
110 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons t KURL&); 112 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons t KURL&);
111 PassRefPtr<SkImage> imageForCurrentFrameForContainer(const KURL&, const Floa tSize& containerSize); 113 PassRefPtr<SkImage> imageForCurrentFrameForContainer(const KURL&, const Floa tSize& containerSize);
112 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons t FloatRect& toRect, RespectImageOrientationEnum, 114 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons t FloatRect& toRect, RespectImageOrientationEnum,
113 ImageClampingMode, const KURL&); 115 ImageClampingMode, const KURL&);
114 116
117 void stopAnimation();
118
115 Persistent<SVGImageChromeClient> m_chromeClient; 119 Persistent<SVGImageChromeClient> m_chromeClient;
116 Persistent<Page> m_page; 120 Persistent<Page> m_page;
117 121
118 // When an SVG image has no intrinsic size the size depends on the 122 // When an SVG image has no intrinsic size the size depends on the
119 // default object size, which in turn depends on the 123 // default object size, which in turn depends on the
120 // container. SVGImage may belong to multiple containers so the 124 // container. SVGImage may belong to multiple containers so the
121 // final image size can't be known in 125 // final image size can't be known in
122 // SVGImage. SVGImageForContainer carried the final image size, 126 // SVGImage. SVGImageForContainer carried the final image size,
123 // also called concrete object size. 127 // also called concrete object size.
124 IntSize m_intrinsicSize; 128 IntSize m_intrinsicSize;
(...skipping 15 matching lines...) Expand all
140 { 144 {
141 m_image->setImageObserverDisabled(false); 145 m_image->setImageObserverDisabled(false);
142 } 146 }
143 private: 147 private:
144 Image* m_image; 148 Image* m_image;
145 }; 149 };
146 150
147 } // namespace blink 151 } // namespace blink
148 152
149 #endif // SVGImage_h 153 #endif // SVGImage_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698