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 15 matching lines...) Expand all Loading... | |
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/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
32 #include "platform/graphics/Color.h" | 32 #include "platform/graphics/Color.h" |
33 #include "platform/graphics/GraphicsTypes.h" | 33 #include "platform/graphics/GraphicsTypes.h" |
34 #include "platform/graphics/ImageAnimationPolicy.h" | 34 #include "platform/graphics/ImageAnimationPolicy.h" |
35 #include "platform/graphics/ImageOrientation.h" | 35 #include "platform/graphics/ImageOrientation.h" |
36 #include "third_party/skia/include/core/SkXfermode.h" | 36 #include "third_party/skia/include/core/SkCanvas.h" |
37 #include "wtf/Assertions.h" | 37 #include "wtf/Assertions.h" |
38 #include "wtf/PassRefPtr.h" | 38 #include "wtf/PassRefPtr.h" |
39 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
40 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
41 #include "wtf/RetainPtr.h" | 41 #include "wtf/RetainPtr.h" |
42 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
43 | 43 |
44 class SkBitmap; | 44 class SkBitmap; |
45 class SkImage; | 45 class SkImage; |
46 | 46 |
47 namespace blink { | 47 namespace blink { |
48 | 48 |
49 class FloatPoint; | 49 class FloatPoint; |
50 class FloatRect; | 50 class FloatRect; |
51 class FloatSize; | 51 class FloatSize; |
52 class GraphicsContext; | 52 class GraphicsContext; |
53 class Length; | 53 class Length; |
54 class SharedBuffer; | 54 class SharedBuffer; |
55 class Image; | |
55 | 56 |
56 // This class gets notified when an image creates or destroys decoded frames and when it advances animation frames. | 57 // This class gets notified when an image creates or destroys decoded frames and when it advances animation frames. |
57 class ImageObserver; | 58 class ImageObserver; |
58 | 59 |
60 class ImageFilterQualityHelper { | |
61 public: | |
62 virtual SkFilterQuality computeFilterQuality(Image*, const FloatRect& dest, const FloatRect& src) const = 0; | |
63 virtual bool shouldClampToSourceRect() const = 0; | |
64 virtual bool shouldDrawAntiAliased(const FloatRect&destRect) const = 0; | |
65 virtual ~ImageFilterQualityHelper() { } | |
66 }; | |
67 | |
59 class PLATFORM_EXPORT Image : public RefCounted<Image> { | 68 class PLATFORM_EXPORT Image : public RefCounted<Image> { |
60 friend class GeneratedImage; | 69 friend class GeneratedImage; |
61 friend class CrossfadeGeneratedImage; | 70 friend class CrossfadeGeneratedImage; |
62 friend class GradientGeneratedImage; | 71 friend class GradientGeneratedImage; |
63 friend class GraphicsContext; | 72 friend class GraphicsContext; |
64 | 73 |
65 public: | 74 public: |
66 virtual ~Image(); | 75 virtual ~Image(); |
67 | 76 |
68 static PassRefPtr<Image> loadPlatformResource(const char* name); | 77 static PassRefPtr<Image> loadPlatformResource(const char* name); |
69 static bool supportsType(const String&); | 78 static bool supportsType(const String&); |
70 | 79 |
71 virtual bool isSVGImage() const { return false; } | 80 virtual bool isSVGImage() const { return false; } |
72 virtual bool isBitmapImage() const { return false; } | 81 virtual bool isBitmapImage() const { return false; } |
82 virtual bool isLazyDecodedBitmap() { return false; } | |
83 virtual bool isImmutableBitmap() { return false; } | |
73 virtual bool currentFrameKnownToBeOpaque() = 0; | 84 virtual bool currentFrameKnownToBeOpaque() = 0; |
74 | 85 |
75 virtual PassRefPtr<SkImage> skImage(); | 86 virtual PassRefPtr<SkImage> skImage(); |
76 | 87 |
77 // Derived classes should override this if they can assure that the current | 88 // Derived classes should override this if they can assure that the current |
78 // image frame contains only resources from its own security origin. | 89 // image frame contains only resources from its own security origin. |
79 virtual bool currentFrameHasSingleSecurityOrigin() const { return false; } | 90 virtual bool currentFrameHasSingleSecurityOrigin() const { return false; } |
80 | 91 |
81 static Image* nullImage(); | 92 static Image* nullImage(); |
82 bool isNull() const { return size().isEmpty(); } | 93 bool isNull() const { return size().isEmpty(); } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 // Typically the ImageResource that owns us. | 134 // Typically the ImageResource that owns us. |
124 ImageObserver* imageObserver() const { return m_imageObserver; } | 135 ImageObserver* imageObserver() const { return m_imageObserver; } |
125 void setImageObserver(ImageObserver* observer) { m_imageObserver = observer; } | 136 void setImageObserver(ImageObserver* observer) { m_imageObserver = observer; } |
126 | 137 |
127 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; | 138 enum TileRule { StretchTile, RoundTile, SpaceTile, RepeatTile }; |
128 | 139 |
129 virtual bool bitmapForCurrentFrame(SkBitmap*) WARN_UNUSED_RETURN; | 140 virtual bool bitmapForCurrentFrame(SkBitmap*) WARN_UNUSED_RETURN; |
130 | 141 |
131 virtual PassRefPtr<Image> imageForDefaultFrame(); | 142 virtual PassRefPtr<Image> imageForDefaultFrame(); |
132 | 143 |
133 virtual void drawPattern(GraphicsContext*, const FloatRect&, | 144 virtual void drawPattern(GraphicsContext*, const FloatRect&, |
Stephen White
2015/05/27 15:46:02
Perhaps at some point we could circle back and cha
Justin Novosad
2015/05/27 20:08:16
Yeah, it is not required to enact the separation,
| |
134 const FloatSize&, const FloatPoint& phase, SkXfermode::Mode, | 145 const FloatSize&, const FloatPoint& phase, SkXfermode::Mode, |
135 const FloatRect&, const IntSize& repeatSpacing = IntSize()); | 146 const FloatRect&, const IntSize& repeatSpacing = IntSize()); |
136 | 147 |
137 #if ENABLE(ASSERT) | 148 #if ENABLE(ASSERT) |
138 virtual bool notSolidColor() { return true; } | 149 virtual bool notSolidColor() { return true; } |
139 #endif | 150 #endif |
140 | 151 |
152 virtual void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum, const ImageFilterQualityHelper *) = 0; | |
Stephen White
2015/05/27 15:46:02
To be honest, I'm not a fan of this callback objec
| |
153 | |
141 protected: | 154 protected: |
142 Image(ImageObserver* = 0); | 155 Image(ImageObserver* = 0); |
143 | 156 |
144 static void fillWithSolidColor(GraphicsContext*, const FloatRect& dstRect, c onst Color&, SkXfermode::Mode); | 157 static void fillWithSolidColor(GraphicsContext*, const FloatRect& dstRect, c onst Color&, SkXfermode::Mode); |
145 static FloatRect adjustForNegativeSize(const FloatRect&); // A helper method for translating negative width and height values. | 158 static FloatRect adjustForNegativeSize(const FloatRect&); // A helper method for translating negative width and height values. |
146 | 159 |
147 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRec t& srcRect, SkXfermode::Mode, RespectImageOrientationEnum) = 0; | |
148 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, | 160 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, |
149 SkXfermode::Mode, const IntSize& repeatSpacing); | 161 SkXfermode::Mode, const IntSize& repeatSpacing); |
150 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, SkXfe rmode::Mode); | 162 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, SkXfe rmode::Mode); |
151 | 163 |
152 // Supporting tiled drawing | 164 // Supporting tiled drawing |
153 virtual bool mayFillWithSolidColor() { return false; } | 165 virtual bool mayFillWithSolidColor() { return false; } |
154 virtual Color solidColor() const { return Color(); } | 166 virtual Color solidColor() const { return Color(); } |
155 | 167 |
156 private: | 168 private: |
157 RefPtr<SharedBuffer> m_encodedImageData; | 169 RefPtr<SharedBuffer> m_encodedImageData; |
158 ImageObserver* m_imageObserver; | 170 ImageObserver* m_imageObserver; |
159 }; | 171 }; |
160 | 172 |
161 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ | 173 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ |
162 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), image.is##t ypeName()) | 174 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), image.is##t ypeName()) |
163 | 175 |
164 } // namespace blink | 176 } // namespace blink |
165 | 177 |
166 #endif | 178 #endif |
OLD | NEW |