62 CleanupStack::PopAndDestroy(2); |
61 CleanupStack::PopAndDestroy(2); |
63 } |
62 } |
64 |
63 |
65 TBool BmpUtils::BitmpIsSame(const CFbsBitmap* aDesBmp, const CFbsBitmap* aSrcBmp) |
64 TBool BmpUtils::BitmpIsSame(const CFbsBitmap* aDesBmp, const CFbsBitmap* aSrcBmp) |
66 { |
65 { |
67 if(!aDesBmp || !aSrcBmp) return FALSE; |
66 if(!aDesBmp || !aSrcBmp) return EFalse; |
68 |
67 |
69 if(aDesBmp->SizeInPixels() == aSrcBmp->SizeInPixels()) |
68 if(aDesBmp->SizeInPixels() == aSrcBmp->SizeInPixels()) |
70 { |
69 { |
71 TSize size(aSrcBmp->SizeInPixels()); |
70 TSize size(aSrcBmp->SizeInPixels()); |
72 TInt scanLineLength = CFbsBitmap::ScanLineLength(size.iWidth, aSrcBmp->DisplayMode()); |
71 TInt scanLineLength = CFbsBitmap::ScanLineLength(size.iWidth, aSrcBmp->DisplayMode()); |
73 TInt length = scanLineLength*size.iHeight; |
72 TInt length = scanLineLength*size.iHeight; |
74 |
73 |
75 aDesBmp->BeginDataAccess(); |
74 aDesBmp->BeginDataAccess(); |
76 aSrcBmp->BeginDataAccess(); |
75 aSrcBmp->BeginDataAccess(); |
77 TInt result = Mem::Compare((TUint8*)aDesBmp->DataAddress(), length, (TUint8*)aSrcBmp->DataAddress(), length); |
76 TInt result = Mem::Compare((TUint8*)aDesBmp->DataAddress(), length, (TUint8*)aSrcBmp->DataAddress(), length); |
78 aSrcBmp->EndDataAccess(TRUE); |
77 aSrcBmp->EndDataAccess(ETrue); |
79 aDesBmp->EndDataAccess(TRUE); |
78 aDesBmp->EndDataAccess(ETrue); |
80 |
79 |
81 if(result == KErrNone) return TRUE; |
80 if(result == KErrNone) return ETrue; |
82 } |
81 } |
83 |
82 |
84 return FALSE; |
83 return EFalse; |
85 } |
84 } |
86 |
85 |
87 |
86 |
88 /////////////////////////////////////////////////////////////////////////////////////////////// |
87 /////////////////////////////////////////////////////////////////////////////////////////////// |
89 // SmileyUtils |
88 // SmileyUtils |
177 return iFrameMask; |
185 return iFrameMask; |
178 } |
186 } |
179 |
187 |
180 void CSmileyImage::BitmapChanged(CFbsBitmap* aBitmap) |
188 void CSmileyImage::BitmapChanged(CFbsBitmap* aBitmap) |
181 { |
189 { |
182 iReadyToDraw = TRUE; // animation is ready |
190 iReadyToDraw = ETrue; // animation is ready |
183 |
191 |
184 if(iImageObserver) iImageObserver->BitmapChanged(this, aBitmap); |
192 if(iImageObserver) iImageObserver->BitmapChanged(this, aBitmap); |
185 |
193 |
186 TRAP_IGNORE(MonitorAnimationEndedL()); |
194 TRAP_IGNORE(MonitorAnimationEndedL()); |
187 } |
195 } |
188 |
196 |
|
197 void CSmileyImage::MonitorAnimationEndedL() |
|
198 { |
|
199 // for animation doesn't call back |
|
200 StopAnimationAsynchronousL(KFrameMaxInterval); |
|
201 |
|
202 // for reduce the times of animation monitor |
|
203 iFrameCounter++; |
|
204 if(iFrameCounter % KFrameMonitorStep) return; |
|
205 |
|
206 // for not call back any more |
|
207 StopAnimationAsynchronousL(KFrameMaxInterval); |
|
208 |
|
209 // monitor the end of animation clip, replay or stop animation if ended |
|
210 if(BmpUtils::BitmpIsSame(iFrameSnap, iFrame)) |
|
211 { |
|
212 iSameFrameCounter++; |
|
213 if(iSameFrameCounter > KMaxSameFrameRepeat) |
|
214 { |
|
215 StopAnimationAsynchronousL(); // can not stop animation synchronously |
|
216 } |
|
217 } |
|
218 else |
|
219 { |
|
220 iSameFrameCounter = 0; |
|
221 BmpUtils::CopyBitmpL(iFrameSnap, iFrame); |
|
222 } |
|
223 } |
|
224 |
189 void CSmileyImage::DoLoadL() |
225 void CSmileyImage::DoLoadL() |
190 { |
226 { |
191 StopAnyAsynchronousTask(); |
227 StopAsynchronousTaskTimer(); |
192 |
228 |
193 if(iFrame) return; |
229 if(iFrame) return; |
194 |
230 |
195 TFileName smileyMifName; |
231 TFileName smileyMifName; |
196 SmileyUtils::GetCustomizableResPath(smileyMifName, KSmileyMif); |
232 SmileyUtils::GetCustomizableResPath(smileyMifName, KSmileyMif); |
197 if(iImageSkinItem.iMinor > 0) |
233 |
|
234 if(iImageSkinItemId.iMinor > 0) |
198 { |
235 { |
199 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
236 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
200 TRAP_IGNORE( AknsUtils::CreateColorIconL(skin, iImageSkinItem, |
237 TRAPD(err, AknsUtils::CreateColorIconL(skin, iImageSkinItemId, |
201 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19, |
238 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19, |
202 iFrame, iFrameMask, |
239 iFrame, iFrameMask, |
203 smileyMifName, iImagePkgItem, iImagePkgItem, |
240 smileyMifName, iImageMifPkgItemId, iImageMifPkgItemId, |
204 AKN_LAF_COLOR(215))); |
241 AKN_LAF_COLOR(215))); |
205 } |
242 } |
206 else |
243 else |
207 { |
244 { |
208 TRAP_IGNORE( AknIconUtils::CreateIconL(iFrame, iFrameMask, smileyMifName, iImagePkgItem, iImagePkgItem)); |
245 TRAPD(err, AknIconUtils::CreateIconL(iFrame, iFrameMask, smileyMifName, iImageMifPkgItemId, iImageMifPkgItemId)); |
209 } |
246 } |
210 |
247 |
211 if(iIsAnimation) // the first frame of animation svg is blank without correct content |
248 if(iIsAnimation) // the first frame of animation svg is blank without correct content |
212 { |
249 { |
213 iReadyToDraw = FALSE; |
250 iReadyToDraw = EFalse; |
214 AknIconUtils::SetObserver(iFrame, this); |
251 AknIconUtils::SetObserver(iFrame, this); |
215 |
252 StopAnimationAsynchronousL(KFrameMaxInterval); // monitor for no callback |
216 StopAnimationAsynchronousL(KFrameMaxInterval); |
|
217 } |
253 } |
218 else // the first frame of static svg has correct content |
254 else // the first frame of static svg has correct content |
219 { |
255 { |
220 iReadyToDraw = TRUE; |
256 iReadyToDraw = ETrue; |
221 if(iImageObserver) iImageObserver->BitmapChanged(this, iFrame); |
257 if(iImageObserver) iImageObserver->BitmapChanged(this, iFrame); |
222 } |
258 } |
223 |
259 |
224 AknIconUtils::SetSize(iFrame, iSize); |
260 AknIconUtils::SetSize(iFrame, iSize); |
|
261 TUid i = iFrame->ExtendedBitmapType(); |
225 } |
262 } |
226 |
263 |
227 void CSmileyImage::DoRelease() |
264 void CSmileyImage::DoRelease() |
228 { |
265 { |
229 StopAnyAsynchronousTask(); |
266 StopAsynchronousTaskTimer(); |
230 |
267 |
231 if(!iFrame) return; |
268 if(!iFrame) return; |
232 |
269 |
233 DELZ(iFrame); |
270 DELZ(iFrame); |
234 DELZ(iFrameMask); |
271 DELZ(iFrameMask); |
235 iFrameSnap->Reset(); |
272 iFrameSnap->Reset(); |
236 |
273 |
237 iReadyToDraw = FALSE; |
274 iReadyToDraw = EFalse; |
238 } |
275 } |
239 |
276 |
240 void CSmileyImage::StopAnyAsynchronousTask() |
277 void CSmileyImage::DoHandleEndedL() |
241 { |
|
242 iAsynchronousTaskTimer->Cancel(); |
|
243 } |
|
244 |
|
245 void CSmileyImage::MonitorAnimationEndedL() |
|
246 { |
|
247 // for animation doesn't call back |
|
248 StopAnimationAsynchronousL(KFrameMaxInterval); |
|
249 |
|
250 // for reduce the times of animation monitor |
|
251 iFrameCounter++; |
|
252 if(iFrameCounter % KFrameMonitorStep) return; |
|
253 |
|
254 // monitor the end of animation clip, replay or stop animation if ended |
|
255 if(BmpUtils::BitmpIsSame(iFrameSnap, iFrame)) |
|
256 { |
|
257 iSameFrameCounter++; |
|
258 if(iSameFrameCounter > KMaxSameFrameRepeat) |
|
259 { |
|
260 StopAnimationAsynchronousL(); |
|
261 } |
|
262 } |
|
263 else |
|
264 { |
|
265 iSameFrameCounter = 0; |
|
266 BmpUtils::CopyBitmpL(iFrameSnap, iFrame); |
|
267 } |
|
268 } |
|
269 |
|
270 void CSmileyImage::HandleAnimationEndedL() |
|
271 { |
278 { |
272 DoRelease(); |
279 DoRelease(); |
273 |
280 |
274 if(iRepeatCount != 0) |
281 if(iRepeatCount != 0) |
275 { |
282 { |
276 iRepeatCount--; |
283 iRepeatCount--; |
277 DoLoadL(); |
284 DoLoadL(); |
278 } |
285 } |
279 } |
286 } |
280 |
287 |
281 void CSmileyImage::StartLoadAsynchronousL(TInt aRepeat, TInt aDelayMicroSeconds) |
288 void CSmileyImage::StopAsynchronousTaskTimer() |
282 { |
289 { |
283 iRepeatCount = aRepeat; |
|
284 |
|
285 iAsynchronousTaskTimer->Cancel(); |
290 iAsynchronousTaskTimer->Cancel(); |
|
291 } |
|
292 |
|
293 void CSmileyImage::StartLoadAsynchronousL(TInt aDelayMicroSeconds) |
|
294 { |
|
295 StopAsynchronousTaskTimer(); |
286 iAsynchronousTaskTimer->Start(aDelayMicroSeconds, 1, TCallBack(StartLoadAsynchronousCallBackL,this)); |
296 iAsynchronousTaskTimer->Start(aDelayMicroSeconds, 1, TCallBack(StartLoadAsynchronousCallBackL,this)); |
287 } |
297 } |
288 |
298 |
289 TInt CSmileyImage::StartLoadAsynchronousCallBackL(TAny* aPtr) |
299 TInt CSmileyImage::StartLoadAsynchronousCallBackL(TAny* aPtr) |
290 { |
300 { |
291 CSmileyImage* self = (CSmileyImage*)aPtr; |
301 CSmileyImage* self = (CSmileyImage*)aPtr; |
292 self->StopAnyAsynchronousTask(); |
302 self->StopAsynchronousTaskTimer(); |
293 self->DoLoadL(); |
303 self->DoLoadL(); |
294 return KErrNone; |
304 return KErrNone; |
295 } |
305 } |
296 |
306 |
297 void CSmileyImage::StopAnimationAsynchronousL(TInt aDelayMicroSeconds) |
307 void CSmileyImage::StopAnimationAsynchronousL(TInt aDelayMicroSeconds) |
298 { |
308 { |
299 iAsynchronousTaskTimer->Cancel(); |
309 StopAsynchronousTaskTimer(); |
300 iAsynchronousTaskTimer->Start(aDelayMicroSeconds, 1, TCallBack(StopAnimationAsynchronousCallBackL,this)); |
310 iAsynchronousTaskTimer->Start(aDelayMicroSeconds, 1, TCallBack(StopAnimationAsynchronousCallBackL,this)); |
301 } |
311 } |
302 |
312 |
303 TInt CSmileyImage::StopAnimationAsynchronousCallBackL(TAny* aPtr) |
313 TInt CSmileyImage::StopAnimationAsynchronousCallBackL(TAny* aPtr) |
304 { |
314 { |
305 CSmileyImage* self = (CSmileyImage*)aPtr; |
315 CSmileyImage* self = (CSmileyImage*)aPtr; |
306 self->StopAnyAsynchronousTask(); |
316 self->StopAsynchronousTaskTimer(); |
307 self->HandleAnimationEndedL(); |
317 self->DoHandleEndedL(); |
308 return KErrNone; |
318 return KErrNone; |
309 } |
319 } |
310 |
320 |
311 |
321 |
312 // end of file |
322 // end of file |