| OLD | NEW |
| 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 13 matching lines...) Expand all Loading... |
| 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 Image_h | 27 #ifndef Image_h |
| 28 #define Image_h | 28 #define Image_h |
| 29 | 29 |
| 30 #include "platform/PlatformExport.h" | 30 #include "platform/PlatformExport.h" |
| 31 #include "platform/SharedBuffer.h" | 31 #include "platform/SharedBuffer.h" |
| 32 #include "platform/geometry/IntRect.h" | 32 #include "platform/geometry/IntRect.h" |
| 33 #include "platform/graphics/Color.h" | 33 #include "platform/graphics/Color.h" |
| 34 #include "platform/graphics/ColorBehavior.h" |
| 34 #include "platform/graphics/GraphicsTypes.h" | 35 #include "platform/graphics/GraphicsTypes.h" |
| 35 #include "platform/graphics/ImageAnimationPolicy.h" | 36 #include "platform/graphics/ImageAnimationPolicy.h" |
| 36 #include "platform/graphics/ImageObserver.h" | 37 #include "platform/graphics/ImageObserver.h" |
| 37 #include "platform/graphics/ImageOrientation.h" | 38 #include "platform/graphics/ImageOrientation.h" |
| 38 #include "third_party/skia/include/core/SkRefCnt.h" | 39 #include "third_party/skia/include/core/SkRefCnt.h" |
| 39 #include "wtf/Assertions.h" | 40 #include "wtf/Assertions.h" |
| 40 #include "wtf/Noncopyable.h" | 41 #include "wtf/Noncopyable.h" |
| 41 #include "wtf/PassRefPtr.h" | 42 #include "wtf/PassRefPtr.h" |
| 42 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
| 43 #include "wtf/ThreadSafeRefCounted.h" | 44 #include "wtf/ThreadSafeRefCounted.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 146 } |
| 146 void clearImageObserver() { m_imageObserver = nullptr; } | 147 void clearImageObserver() { m_imageObserver = nullptr; } |
| 147 // To avoid interleaved accesses to |m_imageObserverDisabled|, do not call | 148 // To avoid interleaved accesses to |m_imageObserverDisabled|, do not call |
| 148 // setImageObserverDisabled() other than from ImageObserverDisabler. | 149 // setImageObserverDisabled() other than from ImageObserverDisabler. |
| 149 void setImageObserverDisabled(bool disabled) { | 150 void setImageObserverDisabled(bool disabled) { |
| 150 m_imageObserverDisabled = disabled; | 151 m_imageObserverDisabled = disabled; |
| 151 } | 152 } |
| 152 | 153 |
| 153 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; | 154 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; |
| 154 | 155 |
| 155 virtual sk_sp<SkImage> imageForCurrentFrame() = 0; | 156 virtual sk_sp<SkImage> imageForCurrentFrame(const ColorBehavior&) = 0; |
| 156 virtual PassRefPtr<Image> imageForDefaultFrame(); | 157 virtual PassRefPtr<Image> imageForDefaultFrame(); |
| 157 | 158 |
| 158 virtual void drawPattern(GraphicsContext&, | 159 virtual void drawPattern(GraphicsContext&, |
| 159 const FloatRect&, | 160 const FloatRect&, |
| 160 const FloatSize&, | 161 const FloatSize&, |
| 161 const FloatPoint& phase, | 162 const FloatPoint& phase, |
| 162 SkBlendMode, | 163 SkBlendMode, |
| 163 const FloatRect&, | 164 const FloatRect&, |
| 164 const FloatSize& repeatSpacing = FloatSize()); | 165 const FloatSize& repeatSpacing = FloatSize()); |
| 165 | 166 |
| 166 enum ImageClampingMode { | 167 enum ImageClampingMode { |
| 167 ClampImageToSourceRect, | 168 ClampImageToSourceRect, |
| 168 DoNotClampImageToSourceRect | 169 DoNotClampImageToSourceRect |
| 169 }; | 170 }; |
| 170 | 171 |
| 171 virtual void draw(SkCanvas*, | 172 virtual void draw(SkCanvas*, |
| 172 const SkPaint&, | 173 const SkPaint&, |
| 173 const FloatRect& dstRect, | 174 const FloatRect& dstRect, |
| 174 const FloatRect& srcRect, | 175 const FloatRect& srcRect, |
| 175 RespectImageOrientationEnum, | 176 RespectImageOrientationEnum, |
| 176 ImageClampingMode) = 0; | 177 ImageClampingMode, |
| 178 const ColorBehavior&) = 0; |
| 177 | 179 |
| 178 virtual bool applyShader(SkPaint&, const SkMatrix& localMatrix); | 180 virtual bool applyShader(SkPaint&, |
| 181 const SkMatrix& localMatrix, |
| 182 const ColorBehavior&); |
| 179 | 183 |
| 180 // Compute the tile which contains a given point (assuming a repeating tile | 184 // Compute the tile which contains a given point (assuming a repeating tile |
| 181 // grid). The point and returned value are in destination grid space. | 185 // grid). The point and returned value are in destination grid space. |
| 182 static FloatRect computeTileContaining(const FloatPoint&, | 186 static FloatRect computeTileContaining(const FloatPoint&, |
| 183 const FloatSize& tileSize, | 187 const FloatSize& tileSize, |
| 184 const FloatPoint& tilePhase, | 188 const FloatPoint& tilePhase, |
| 185 const FloatSize& tileSpacing); | 189 const FloatSize& tileSpacing); |
| 186 | 190 |
| 187 // Compute the image subset which gets mapped onto |dest|, when the whole | 191 // Compute the image subset which gets mapped onto |dest|, when the whole |
| 188 // image is drawn into |tile|. Assumes |tile| contains |dest|. The tile rect | 192 // image is drawn into |tile|. Assumes |tile| contains |dest|. The tile rect |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 bool m_imageObserverDisabled; | 224 bool m_imageObserverDisabled; |
| 221 }; | 225 }; |
| 222 | 226 |
| 223 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ | 227 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ |
| 224 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), \ | 228 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), \ |
| 225 image.is##typeName()) | 229 image.is##typeName()) |
| 226 | 230 |
| 227 } // namespace blink | 231 } // namespace blink |
| 228 | 232 |
| 229 #endif | 233 #endif |
| OLD | NEW |