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