|
1 /* |
|
2 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 ImageSource_h |
|
27 #define ImageSource_h |
|
28 |
|
29 #include <wtf/Noncopyable.h> |
|
30 #include <wtf/Vector.h> |
|
31 |
|
32 #if PLATFORM(CG) |
|
33 typedef struct CGImageSource* CGImageSourceRef; |
|
34 typedef struct CGImage* CGImageRef; |
|
35 typedef const struct __CFData* CFDataRef; |
|
36 #elif PLATFORM(QT) |
|
37 class QPixmap; |
|
38 #elif PLATFORM(CAIRO) |
|
39 struct _cairo_surface; |
|
40 typedef struct _cairo_surface cairo_surface_t; |
|
41 #elif PLATFORM(SYMBIAN) |
|
42 #include "PlatformString.h" |
|
43 class CAnimationDecoder; |
|
44 class CMaskedBitmap; |
|
45 #endif |
|
46 |
|
47 namespace WebCore { |
|
48 |
|
49 class IntSize; |
|
50 class SharedBuffer; |
|
51 |
|
52 #if PLATFORM(CG) |
|
53 typedef CGImageSourceRef NativeImageSourcePtr; |
|
54 typedef CGImageRef NativeImagePtr; |
|
55 #elif PLATFORM(QT) |
|
56 class ImageDecoderQt; |
|
57 typedef ImageDecoderQt* NativeImageSourcePtr; |
|
58 typedef QPixmap* NativeImagePtr; |
|
59 #elif PLATFORM(SYMBIAN) |
|
60 typedef CAnimationDecoder* NativeImageSourcePtr; |
|
61 typedef const Vector<char>* NativeBytePtr; |
|
62 typedef CMaskedBitmap* NativeImagePtr; |
|
63 class ImageObserver; |
|
64 #else |
|
65 class ImageDecoder; |
|
66 typedef ImageDecoder* NativeImageSourcePtr; |
|
67 typedef cairo_surface_t* NativeImagePtr; |
|
68 #endif |
|
69 |
|
70 const int cAnimationLoopOnce = -1; |
|
71 const int cAnimationNone = -2; |
|
72 |
|
73 class ImageSource : Noncopyable { |
|
74 public: |
|
75 ImageSource(); |
|
76 ~ImageSource(); |
|
77 |
|
78 void clear(); |
|
79 |
|
80 bool initialized() const; |
|
81 |
|
82 void setData(SharedBuffer* data, bool allDataReceived); |
|
83 |
|
84 bool isSizeAvailable(); |
|
85 IntSize size() const; |
|
86 |
|
87 int repetitionCount(); |
|
88 |
|
89 size_t frameCount() const; |
|
90 |
|
91 NativeImagePtr createFrameAtIndex(size_t); |
|
92 |
|
93 float frameDurationAtIndex(size_t); |
|
94 bool frameHasAlphaAtIndex(size_t); // Whether or not the frame actually used any alpha. |
|
95 bool frameIsCompleteAtIndex(size_t); // Whether or not the frame is completely decoded. |
|
96 |
|
97 #if PLATFORM(SYMBIAN) |
|
98 void setDecoderListener(ImageObserver*); |
|
99 NativeImageSourcePtr decoder() const { return m_decoder; } |
|
100 void setMimeType(const String& mimeType); |
|
101 const String& getMimeType(); |
|
102 #endif |
|
103 private: |
|
104 NativeImageSourcePtr m_decoder; |
|
105 #if PLATFORM(SYMBIAN) |
|
106 String m_mimeType; |
|
107 #endif |
|
108 }; |
|
109 |
|
110 } |
|
111 |
|
112 #endif |