| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 virtual PassRefPtr<Image> imageForDefaultFrame(); | 134 virtual PassRefPtr<Image> imageForDefaultFrame(); |
| 132 | 135 |
| 133 virtual void drawPattern(GraphicsContext*, const FloatRect&, | 136 virtual void drawPattern(GraphicsContext*, const FloatRect&, |
| 134 const FloatSize&, const FloatPoint& phase, SkXfermode::Mode, | 137 const FloatSize&, const FloatPoint& phase, SkXfermode::Mode, |
| 135 const FloatRect&, const IntSize& repeatSpacing = IntSize()); | 138 const FloatRect&, const IntSize& repeatSpacing = IntSize()); |
| 136 | 139 |
| 137 #if ENABLE(ASSERT) | 140 #if ENABLE(ASSERT) |
| 138 virtual bool notSolidColor() { return true; } | 141 virtual bool notSolidColor() { return true; } |
| 139 #endif | 142 #endif |
| 140 | 143 |
| 144 virtual void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const
FloatRect& srcRect, RespectImageOrientationEnum, bool shouldClampToSourceRect)
= 0; |
| 145 |
| 141 protected: | 146 protected: |
| 142 Image(ImageObserver* = 0); | 147 Image(ImageObserver* = 0); |
| 143 | 148 |
| 144 static void fillWithSolidColor(GraphicsContext*, const FloatRect& dstRect, c
onst Color&, SkXfermode::Mode); | 149 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. | |
| 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 |