OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 #ifndef DeferredImageDecoder_h | |
27 #define DeferredImageDecoder_h | |
28 | |
29 #include "SkBitmap.h" | |
30 #include "core/platform/graphics/ImageSource.h" | |
31 #include "core/platform/image-decoders/ImageDecoder.h" | |
32 #include "platform/geometry/IntSize.h" | |
33 #include "wtf/Forward.h" | |
34 #include "wtf/OwnPtr.h" | |
35 #include "wtf/Vector.h" | |
36 | |
37 namespace WebCore { | |
38 | |
39 class ImageFrameGenerator; | |
40 class SharedBuffer; | |
41 | |
42 class DeferredImageDecoder { | |
43 public: | |
44 ~DeferredImageDecoder(); | |
45 static PassOwnPtr<DeferredImageDecoder> create(const SharedBuffer& data, Ima
geSource::AlphaOption, ImageSource::GammaAndColorProfileOption); | |
46 | |
47 static PassOwnPtr<DeferredImageDecoder> createForTesting(PassOwnPtr<ImageDec
oder>); | |
48 | |
49 static bool isLazyDecoded(const SkBitmap&); | |
50 | |
51 static void setEnabled(bool); | |
52 | |
53 String filenameExtension() const; | |
54 | |
55 ImageFrame* frameBufferAtIndex(size_t index); | |
56 | |
57 void setData(SharedBuffer* data, bool allDataReceived); | |
58 | |
59 bool isSizeAvailable(); | |
60 IntSize size() const; | |
61 IntSize frameSizeAtIndex(size_t index) const; | |
62 size_t frameCount(); | |
63 int repetitionCount() const; | |
64 size_t clearCacheExceptFrame(size_t); | |
65 bool frameHasAlphaAtIndex(size_t index) const; | |
66 bool frameIsCompleteAtIndex(size_t) const; | |
67 float frameDurationAtIndex(size_t) const; | |
68 unsigned frameBytesAtIndex(size_t index) const; | |
69 ImageOrientation orientation() const; | |
70 bool hotSpot(IntPoint&) const; | |
71 | |
72 // For testing. | |
73 ImageFrameGenerator* frameGenerator() { return m_frameGenerator.get(); } | |
74 | |
75 private: | |
76 explicit DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecoder); | |
77 void prepareLazyDecodedFrames(); | |
78 SkBitmap createLazyDecodingBitmap(size_t index); | |
79 void activateLazyDecoding(); | |
80 void setData(PassRefPtr<SharedBuffer>, bool allDataReceived); | |
81 | |
82 RefPtr<SharedBuffer> m_data; | |
83 bool m_allDataReceived; | |
84 OwnPtr<ImageDecoder> m_actualDecoder; | |
85 | |
86 String m_filenameExtension; | |
87 IntSize m_size; | |
88 ImageOrientation m_orientation; | |
89 int m_repetitionCount; | |
90 | |
91 Vector<OwnPtr<ImageFrame> > m_lazyDecodedFrames; | |
92 RefPtr<ImageFrameGenerator> m_frameGenerator; | |
93 | |
94 static bool s_enabled; | |
95 }; | |
96 | |
97 } // namespace WebCore | |
98 | |
99 #endif | |
OLD | NEW |