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