9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 #ifndef ANIMATIONDECODER_H |
19 #ifndef ANIMATIONDECODER_H |
20 #define ANIMATIONDECODER_H |
20 #define ANIMATIONDECODER_H |
21 |
21 |
22 // INCLUDES |
22 // INCLUDES |
23 |
23 #include "AnimationDecoderWrapped.h" |
24 #include <e32base.h> |
|
25 #include <imageconversion.h> // TFrameInfo |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CMaskedBitmap; |
|
29 class CBufferedImageDecoder; |
|
30 class CSynDecodeThread; |
|
31 namespace WebCore { |
|
32 class ImageObserver; |
|
33 } |
|
34 // CONSTANTS |
|
35 |
|
36 _LIT(KMimeJPEG, "image/jpeg"); |
|
37 _LIT(KMimeJPG, "image/jpg"); |
|
38 _LIT(KMimeGIF, "image/gif"); |
|
39 _LIT(KMimePNG, "image/png"); |
|
40 _LIT(KMimeTIFF, "image/tiff"); |
|
41 _LIT(KMimeBMP, "image/bmp"); |
|
42 _LIT(KMimeWBMP, "image/vnd.wap.wbmp"); |
|
43 _LIT(KMimeWMF, "application/x-msmetafile"); |
|
44 _LIT(KMimeMBM, "image/x-epoc-mbm"); |
|
45 _LIT(KMimeOTA, "image/vnd.nokia.ota-bitmap"); |
|
46 _LIT(KMimeICO, "image/x-icon"); |
|
47 _LIT(KMimeDRM, "application/vnd.oma.drm.content"); |
|
48 |
|
49 //const TDisplayMode KMaxDepth = EColor64K; |
|
50 |
|
51 // FIXME: we should move this back to EColor64K after Symbian fix their Gif image decoder bug. |
|
52 const TDisplayMode KMaxDepth = EColor16M; |
|
53 |
24 |
54 // CLASS DECLARATION |
25 // CLASS DECLARATION |
55 /** |
26 /** |
56 * CAnimationDecoder |
27 * CAnimationDecoder |
57 * |
28 * |
58 * Implementation of file based image class. |
29 * Proxy for implementation of file based image class. |
59 * @lib IHL.lib |
30 * @lib IHL.lib |
60 * @since 3.0 |
31 * @since 3.0 |
|
32 * |
|
33 * This class is a proxy for CAnimationDecoderWrapped |
|
34 * |
|
35 * We needed to wrap animation decoding in a proxy because sometimes the cache gets cleared when decoding |
|
36 * is in progress; when that happens the animation gets deleted while it's in the middle (which causes all sorts |
|
37 * of crashes and memory stomping). Now, the cache can delete the proxy while the animation is decoding; the proxy |
|
38 * will pass on the delete request to the decoder which will cleanup (delete itself) when it's safe to do so. |
61 */ |
39 */ |
62 |
40 |
63 class CAnimationDecoder : public CActive |
41 class CAnimationDecoder |
64 { |
42 { |
65 public: // Constructors and destructor |
43 public: // Constructors and destructor |
66 |
44 |
67 /** |
45 /** |
68 * Two-phased constructor. |
46 * Two-phased constructor. |
78 |
56 |
79 /* |
57 /* |
80 * From MIHLFileImage, see base class header. |
58 * From MIHLFileImage, see base class header. |
81 */ |
59 */ |
82 void OpenL( const TDesC8& aData, TDesC* aMIMEType, TBool aIsComplete ); |
60 void OpenL( const TDesC8& aData, TDesC* aMIMEType, TBool aIsComplete ); |
83 void OpenAndDecodeSyncL( const TDesC8& aData ); |
|
84 |
61 |
85 /* |
62 /* |
86 * From MIHLFileImage, see base class header. |
63 * From MIHLFileImage, see base class header. |
87 */ |
64 */ |
88 void AddDataL( const TDesC8& aData, TBool aIsComplete ); |
65 TSize Size() const; |
89 |
66 |
90 /* |
67 /* |
91 * From MIHLFileImage, see base class header. |
68 * From MIHLFileImage, see base class header. |
92 */ |
69 */ |
93 TSize Size() const { return iFrameInfo.iOverallSizeInPixels; } |
70 TInt AnimationFrameCount() const; |
94 |
|
95 /* |
|
96 * From MIHLFileImage, see base class header. |
|
97 */ |
|
98 TDisplayMode DisplayMode() const { return KMaxDepth; } |
|
99 |
|
100 /* |
|
101 * From MIHLFileImage, see base class header. |
|
102 */ |
|
103 TDisplayMode MaskDisplayMode() const; |
|
104 |
|
105 /* |
|
106 * From MIHLFileImage, see base class header. |
|
107 */ |
|
108 TRgb BackgroundColor() const { return iFrameInfo.iBackgroundColor; } |
|
109 |
|
110 /* |
|
111 * From MIHLFileImage, see base class header. |
|
112 */ |
|
113 TBool IsAnimation() const { return iAnimation; } |
|
114 |
|
115 /* |
|
116 * From MIHLFileImage, see base class header. |
|
117 */ |
|
118 TInt AnimationFrameCount() const { return iAnimationFrameCount; } |
|
119 |
|
120 /* |
|
121 * From MIHLFileImage, see base class header. |
|
122 */ |
|
123 TTimeIntervalMicroSeconds32 AnimationFrameDelay( TInt aAnimationFrameIndex ) const; |
|
124 |
|
125 /* |
71 /* |
126 * From MIHLFileImage, see base class header. |
72 * From MIHLFileImage, see base class header. |
127 */ |
73 */ |
128 TInt LoadFrame( TInt aFrameIndex ); |
74 TInt LoadFrame( TInt aFrameIndex ); |
129 |
75 |
130 /* |
|
131 * From MIHLFileImage, see base class header. |
|
132 */ |
|
133 TBool IsBusy() const { return ( iImageState != EInactive ); } |
|
134 |
|
135 |
|
136 /* |
|
137 * From MIHLFileImage, see base class header. |
|
138 */ |
|
139 void CancelLoad() { Cancel(); } |
|
140 |
|
141 TBool IsOpen() const { return iDecoder!=0; } |
|
142 |
|
143 //funtions related to Loop count of animation image. |
76 //funtions related to Loop count of animation image. |
144 TInt16 getLoopCount(){return iCurLoopCount;}; |
77 TInt16 getLoopCount(); |
145 void resetLoopCount(){iCurLoopCount = iLoopCount;}; |
|
146 void decreamentLoopCount(){ iCurLoopCount--;}; |
|
147 CMaskedBitmap* Destination(); |
78 CMaskedBitmap* Destination(); |
148 TBool isSizeAvailable() const { return iSizeAvailable; } |
79 TBool isSizeAvailable() const; |
149 TBool decodeInProgress() const { return iDecodeInProgress; } |
80 TBool decodeInProgress() const; |
150 |
|
151 private: // From base class CActive |
|
152 |
|
153 /* |
|
154 * From CActive, see base class header. |
|
155 */ |
|
156 void DoCancel(); |
|
157 |
|
158 /* |
|
159 * From CActive, see base class header. |
|
160 */ |
|
161 void RunL(); |
|
162 |
|
163 /* |
|
164 * From CActive, see base class header. |
|
165 */ |
|
166 TInt RunError( TInt aError ); |
|
167 |
|
168 private: // Private methods |
|
169 |
|
170 void StartDecodingL(); |
|
171 void StartLoadL(); |
|
172 void StartLoadNormalBitmap( TInt aFrameIndex ); |
|
173 void StartLoadAnimationBitmapL( TInt aFrameIndex ); |
|
174 void CompleteLoadL(); |
|
175 void BuildAnimationFrameL(); |
|
176 void ErrorCleanup(); |
|
177 void SelfComplete( TInt aError = KErrNone ); |
|
178 HBufC8* DecodeDRMImageContentL(const TDesC8& aData); |
|
179 |
81 |
180 private: // Private constructors |
82 private: // Private constructors |
181 |
83 |
182 CAnimationDecoder(WebCore::ImageObserver* aObs); |
84 CAnimationDecoder(CAnimationDecoderWrapped *aDecoder); |
183 void ConstructL( ); |
85 void ConstructL( ); |
184 |
86 |
185 private: // Private data types |
|
186 |
|
187 enum TImageState |
|
188 { |
|
189 EInactive, |
|
190 EStartLoad, |
|
191 ECompleteLoad, |
|
192 }; |
|
193 |
|
194 private: // Data |
87 private: // Data |
195 |
88 CAnimationDecoderWrapped *iWrapped; |
196 // Image status & state |
|
197 TRequestStatus* iImageStatus; |
|
198 TImageState iImageState; |
|
199 |
|
200 // Own: Image decoder |
|
201 CBufferedImageDecoder* iDecoder; // owned |
|
202 |
|
203 TFrameInfo iFrameInfo; |
|
204 TBool iAnimation; |
|
205 TInt iAnimationFrameCount; |
|
206 |
|
207 // Ref: Destination bitmap |
|
208 CMaskedBitmap* iDestination; |
|
209 TInt iFrameIndex; |
|
210 |
|
211 // Own: Temporary animation bitmap |
|
212 CMaskedBitmap* iAnimationBitmap; // owned |
|
213 TInt iAnimationFrameIndex; |
|
214 |
|
215 WebCore::ImageObserver* iObserver; // not owned |
|
216 |
|
217 TBool iRawDataComplete; |
|
218 |
|
219 //Loop count for animation image. Default to -1 -- loop forever |
|
220 TInt16 iLoopCount; |
|
221 TInt16 iCurLoopCount; |
|
222 |
|
223 TBool iSizeAvailable; |
|
224 TInt iSyncBitmapHandle; |
|
225 TBool iSyncMaskHandle; |
|
226 TBool iDecodeInProgress; |
|
227 static CSynDecodeThread* iSyncDecodeThread; // sync decoder thread |
|
228 HBufC8* iDrmContent; |
|
229 }; |
89 }; |
230 |
90 |
231 #endif // CAnimationDecoder_H |
91 #endif // CAnimationDecoder_H |
232 |
92 |
233 // End of File |
93 // End of File |