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 |
59 class PLATFORM_EXPORT Image : public RefCounted<Image> { | 60 class PLATFORM_EXPORT Image : public RefCounted<Image> { |
60 friend class GeneratedImage; | 61 friend class GeneratedImage; |
61 friend class CrossfadeGeneratedImage; | 62 friend class CrossfadeGeneratedImage; |
62 friend class GradientGeneratedImage; | 63 friend class GradientGeneratedImage; |
63 friend class GraphicsContext; | 64 friend class GraphicsContext; |
64 | 65 |
65 public: | 66 public: |
66 virtual ~Image(); | 67 virtual ~Image(); |
67 | 68 |
68 static PassRefPtr<Image> loadPlatformResource(const char* name); | 69 static PassRefPtr<Image> loadPlatformResource(const char* name); |
69 static bool supportsType(const String&); | 70 static bool supportsType(const String&); |
70 | 71 |
71 virtual bool isSVGImage() const { return false; } | 72 virtual bool isSVGImage() const { return false; } |
72 virtual bool isBitmapImage() const { return false; } | 73 virtual bool isBitmapImage() const { return false; } |
| 74 virtual bool isLazyDecodedBitmap() { return false; } |
| 75 virtual bool isImmutableBitmap() { return false; } |
73 virtual bool currentFrameKnownToBeOpaque() = 0; | 76 virtual bool currentFrameKnownToBeOpaque() = 0; |
74 | 77 |
75 virtual PassRefPtr<SkImage> skImage(); | 78 virtual PassRefPtr<SkImage> skImage(); |
76 | 79 |
77 // Derived classes should override this if they can assure that the current | 80 // Derived classes should override this if they can assure that the current |
78 // image frame contains only resources from its own security origin. | 81 // image frame contains only resources from its own security origin. |
79 virtual bool currentFrameHasSingleSecurityOrigin() const { return false; } | 82 virtual bool currentFrameHasSingleSecurityOrigin() const { return false; } |
80 | 83 |
81 static Image* nullImage(); | 84 static Image* nullImage(); |
82 bool isNull() const { return size().isEmpty(); } | 85 bool isNull() const { return size().isEmpty(); } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 virtual PassRefPtr<Image> imageForDefaultFrame(); | 135 virtual PassRefPtr<Image> imageForDefaultFrame(); |
133 | 136 |
134 virtual void drawPattern(GraphicsContext*, const FloatRect&, | 137 virtual void drawPattern(GraphicsContext*, const FloatRect&, |
135 const FloatSize&, const FloatPoint& phase, SkXfermode::Mode, | 138 const FloatSize&, const FloatPoint& phase, SkXfermode::Mode, |
136 const FloatRect&, const IntSize& repeatSpacing = IntSize()); | 139 const FloatRect&, const IntSize& repeatSpacing = IntSize()); |
137 | 140 |
138 #if ENABLE(ASSERT) | 141 #if ENABLE(ASSERT) |
139 virtual bool notSolidColor() { return true; } | 142 virtual bool notSolidColor() { return true; } |
140 #endif | 143 #endif |
141 | 144 |
| 145 enum ImageClampingMode { |
| 146 ClampImageToSourceRect, |
| 147 DoNotClampImageToSourceRect |
| 148 }; |
| 149 |
| 150 virtual void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const
FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode) = 0; |
| 151 |
142 protected: | 152 protected: |
143 Image(ImageObserver* = 0); | 153 Image(ImageObserver* = 0); |
144 | 154 |
145 static void fillWithSolidColor(GraphicsContext*, const FloatRect& dstRect, c
onst Color&, SkXfermode::Mode); | 155 static void fillWithSolidColor(GraphicsContext*, const FloatRect& dstRect, c
onst Color&, SkXfermode::Mode); |
146 static FloatRect adjustForNegativeSize(const FloatRect&); // A helper method
for translating negative width and height values. | |
147 | 156 |
148 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRec
t& srcRect, SkXfermode::Mode, RespectImageOrientationEnum) = 0; | |
149 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint&
srcPoint, const FloatSize& tileSize, | 157 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint&
srcPoint, const FloatSize& tileSize, |
150 SkXfermode::Mode, const IntSize& repeatSpacing); | 158 SkXfermode::Mode, const IntSize& repeatSpacing); |
151 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect&
srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, SkXfe
rmode::Mode); | 159 void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect&
srcRect, const FloatSize& tileScaleFactor, TileRule hRule, TileRule vRule, SkXfe
rmode::Mode); |
152 | 160 |
153 // Supporting tiled drawing | 161 // Supporting tiled drawing |
154 virtual bool mayFillWithSolidColor() { return false; } | 162 virtual bool mayFillWithSolidColor() { return false; } |
155 virtual Color solidColor() const { return Color(); } | 163 virtual Color solidColor() const { return Color(); } |
156 | 164 |
157 private: | 165 private: |
158 RefPtr<SharedBuffer> m_encodedImageData; | 166 RefPtr<SharedBuffer> m_encodedImageData; |
159 ImageObserver* m_imageObserver; | 167 ImageObserver* m_imageObserver; |
160 }; | 168 }; |
161 | 169 |
162 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ | 170 #define DEFINE_IMAGE_TYPE_CASTS(typeName) \ |
163 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), image.is##t
ypeName()) | 171 DEFINE_TYPE_CASTS(typeName, Image, image, image->is##typeName(), image.is##t
ypeName()) |
164 | 172 |
165 } // namespace blink | 173 } // namespace blink |
166 | 174 |
167 #endif | 175 #endif |
OLD | NEW |