| 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 * Copyright (C) 2008-2009 Torch Mobile, Inc. | 4 * Copyright (C) 2008-2009 Torch Mobile, Inc. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "platform/graphics/FrameData.h" | 33 #include "platform/graphics/FrameData.h" |
| 34 #include "platform/graphics/Image.h" | 34 #include "platform/graphics/Image.h" |
| 35 #include "platform/graphics/ImageAnimationPolicy.h" | 35 #include "platform/graphics/ImageAnimationPolicy.h" |
| 36 #include "platform/graphics/ImageOrientation.h" | 36 #include "platform/graphics/ImageOrientation.h" |
| 37 #include "platform/graphics/ImageSource.h" | 37 #include "platform/graphics/ImageSource.h" |
| 38 #include "platform/image-decoders/ImageAnimation.h" | 38 #include "platform/image-decoders/ImageAnimation.h" |
| 39 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class NativeImageSkia; | |
| 44 template <typename T> class Timer; | 43 template <typename T> class Timer; |
| 45 | 44 |
| 46 class PLATFORM_EXPORT BitmapImage : public Image { | 45 class PLATFORM_EXPORT BitmapImage : public Image { |
| 47 friend class GeneratedImage; | 46 friend class GeneratedImage; |
| 48 friend class CrossfadeGeneratedImage; | 47 friend class CrossfadeGeneratedImage; |
| 49 friend class GradientGeneratedImage; | 48 friend class GradientGeneratedImage; |
| 50 friend class GraphicsContext; | 49 friend class GraphicsContext; |
| 51 public: | 50 public: |
| 52 static PassRefPtr<BitmapImage> create(PassRefPtr<NativeImageSkia>, ImageObse
rver* = 0); | 51 static PassRefPtr<BitmapImage> create(const SkBitmap&, ImageObserver* = 0); |
| 53 | 52 |
| 54 static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0) | 53 static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0) |
| 55 { | 54 { |
| 56 return adoptRef(new BitmapImage(observer)); | 55 return adoptRef(new BitmapImage(observer)); |
| 57 } | 56 } |
| 58 | 57 |
| 59 // This allows constructing a BitmapImage with a forced non-default orientat
ion. | 58 // This allows constructing a BitmapImage with a forced non-default orientat
ion. |
| 60 static PassRefPtr<BitmapImage> createWithOrientationForTesting(PassRefPtr<Na
tiveImageSkia>, ImageOrientation); | 59 static PassRefPtr<BitmapImage> createWithOrientationForTesting(const SkBitma
p&, ImageOrientation); |
| 61 | 60 |
| 62 virtual ~BitmapImage(); | 61 virtual ~BitmapImage(); |
| 63 | 62 |
| 64 virtual bool isBitmapImage() const override; | 63 virtual bool isBitmapImage() const override; |
| 65 | 64 |
| 66 virtual bool currentFrameHasSingleSecurityOrigin() const override; | 65 virtual bool currentFrameHasSingleSecurityOrigin() const override; |
| 67 | 66 |
| 68 virtual IntSize size() const override; | 67 virtual IntSize size() const override; |
| 69 IntSize sizeRespectingOrientation() const; | 68 IntSize sizeRespectingOrientation() const; |
| 70 virtual bool getHotSpot(IntPoint&) const override; | 69 virtual bool getHotSpot(IntPoint&) const override; |
| 71 virtual String filenameExtension() const override; | 70 virtual String filenameExtension() const override; |
| 72 virtual bool dataChanged(bool allDataReceived) override; | 71 virtual bool dataChanged(bool allDataReceived) override; |
| 73 | 72 |
| 74 bool isAllDataReceived() const { return m_allDataReceived; } | 73 bool isAllDataReceived() const { return m_allDataReceived; } |
| 75 bool hasColorProfile() const; | 74 bool hasColorProfile() const; |
| 76 | 75 |
| 77 // It may look unusual that there's no start animation call as public API. | 76 // It may look unusual that there's no start animation call as public API. |
| 78 // This because we start and stop animating lazily. Animation starts when | 77 // This because we start and stop animating lazily. Animation starts when |
| 79 // the image is rendered, and automatically pauses once all observers no | 78 // the image is rendered, and automatically pauses once all observers no |
| 80 // longer want to render the image. | 79 // longer want to render the image. |
| 81 virtual void stopAnimation() override; | 80 virtual void stopAnimation() override; |
| 82 virtual void resetAnimation() override; | 81 virtual void resetAnimation() override; |
| 83 virtual bool maybeAnimated() override; | 82 virtual bool maybeAnimated() override; |
| 84 | 83 |
| 85 virtual void setAnimationPolicy(ImageAnimationPolicy policy) override { m_an
imationPolicy = policy; } | 84 virtual void setAnimationPolicy(ImageAnimationPolicy policy) override { m_an
imationPolicy = policy; } |
| 86 virtual ImageAnimationPolicy animationPolicy() override { return m_animation
Policy; } | 85 virtual ImageAnimationPolicy animationPolicy() override { return m_animation
Policy; } |
| 87 | 86 |
| 88 virtual PassRefPtr<NativeImageSkia> nativeImageForCurrentFrame() override; | 87 virtual bool bitmapForCurrentFrame(SkBitmap*) override; |
| 89 virtual PassRefPtr<Image> imageForDefaultFrame() override; | 88 virtual PassRefPtr<Image> imageForDefaultFrame() override; |
| 90 virtual bool currentFrameKnownToBeOpaque() override; | 89 virtual bool currentFrameKnownToBeOpaque() override; |
| 91 ImageOrientation currentFrameOrientation(); | 90 ImageOrientation currentFrameOrientation(); |
| 92 | 91 |
| 93 #if ENABLE(ASSERT) | 92 #if ENABLE(ASSERT) |
| 94 virtual bool notSolidColor() override; | 93 virtual bool notSolidColor() override; |
| 95 #endif | 94 #endif |
| 96 | 95 |
| 97 private: | 96 private: |
| 98 friend class BitmapImageTest; | 97 friend class BitmapImageTest; |
| 99 | 98 |
| 100 void updateSize() const; | 99 void updateSize() const; |
| 101 | 100 |
| 102 private: | 101 private: |
| 103 enum RepetitionCountStatus { | 102 enum RepetitionCountStatus { |
| 104 Unknown, // We haven't checked the source's repetition count. | 103 Unknown, // We haven't checked the source's repetition count. |
| 105 Uncertain, // We have a repetition count, but it might be wrong (some GIF
s have a count after the image data, and will report "loop once" until all data
has been decoded). | 104 Uncertain, // We have a repetition count, but it might be wrong (some GIF
s have a count after the image data, and will report "loop once" until all data
has been decoded). |
| 106 Certain // The repetition count is known to be correct. | 105 Certain // The repetition count is known to be correct. |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 BitmapImage(PassRefPtr<NativeImageSkia>, ImageObserver* = 0); | 108 BitmapImage(const SkBitmap &, ImageObserver* = 0); |
| 110 BitmapImage(ImageObserver* = 0); | 109 BitmapImage(ImageObserver* = 0); |
| 111 | 110 |
| 112 void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRe
ct, SkXfermode::Mode, RespectImageOrientationEnum) override; | 111 void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRe
ct, SkXfermode::Mode, RespectImageOrientationEnum) override; |
| 113 | 112 |
| 114 size_t currentFrame() const { return m_currentFrame; } | 113 size_t currentFrame() const { return m_currentFrame; } |
| 115 size_t frameCount(); | 114 size_t frameCount(); |
| 116 | 115 |
| 117 PassRefPtr<NativeImageSkia> frameAtIndex(size_t); | 116 bool frameAtIndex(size_t, SkBitmap*) WARN_UNUSED_RETURN; |
| 118 | 117 |
| 119 bool frameIsCompleteAtIndex(size_t); | 118 bool frameIsCompleteAtIndex(size_t); |
| 120 float frameDurationAtIndex(size_t); | 119 float frameDurationAtIndex(size_t); |
| 121 bool frameHasAlphaAtIndex(size_t); | 120 bool frameHasAlphaAtIndex(size_t); |
| 122 ImageOrientation frameOrientationAtIndex(size_t); | 121 ImageOrientation frameOrientationAtIndex(size_t); |
| 123 | 122 |
| 124 // Decodes and caches a frame. Never accessed except internally. | 123 // Decodes and caches a frame. Never accessed except internally. |
| 125 void cacheFrame(size_t index); | 124 void cacheFrame(size_t index); |
| 126 | 125 |
| 127 // Called before accessing m_frames[index]. Returns false on index out of bo
unds. | 126 // Called before accessing m_frames[index]. Returns false on index out of bo
unds. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi
rst image frame yet from ImageIO. | 196 bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the fi
rst image frame yet from ImageIO. |
| 198 mutable bool m_hasUniformFrameSize : 1; | 197 mutable bool m_hasUniformFrameSize : 1; |
| 199 mutable bool m_haveFrameCount : 1; | 198 mutable bool m_haveFrameCount : 1; |
| 200 }; | 199 }; |
| 201 | 200 |
| 202 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); | 201 DEFINE_IMAGE_TYPE_CASTS(BitmapImage); |
| 203 | 202 |
| 204 } // namespace blink | 203 } // namespace blink |
| 205 | 204 |
| 206 #endif | 205 #endif |
| OLD | NEW |