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

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

Issue 2005693002: Delay SVGImage animations reset while being updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/graphics/SVGImage.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) 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
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 void updateUseCounters(Document&) const; 77 void updateUseCounters(Document&) const;
78 78
79 // The defaultObjectSize is assumed to be unzoomed, i.e. it should 79 // The defaultObjectSize is assumed to be unzoomed, i.e. it should
80 // not have the effective zoom level applied. The returned size is 80 // not have the effective zoom level applied. The returned size is
81 // thus also independent of current zoom level. 81 // thus also independent of current zoom level.
82 FloatSize concreteObjectSize(const FloatSize& defaultObjectSize) const; 82 FloatSize concreteObjectSize(const FloatSize& defaultObjectSize) const;
83 83
84 bool hasIntrinsicDimensions() const; 84 bool hasIntrinsicDimensions() const;
85 85
86 // While updating the image's animations the underlying ImageResource needs
87 // to be kept alive and it should not trigger resetting of animations while
88 // the update runs. This scope object takes care of the details.
89 class UpdateAnimationScope {
90 STACK_ALLOCATED();
91 public:
92 explicit UpdateAnimationScope(SVGImage*);
93 ~UpdateAnimationScope();
94
95 private:
96 SVGImage* m_image;
97 Member<ImageObserver> m_imageObserver;
98 };
99
86 private: 100 private:
87 friend class AXLayoutObject; 101 friend class AXLayoutObject;
88 friend class SVGImageChromeClient; 102 friend class SVGImageChromeClient;
89 friend class SVGImageForContainer; 103 friend class SVGImageForContainer;
104 friend class UpdateAnimationScope;
90 105
91 ~SVGImage() override; 106 ~SVGImage() override;
92 107
93 String filenameExtension() const override; 108 String filenameExtension() const override;
94 109
95 IntSize containerSize() const; 110 IntSize containerSize() const;
96 bool usesContainerSize() const override { return true; } 111 bool usesContainerSize() const override { return true; }
97 112
98 bool dataChanged(bool allDataReceived) override; 113 bool dataChanged(bool allDataReceived) override;
99 114
100 // FIXME: SVGImages are underreporting decoded sizes and will be unable 115 // FIXME: SVGImages are underreporting decoded sizes and will be unable
101 // to prune because these functions are not implemented yet. 116 // to prune because these functions are not implemented yet.
102 void destroyDecodedData(bool) override { } 117 void destroyDecodedData(bool) override { }
103 118
104 // FIXME: Implement this to be less conservative. 119 // FIXME: Implement this to be less conservative.
105 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; } 120 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { return false; }
106 121
107 SVGImage(ImageObserver*); 122 SVGImage(ImageObserver*);
108 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override; 123 void draw(SkCanvas*, const SkPaint&, const FloatRect& fromRect, const FloatR ect& toRect, RespectImageOrientationEnum, ImageClampingMode) override;
109 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con st FloatRect&, const FloatRect&, const KURL&); 124 void drawForContainer(SkCanvas*, const SkPaint&, const FloatSize, float, con st FloatRect&, const FloatRect&, const KURL&);
110 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const FloatRect&, const FloatSize&, const FloatPoint&, 125 void drawPatternForContainer(GraphicsContext&, const FloatSize, float, const FloatRect&, const FloatSize&, const FloatPoint&,
111 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons t KURL&); 126 SkXfermode::Mode, const FloatRect&, const FloatSize& repeatSpacing, cons t KURL&);
112 PassRefPtr<SkImage> imageForCurrentFrameForContainer(const KURL&, const Floa tSize& containerSize); 127 PassRefPtr<SkImage> imageForCurrentFrameForContainer(const KURL&, const Floa tSize& containerSize);
113 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons t FloatRect& toRect, RespectImageOrientationEnum, 128 void drawInternal(SkCanvas*, const SkPaint&, const FloatRect& fromRect, cons t FloatRect& toRect, RespectImageOrientationEnum,
114 ImageClampingMode, const KURL&); 129 ImageClampingMode, const KURL&);
115 130
131 void enterNoResetAnimationsScope()
132 {
133 // No known need for supporting nested invocations.
134 DCHECK(!m_updatingAnimations);
135 m_updatingAnimations = true;
136 }
137
138 void leaveNoResetAnimationScope();
139
116 Persistent<SVGImageChromeClient> m_chromeClient; 140 Persistent<SVGImageChromeClient> m_chromeClient;
117 Persistent<Page> m_page; 141 Persistent<Page> m_page;
118 142
119 // When an SVG image has no intrinsic size the size depends on the 143 // When an SVG image has no intrinsic size the size depends on the
120 // default object size, which in turn depends on the 144 // default object size, which in turn depends on the
121 // container. SVGImage may belong to multiple containers so the 145 // container. SVGImage may belong to multiple containers so the
122 // final image size can't be known in 146 // final image size can't be known in
123 // SVGImage. SVGImageForContainer carried the final image size, 147 // SVGImage. SVGImageForContainer carried the final image size,
124 // also called concrete object size. 148 // also called concrete object size.
125 IntSize m_intrinsicSize; 149 IntSize m_intrinsicSize;
150
151 bool m_updatingAnimations;
152 bool m_resetAnimationAfterUpdate;
126 }; 153 };
127 154
128 DEFINE_IMAGE_TYPE_CASTS(SVGImage); 155 DEFINE_IMAGE_TYPE_CASTS(SVGImage);
129 156
130 class ImageObserverDisabler { 157 class ImageObserverDisabler {
131 STACK_ALLOCATED(); 158 STACK_ALLOCATED();
132 WTF_MAKE_NONCOPYABLE(ImageObserverDisabler); 159 WTF_MAKE_NONCOPYABLE(ImageObserverDisabler);
133 public: 160 public:
134 ImageObserverDisabler(Image* image) 161 ImageObserverDisabler(Image* image)
135 : m_image(image) 162 : m_image(image)
136 { 163 {
137 m_image->setImageObserverDisabled(true); 164 m_image->setImageObserverDisabled(true);
138 } 165 }
139 166
140 ~ImageObserverDisabler() 167 ~ImageObserverDisabler()
141 { 168 {
142 m_image->setImageObserverDisabled(false); 169 m_image->setImageObserverDisabled(false);
143 } 170 }
144 private: 171 private:
145 Image* m_image; 172 Image* m_image;
146 }; 173 };
147 174
148 } // namespace blink 175 } // namespace blink
149 176
150 #endif // SVGImage_h 177 #endif // SVGImage_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698