OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #ifndef DeferredImageDecoder_h | 26 #ifndef DeferredImageDecoder_h |
27 #define DeferredImageDecoder_h | 27 #define DeferredImageDecoder_h |
28 | 28 |
29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
30 #include "platform/geometry/IntSize.h" | 30 #include "platform/geometry/IntSize.h" |
31 #include "platform/image-decoders/ImageDecoder.h" | 31 #include "platform/image-decoders/ImageDecoder.h" |
32 #include "third_party/skia/include/core/SkRWBuffer.h" | 32 #include "third_party/skia/include/core/SkRWBuffer.h" |
33 #include "wtf/Allocator.h" | 33 #include "wtf/Allocator.h" |
34 #include "wtf/Forward.h" | 34 #include "wtf/Forward.h" |
| 35 #include "wtf/OwnPtr.h" |
35 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
36 #include <memory> | |
37 | 37 |
38 class SkImage; | 38 class SkImage; |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class ImageFrameGenerator; | 42 class ImageFrameGenerator; |
43 class SharedBuffer; | 43 class SharedBuffer; |
44 struct DeferredFrameData; | 44 struct DeferredFrameData; |
45 | 45 |
46 class PLATFORM_EXPORT DeferredImageDecoder final { | 46 class PLATFORM_EXPORT DeferredImageDecoder final { |
47 WTF_MAKE_NONCOPYABLE(DeferredImageDecoder); | 47 WTF_MAKE_NONCOPYABLE(DeferredImageDecoder); |
48 USING_FAST_MALLOC(DeferredImageDecoder); | 48 USING_FAST_MALLOC(DeferredImageDecoder); |
49 public: | 49 public: |
50 static std::unique_ptr<DeferredImageDecoder> create(const SharedBuffer& data
, ImageDecoder::AlphaOption, ImageDecoder::GammaAndColorProfileOption); | 50 static PassOwnPtr<DeferredImageDecoder> create(const SharedBuffer& data, Ima
geDecoder::AlphaOption, ImageDecoder::GammaAndColorProfileOption); |
51 | 51 |
52 static std::unique_ptr<DeferredImageDecoder> createForTesting(std::unique_pt
r<ImageDecoder>); | 52 static PassOwnPtr<DeferredImageDecoder> createForTesting(PassOwnPtr<ImageDec
oder>); |
53 | 53 |
54 ~DeferredImageDecoder(); | 54 ~DeferredImageDecoder(); |
55 | 55 |
56 String filenameExtension() const; | 56 String filenameExtension() const; |
57 | 57 |
58 PassRefPtr<SkImage> createFrameAtIndex(size_t); | 58 PassRefPtr<SkImage> createFrameAtIndex(size_t); |
59 | 59 |
60 void setData(SharedBuffer& data, bool allDataReceived); | 60 void setData(SharedBuffer& data, bool allDataReceived); |
61 | 61 |
62 bool isSizeAvailable(); | 62 bool isSizeAvailable(); |
63 bool hasColorProfile() const; | 63 bool hasColorProfile() const; |
64 IntSize size() const; | 64 IntSize size() const; |
65 IntSize frameSizeAtIndex(size_t index) const; | 65 IntSize frameSizeAtIndex(size_t index) const; |
66 size_t frameCount(); | 66 size_t frameCount(); |
67 int repetitionCount() const; | 67 int repetitionCount() const; |
68 size_t clearCacheExceptFrame(size_t index); | 68 size_t clearCacheExceptFrame(size_t index); |
69 bool frameHasAlphaAtIndex(size_t index) const; | 69 bool frameHasAlphaAtIndex(size_t index) const; |
70 bool frameIsCompleteAtIndex(size_t index) const; | 70 bool frameIsCompleteAtIndex(size_t index) const; |
71 float frameDurationAtIndex(size_t index) const; | 71 float frameDurationAtIndex(size_t index) const; |
72 size_t frameBytesAtIndex(size_t index) const; | 72 size_t frameBytesAtIndex(size_t index) const; |
73 ImageOrientation orientationAtIndex(size_t index) const; | 73 ImageOrientation orientationAtIndex(size_t index) const; |
74 bool hotSpot(IntPoint&) const; | 74 bool hotSpot(IntPoint&) const; |
75 | 75 |
76 private: | 76 private: |
77 explicit DeferredImageDecoder(std::unique_ptr<ImageDecoder> actualDecoder); | 77 explicit DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecoder); |
78 | 78 |
79 friend class DeferredImageDecoderTest; | 79 friend class DeferredImageDecoderTest; |
80 ImageFrameGenerator* frameGenerator() { return m_frameGenerator.get(); } | 80 ImageFrameGenerator* frameGenerator() { return m_frameGenerator.get(); } |
81 | 81 |
82 void activateLazyDecoding(); | 82 void activateLazyDecoding(); |
83 void prepareLazyDecodedFrames(); | 83 void prepareLazyDecodedFrames(); |
84 | 84 |
85 PassRefPtr<SkImage> createFrameImageAtIndex(size_t index, bool knownToBeOpaq
ue); | 85 PassRefPtr<SkImage> createFrameImageAtIndex(size_t index, bool knownToBeOpaq
ue); |
86 | 86 |
87 // Copy of the data that is passed in, used by deferred decoding. | 87 // Copy of the data that is passed in, used by deferred decoding. |
88 // Allows creating readonly snapshots that may be read in another thread. | 88 // Allows creating readonly snapshots that may be read in another thread. |
89 std::unique_ptr<SkRWBuffer> m_rwBuffer; | 89 OwnPtr<SkRWBuffer> m_rwBuffer; |
90 bool m_allDataReceived; | 90 bool m_allDataReceived; |
91 std::unique_ptr<ImageDecoder> m_actualDecoder; | 91 OwnPtr<ImageDecoder> m_actualDecoder; |
92 | 92 |
93 String m_filenameExtension; | 93 String m_filenameExtension; |
94 IntSize m_size; | 94 IntSize m_size; |
95 int m_repetitionCount; | 95 int m_repetitionCount; |
96 bool m_hasColorProfile; | 96 bool m_hasColorProfile; |
97 bool m_canYUVDecode; | 97 bool m_canYUVDecode; |
98 bool m_hasHotSpot; | 98 bool m_hasHotSpot; |
99 IntPoint m_hotSpot; | 99 IntPoint m_hotSpot; |
100 | 100 |
101 // Caches frame state information. | 101 // Caches frame state information. |
102 Vector<DeferredFrameData> m_frameData; | 102 Vector<DeferredFrameData> m_frameData; |
103 RefPtr<ImageFrameGenerator> m_frameGenerator; | 103 RefPtr<ImageFrameGenerator> m_frameGenerator; |
104 }; | 104 }; |
105 | 105 |
106 } // namespace blink | 106 } // namespace blink |
107 | 107 |
108 #endif | 108 #endif |
OLD | NEW |