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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Image.h

Issue 2398453002: Rewrap comments to 80 columns in Source/platform/graphics/. (Closed)
Patch Set: Review feedback Created 4 years, 2 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 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 virtual String filenameExtension() const { 113 virtual String filenameExtension() const {
114 return String(); 114 return String();
115 } // null string if unknown 115 } // null string if unknown
116 116
117 virtual void destroyDecodedData() = 0; 117 virtual void destroyDecodedData() = 0;
118 118
119 virtual PassRefPtr<SharedBuffer> data() { return m_encodedImageData; } 119 virtual PassRefPtr<SharedBuffer> data() { return m_encodedImageData; }
120 120
121 // Animation begins whenever someone draws the image, so startAnimation() is n ot normally called. 121 // Animation begins whenever someone draws the image, so startAnimation() is
122 // It will automatically pause once all observers no longer want to render the image anywhere. 122 // not normally called. It will automatically pause once all observers no
123 // longer want to render the image anywhere.
123 enum CatchUpAnimation { DoNotCatchUp, CatchUp }; 124 enum CatchUpAnimation { DoNotCatchUp, CatchUp };
124 virtual void startAnimation(CatchUpAnimation = CatchUp) {} 125 virtual void startAnimation(CatchUpAnimation = CatchUp) {}
125 virtual void resetAnimation() {} 126 virtual void resetAnimation() {}
126 127
127 // True if this image can potentially animate. 128 // True if this image can potentially animate.
128 virtual bool maybeAnimated() { return false; } 129 virtual bool maybeAnimated() { return false; }
129 130
130 // Set animationPolicy 131 // Set animationPolicy
131 virtual void setAnimationPolicy(ImageAnimationPolicy) {} 132 virtual void setAnimationPolicy(ImageAnimationPolicy) {}
132 virtual ImageAnimationPolicy animationPolicy() { 133 virtual ImageAnimationPolicy animationPolicy() {
133 return ImageAnimationPolicyAllowed; 134 return ImageAnimationPolicyAllowed;
134 } 135 }
135 virtual void advanceTime(double deltaTimeInSeconds) {} 136 virtual void advanceTime(double deltaTimeInSeconds) {}
136 137
137 // Advances an animated image. For BitmapImage (e.g., animated gifs) this 138 // Advances an animated image. For BitmapImage (e.g., animated gifs) this
138 // will advance to the next frame. For SVGImage, this will trigger an 139 // will advance to the next frame. For SVGImage, this will trigger an
139 // animation update for CSS and advance the SMIL timeline by one frame. 140 // animation update for CSS and advance the SMIL timeline by one frame.
140 virtual void advanceAnimationForTesting() {} 141 virtual void advanceAnimationForTesting() {}
141 142
142 // Typically the ImageResource that owns us. 143 // Typically the ImageResource that owns us.
143 ImageObserver* getImageObserver() const { 144 ImageObserver* getImageObserver() const {
144 return m_imageObserverDisabled ? nullptr : m_imageObserver; 145 return m_imageObserverDisabled ? nullptr : m_imageObserver;
145 } 146 }
146 void clearImageObserver() { m_imageObserver = nullptr; } 147 void clearImageObserver() { m_imageObserver = nullptr; }
147 // Do not call setImageObserverDisabled() other than from ImageObserverDisable r to avoid interleaved accesses to |m_imageObserverDisabled|. 148 // To avoid interleaved accesses to |m_imageObserverDisabled|, do not call
149 // setImageObserverDisabled() other than from ImageObserverDisabler.
148 void setImageObserverDisabled(bool disabled) { 150 void setImageObserverDisabled(bool disabled) {
149 m_imageObserverDisabled = disabled; 151 m_imageObserverDisabled = disabled;
150 } 152 }
151 153
152 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; 154 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile };
153 155
154 virtual sk_sp<SkImage> imageForCurrentFrame() = 0; 156 virtual sk_sp<SkImage> imageForCurrentFrame() = 0;
155 virtual PassRefPtr<Image> imageForDefaultFrame(); 157 virtual PassRefPtr<Image> imageForDefaultFrame();
156 158
157 virtual void drawPattern(GraphicsContext&, 159 virtual void drawPattern(GraphicsContext&,
(...skipping 11 matching lines...) Expand all
169 171
170 virtual void draw(SkCanvas*, 172 virtual void draw(SkCanvas*,
171 const SkPaint&, 173 const SkPaint&,
172 const FloatRect& dstRect, 174 const FloatRect& dstRect,
173 const FloatRect& srcRect, 175 const FloatRect& srcRect,
174 RespectImageOrientationEnum, 176 RespectImageOrientationEnum,
175 ImageClampingMode) = 0; 177 ImageClampingMode) = 0;
176 178
177 virtual bool applyShader(SkPaint&, const SkMatrix& localMatrix); 179 virtual bool applyShader(SkPaint&, const SkMatrix& localMatrix);
178 180
179 // Compute the tile which contains a given point (assuming a repeating tile gr id). 181 // Compute the tile which contains a given point (assuming a repeating tile
180 // The point and returned value are in destination grid space. 182 // grid). The point and returned value are in destination grid space.
181 static FloatRect computeTileContaining(const FloatPoint&, 183 static FloatRect computeTileContaining(const FloatPoint&,
182 const FloatSize& tileSize, 184 const FloatSize& tileSize,
183 const FloatPoint& tilePhase, 185 const FloatPoint& tilePhase,
184 const FloatSize& tileSpacing); 186 const FloatSize& tileSpacing);
185 187
186 // Compute the image subset which gets mapped onto dest, when the whole image is drawn into 188 // Compute the image subset which gets mapped onto |dest|, when the whole
187 // tile. Assumes the tile contains dest. The tile rect is in destination gri d space while 189 // image is drawn into |tile|. Assumes |tile| contains |dest|. The tile rect
188 // the return value is in image coordinate space. 190 // is in destination grid space while the return value is in image coordinate
191 // space.
189 static FloatRect computeSubsetForTile(const FloatRect& tile, 192 static FloatRect computeSubsetForTile(const FloatRect& tile,
190 const FloatRect& dest, 193 const FloatRect& dest,
191 const FloatSize& imageSize); 194 const FloatSize& imageSize);
192 195
193 protected: 196 protected:
194 Image(ImageObserver* = 0); 197 Image(ImageObserver* = 0);
195 198
196 void drawTiled(GraphicsContext&, 199 void drawTiled(GraphicsContext&,
197 const FloatRect& dstRect, 200 const FloatRect& dstRect,
198 const FloatPoint& srcPoint, 201 const FloatPoint& srcPoint,
199 const FloatSize& tileSize, 202 const FloatSize& tileSize,
200 SkXfermode::Mode, 203 SkXfermode::Mode,
201 const FloatSize& repeatSpacing); 204 const FloatSize& repeatSpacing);
202 void drawTiled(GraphicsContext&, 205 void drawTiled(GraphicsContext&,
203 const FloatRect& dstRect, 206 const FloatRect& dstRect,
204 const FloatRect& srcRect, 207 const FloatRect& srcRect,
205 const FloatSize& tileScaleFactor, 208 const FloatSize& tileScaleFactor,
206 TileRule hRule, 209 TileRule hRule,
207 TileRule vRule, 210 TileRule vRule,
208 SkXfermode::Mode); 211 SkXfermode::Mode);
209 212
210 private: 213 private:
211 RefPtr<SharedBuffer> m_encodedImageData; 214 RefPtr<SharedBuffer> m_encodedImageData;
212 // TODO(Oilpan): consider having Image on the Oilpan heap and 215 // TODO(Oilpan): consider having Image on the Oilpan heap and
213 // turn this into a Member<>. 216 // turn this into a Member<>.
214 // 217 //
215 // The observer (an ImageResource) is an untraced member, with the ImageResour ce 218 // The observer (an ImageResource) is an untraced member, with the
216 // being responsible of clearing itself out. 219 // ImageResource being responsible for clearing itself out.
217 UntracedMember<ImageObserver> m_imageObserver; 220 UntracedMember<ImageObserver> m_imageObserver;
218 bool m_imageObserverDisabled; 221 bool m_imageObserverDisabled;
219 }; 222 };
220 223
221 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ 224 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \
222 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), \ 225 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), \
223 image.is##typeName()) 226 image.is##typeName())
224 227
225 } // namespace blink 228 } // namespace blink
226 229
227 #endif 230 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/GraphicsTypes.h ('k') | third_party/WebKit/Source/platform/graphics/Image.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698