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 10 matching lines...) Expand all Loading... |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #ifndef FrameData_h | 28 #ifndef FrameData_h |
29 #define FrameData_h | 29 #define FrameData_h |
30 | 30 |
| 31 #include "platform/graphics/ColorSpaceFilter.h" |
31 #include "platform/graphics/ImageOrientation.h" | 32 #include "platform/graphics/ImageOrientation.h" |
| 33 #include "third_party/skia/include/core/SkColorFilter.h" |
32 #include "third_party/skia/include/core/SkImage.h" | 34 #include "third_party/skia/include/core/SkImage.h" |
| 35 #include "third_party/skia/include/core/SkPicture.h" |
33 #include "wtf/Allocator.h" | 36 #include "wtf/Allocator.h" |
| 37 #include "wtf/HashMap.h" |
| 38 #include "wtf/MainThread.h" |
34 #include "wtf/Noncopyable.h" | 39 #include "wtf/Noncopyable.h" |
35 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
36 #include "wtf/VectorTraits.h" | 41 #include "wtf/VectorTraits.h" |
| 42 #include "wtf/text/StringHash.h" |
| 43 #include "wtf/text/WTFString.h" |
| 44 |
| 45 class ColorTransformImageCache { |
| 46 WTF_MAKE_NONCOPYABLE(ColorTransformImageCache); |
| 47 public: |
| 48 ColorTransformImageCache() { } |
| 49 |
| 50 void set(const String& key, SkImage* image) |
| 51 { |
| 52 m_colorImages.set(key, image); |
| 53 } |
| 54 |
| 55 PassRefPtr<SkImage> find(const String& key) const |
| 56 { |
| 57 HashMap<String, RefPtr<SkImage>>::const_iterator it = m_colorImages.find
(key); |
| 58 return it != m_colorImages.end() ? it->value : nullptr; |
| 59 } |
| 60 |
| 61 void clear() |
| 62 { |
| 63 m_colorImages.clear(); |
| 64 } |
| 65 |
| 66 private: |
| 67 HashMap<String, RefPtr<SkImage>> m_colorImages; |
| 68 }; |
37 | 69 |
38 namespace blink { | 70 namespace blink { |
39 | 71 |
40 struct FrameData { | 72 struct FrameData { |
41 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 73 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
42 WTF_MAKE_NONCOPYABLE(FrameData); | 74 WTF_MAKE_NONCOPYABLE(FrameData); |
43 public: | 75 public: |
44 FrameData(); | 76 FrameData(); |
45 ~FrameData(); | 77 ~FrameData(); |
46 | 78 |
| 79 PassRefPtr<SkImage> find(SkColorFilter* transform) |
| 80 { |
| 81 return cache().find(colorSpaceFilterKey(transform)); |
| 82 } |
| 83 |
| 84 void cache(SkColorFilter* transform, SkImage* image) |
| 85 { |
| 86 cache().set(colorSpaceFilterKey(transform), image); |
| 87 } |
| 88 |
| 89 ColorTransformImageCache& cache() |
| 90 { |
| 91 RELEASE_ASSERT(isMainThread()); |
| 92 return m_cache; |
| 93 } |
| 94 |
47 // Clear the cached image data on the frame, and (optionally) the metadata. | 95 // Clear the cached image data on the frame, and (optionally) the metadata. |
48 // Returns whether there was cached image data to clear. | 96 // Returns whether there was cached image data to clear. |
49 bool clear(bool clearMetadata); | 97 bool clear(bool clearMetadata); |
50 | 98 |
51 RefPtr<SkImage> m_frame; | 99 RefPtr<SkImage> m_frame; |
| 100 ColorTransformImageCache m_cache; |
52 ImageOrientation m_orientation; | 101 ImageOrientation m_orientation; |
53 float m_duration; | 102 float m_duration; |
54 bool m_haveMetadata : 1; | 103 bool m_haveMetadata : 1; |
55 bool m_isComplete : 1; | 104 bool m_isComplete : 1; |
56 bool m_hasAlpha : 1; | 105 bool m_hasAlpha : 1; |
57 size_t m_frameBytes; | 106 size_t m_frameBytes; |
58 }; | 107 }; |
59 | 108 |
60 } // namespace blink | 109 } // namespace blink |
61 | 110 |
62 namespace WTF { | 111 namespace WTF { |
63 template<> struct VectorTraits<blink::FrameData> : public SimpleClassVectorTrait
s<blink::FrameData> { | 112 template<> struct VectorTraits<blink::FrameData> : public SimpleClassVectorTrait
s<blink::FrameData> { |
64 STATIC_ONLY(VectorTraits); | 113 STATIC_ONLY(VectorTraits); |
65 static const bool canInitializeWithMemset = false; // Not all FrameData memb
ers initialize to 0. | 114 static const bool canInitializeWithMemset = false; // Not all FrameData memb
ers initialize to 0. |
66 }; | 115 }; |
67 } | 116 } |
68 | 117 |
69 #endif // FrameData_h | 118 #endif // FrameData_h |
OLD | NEW |