author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:19:17 +0300 | |
branch | RCL_3 |
changeset 64 | 34937ec34dac |
parent 60 | 5b3385a43d68 |
child 75 | 01504893d9cb |
permissions | -rw-r--r-- |
60 | 1 |
/* |
2 |
* Copyright (c) 2008-2009 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 "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: DRM Gif Texture creator implementation |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <e32math.h> |
|
19 |
#include <imageconversion.h> |
|
20 |
#include <glxtracer.h> |
|
21 |
#include <glxlog.h> |
|
22 |
#include <alf/ialfwidgeteventhandler.h> // The interface for event handlers used by widget controls |
|
23 |
#include <mul/imulmodel.h> // An interface for the data model |
|
24 |
#include <alf/alfutil.h> // AlfUtil |
|
25 |
#include <glxmedia.h> |
|
26 |
||
27 |
#include "glxtexturemanager.h" |
|
28 |
#include "glxbinding.h" |
|
29 |
#include "glxuiutility.h" |
|
30 |
#include "glxdrmgiftexturecreator.h" |
|
31 |
#include "glxdrmgifactivedecoder.h" |
|
32 |
||
33 |
// Default frame interval for animation, in microseconds |
|
34 |
const TInt KDefaultFrameInterval = 100000; |
|
35 |
||
36 |
// ----------------------------------------------------------------------------- |
|
37 |
// NewLC |
|
38 |
// ----------------------------------------------------------------------------- |
|
39 |
CGlxDrmGifTextureCreator* CGlxDrmGifTextureCreator::NewL( |
|
40 |
const CGlxBinding& aBinding, const TGlxMedia& aMedia, |
|
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
41 |
TInt aItemIndex, Alf::IMulModel* aModel, MGlxMediaList& aMediaList) |
60 | 42 |
{ |
43 |
TRACER("CGlxDrmGifTextureCreator* CGlxDrmGifTextureCreator::NewL()"); |
|
44 |
CGlxDrmGifTextureCreator* self = new (ELeave) CGlxDrmGifTextureCreator( |
|
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
45 |
aBinding, aMedia, aItemIndex, aModel, aMediaList); |
60 | 46 |
CleanupStack::PushL(self); |
47 |
self->ConstructL(); |
|
48 |
CleanupStack::Pop(self); |
|
49 |
return self; |
|
50 |
} |
|
51 |
||
52 |
// ----------------------------------------------------------------------------- |
|
53 |
// Destructor |
|
54 |
// ----------------------------------------------------------------------------- |
|
55 |
CGlxDrmGifTextureCreator::~CGlxDrmGifTextureCreator() |
|
56 |
{ |
|
57 |
TRACER("CGlxDrmGifTextureCreator::~CGlxDrmGifTextureCreator()"); |
|
58 |
ReleaseContent(); |
|
59 |
||
60 |
// Delete the animation timer |
|
61 |
if (iAnimationTimer) |
|
62 |
{ |
|
63 |
iAnimationTimer->Cancel(); |
|
64 |
delete iAnimationTimer; |
|
65 |
} |
|
66 |
||
67 |
iUiUtility->Close(); |
|
68 |
||
69 |
delete iGlxDecoderAO; |
|
70 |
||
71 |
iFsSession.Close(); |
|
72 |
} |
|
73 |
||
74 |
// ----------------------------------------------------------------------------- |
|
75 |
// ReleaseContent |
|
76 |
// ----------------------------------------------------------------------------- |
|
77 |
void CGlxDrmGifTextureCreator::ReleaseContent() |
|
78 |
{ |
|
79 |
TRACER("void CGlxDrmGifTextureCreator::ReleaseContent()"); |
|
80 |
iBitmapReady = EFalse; |
|
81 |
iAnimCount = 0; |
|
82 |
iAnimateFlag = EFalse; |
|
83 |
iTransparencyPossible = EFalse; |
|
84 |
iFrameShift = EFalse; |
|
85 |
||
86 |
if (iGlxDecoderAO) |
|
87 |
{ |
|
88 |
iGlxDecoderAO->Cancel(); |
|
89 |
} |
|
90 |
||
91 |
if (iAnimationTimer) |
|
92 |
{ |
|
93 |
iAnimationTimer->Cancel(); |
|
94 |
} |
|
95 |
||
96 |
for (TInt i = 0; i < iFrameCount; i++) |
|
97 |
{ |
|
98 |
GLX_LOG_INFO1("DrmGif: ReleaseContent() Releasing AnimBitmaps %d", i); |
|
99 |
delete (iDecodedBitmap[i]); |
|
100 |
iDecodedBitmap[i] = NULL; |
|
101 |
delete (iDecodedMask[i]); |
|
102 |
iDecodedMask[i] = NULL; |
|
103 |
} |
|
104 |
||
105 |
if (iUiUtility && iMedia) |
|
106 |
{ |
|
107 |
iUiUtility->GlxTextureManager().RemoveTexture(iMedia->Id()); |
|
108 |
} |
|
109 |
||
110 |
if (iImageDecoder) |
|
111 |
{ |
|
112 |
delete iImageDecoder; |
|
113 |
iImageDecoder = NULL; |
|
114 |
} |
|
115 |
} |
|
116 |
||
117 |
// ----------------------------------------------------------------------------- |
|
118 |
// Constructor |
|
119 |
// ----------------------------------------------------------------------------- |
|
120 |
CGlxDrmGifTextureCreator::CGlxDrmGifTextureCreator( |
|
121 |
const CGlxBinding& aBinding, const TGlxMedia& aMedia, |
|
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
122 |
TInt aItemIndex, Alf::IMulModel* aModel, MGlxMediaList& aMediaList) : |
60 | 123 |
iBinding(&aBinding), iMedia(&aMedia), iModel(aModel), iItemIndex( |
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
124 |
aItemIndex), iMediaList(aMediaList) |
60 | 125 |
{ |
126 |
TRACER("CGlxDrmGifTextureCreator::CGlxDrmGifTextureCreator()"); |
|
127 |
// Implement nothing here |
|
128 |
} |
|
129 |
||
130 |
// ----------------------------------------------------------------------------- |
|
131 |
// ConstructL |
|
132 |
// ----------------------------------------------------------------------------- |
|
133 |
void CGlxDrmGifTextureCreator::ConstructL() |
|
134 |
{ |
|
135 |
TRACER("CGlxDrmGifTextureCreator::ConstructL()"); |
|
136 |
iUiUtility = CGlxUiUtility::UtilityL(); |
|
137 |
User::LeaveIfError(iFsSession.Connect()); |
|
138 |
iBitmapReady = EFalse; |
|
139 |
iAnimCount = 0; |
|
140 |
iAnimateFlag = EFalse; |
|
141 |
iTransparencyPossible = EFalse; |
|
142 |
iFrameShift = EFalse; |
|
143 |
||
144 |
//Set the initial texture, it could be default or the FS texture |
|
145 |
SetTexture(); |
|
146 |
// Create the active object |
|
147 |
iGlxDecoderAO = CGlxDRMgifDecoderAO::NewL(this); |
|
148 |
#ifdef _DEBUG |
|
149 |
iStartTime.HomeTime(); |
|
150 |
#endif |
|
151 |
CreateImageDecoderL(iMedia->Uri()); |
|
152 |
CreateBitmapAndStartDecodingL(); |
|
153 |
} |
|
154 |
||
155 |
// ----------------------------------------------------------------------------- |
|
156 |
// UpdateNewImageL |
|
157 |
// ----------------------------------------------------------------------------- |
|
158 |
void CGlxDrmGifTextureCreator::UpdateNewImageL(const TGlxMedia& aMedia, |
|
159 |
TInt aItemIndex) |
|
160 |
{ |
|
161 |
TRACER("CGlxDrmGifTextureCreator::UpdateNewImageL()"); |
|
162 |
GLX_LOG_INFO1("DrmGif: UpdateNewImageL() aItemIndex=%d", aItemIndex); |
|
163 |
if (aItemIndex == iItemIndex) |
|
164 |
{ |
|
165 |
return; |
|
166 |
} |
|
167 |
||
168 |
// First release the contents before proceeding further |
|
169 |
ReleaseContent(); |
|
170 |
||
171 |
iItemIndex = aItemIndex; |
|
172 |
iMedia = &aMedia; |
|
173 |
||
174 |
iBitmapReady = EFalse; |
|
175 |
iAnimCount = 0; |
|
176 |
iAnimateFlag = EFalse; |
|
177 |
iTransparencyPossible = EFalse; |
|
178 |
iFrameShift = EFalse; |
|
179 |
||
180 |
//Set the initial texture, it could be default or the FS texture |
|
181 |
SetTexture(); |
|
182 |
#ifdef _DEBUG |
|
183 |
iStartTime.HomeTime(); |
|
184 |
#endif |
|
185 |
CreateImageDecoderL(iMedia->Uri()); |
|
186 |
CreateBitmapAndStartDecodingL(); |
|
187 |
} |
|
188 |
||
189 |
// ----------------------------------------------------------------------------- |
|
190 |
// AnimateDRMGifItem |
|
191 |
// ----------------------------------------------------------------------------- |
|
192 |
void CGlxDrmGifTextureCreator::AnimateDRMGifItem(TBool aAnimate) |
|
193 |
{ |
|
194 |
TRACER("CGlxDrmGifTextureCreator::AnimateDRMGifItem()"); |
|
195 |
if (!iAnimationTimer) |
|
196 |
{ |
|
197 |
return; |
|
198 |
} |
|
199 |
||
200 |
if (aAnimate && iBitmapReady) |
|
201 |
{ |
|
202 |
if (!iAnimationTimer->IsActive()) |
|
203 |
{ |
|
204 |
GLX_LOG_INFO1("DrmGif: AnimateDRMGifItem() - iAnimCount=%d", iAnimCount); |
|
205 |
GLX_LOG_INFO1("DrmGif: AnimateDRMGifItem() - Frame Interval <%d> us", |
|
206 |
(TInt)iFrameInfo.iDelay.Int64()); |
|
207 |
TInt interval =((TInt)iFrameInfo.iDelay.Int64()) ? |
|
208 |
((TInt)iFrameInfo.iDelay.Int64()) : KDefaultFrameInterval; |
|
209 |
GLX_LOG_INFO1("DrmGif: AnimateDRMGifItem() interval=<%d> us", interval); |
|
210 |
iAnimationTimer->Start(interval, interval, TCallBack(TimerCallbackL, this)); |
|
211 |
} |
|
212 |
iAnimateFlag = ETrue; |
|
213 |
} |
|
214 |
else |
|
215 |
{ |
|
216 |
if (iAnimationTimer->IsActive()) |
|
217 |
{ |
|
218 |
iAnimationTimer->Cancel(); |
|
219 |
iAnimateFlag = EFalse; |
|
220 |
} |
|
221 |
} |
|
222 |
} |
|
223 |
||
224 |
// ----------------------------------------------------------------------------- |
|
225 |
// RefreshL |
|
226 |
// ----------------------------------------------------------------------------- |
|
227 |
void CGlxDrmGifTextureCreator::RefreshL() |
|
228 |
{ |
|
229 |
TRACER("CGlxDrmGifTextureCreator::RefreshL()"); |
|
230 |
GLX_LOG_INFO2("DrmGif: RefreshL() iAnimCount=%d, iFrameShift=%d", |
|
231 |
iAnimCount, iFrameShift); |
|
232 |
TInt textureId = KErrNotFound; |
|
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
233 |
if(iMediaList.Count()) |
60 | 234 |
{ |
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
235 |
const TGlxMedia media = iMediaList.Item(iItemIndex); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
236 |
|
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
237 |
if (iTransparencyPossible && !iFrameShift) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
238 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
239 |
textureId |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
240 |
= (iUiUtility->GlxTextureManager().CreateDRMAnimatedGifTextureL( |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
241 |
media, media.IdSpaceId(), iAnimCount, |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
242 |
iDecodedBitmap[iAnimCount], |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
243 |
iDecodedMask[iAnimCount])).Id(); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
244 |
} |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
245 |
else |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
246 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
247 |
textureId |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
248 |
= (iUiUtility->GlxTextureManager().CreateDRMAnimatedGifTextureL( |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
249 |
media, media.IdSpaceId(), iAnimCount, |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
250 |
iDecodedBitmap[iAnimCount], NULL)).Id(); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
251 |
} |
60 | 252 |
} |
253 |
||
254 |
SetTexture(textureId); |
|
255 |
// Advance animation |
|
256 |
iAnimCount++; |
|
257 |
// if animation count is becoming maximum, then reset to animate again |
|
258 |
if (iAnimCount >= iFrameCount) |
|
259 |
{ |
|
260 |
GLX_LOG_INFO("DrmGif: RefreshL() Reset iAnimCount"); |
|
261 |
iAnimCount = 0; |
|
262 |
} |
|
263 |
} |
|
264 |
||
265 |
// ----------------------------------------------------------------------------- |
|
266 |
// CreateBitmapAndStartDecodingL |
|
267 |
// ----------------------------------------------------------------------------- |
|
268 |
void CGlxDrmGifTextureCreator::CreateBitmapAndStartDecodingL() |
|
269 |
{ |
|
270 |
TRACER("CGlxDrmGifTextureCreator::CreateBitmapAndStartDecodingL()"); |
|
271 |
GLX_LOG_INFO1("CreateBitmapAndDecodingL() iAnimCount=%d", iAnimCount); |
|
272 |
// Create the bitmap and mask as of original image size, and let the |
|
273 |
// coverflow widget do the scaling, if required. |
|
274 |
// This is needed for the transparent gifs frames as the |
|
275 |
// frame co-ordinates would mismatch if downscaling is applied. |
|
276 |
TSize frameSize = iImageDecoder->FrameInfo(iAnimCount).iFrameSizeInPixels; |
|
277 |
GLX_LOG_INFO3("DrmGif: CreateBitmapAndStartDecodingL() - Frame[%d] size=%d,%d", |
|
278 |
iAnimCount, frameSize.iWidth, frameSize.iHeight); |
|
279 |
||
280 |
iDecodedBitmap[iAnimCount] = new (ELeave) CFbsBitmap(); |
|
281 |
iDecodedBitmap[iAnimCount]->Create(frameSize, |
|
282 |
iFrameInfo.iFrameDisplayMode); |
|
283 |
User::LeaveIfNull(iDecodedBitmap[iAnimCount]); |
|
284 |
||
285 |
if (iFrameInfo.iFlags & TFrameInfo::ETransparencyPossible) |
|
286 |
{ |
|
287 |
iDecodedMask[iAnimCount] = new (ELeave) CFbsBitmap(); |
|
288 |
iDecodedMask[iAnimCount]->Create(frameSize, iFrameInfo.iFlags |
|
289 |
& TFrameInfo::EAlphaChannel ? EGray256 : EGray2); |
|
290 |
User::LeaveIfNull(iDecodedMask[iAnimCount]); |
|
291 |
||
292 |
// decoding the image |
|
293 |
iGlxDecoderAO->ConvertImageL(iDecodedBitmap[iAnimCount], |
|
294 |
iDecodedMask[iAnimCount], iAnimCount, iImageDecoder); |
|
295 |
iTransparencyPossible = ETrue; |
|
296 |
} |
|
297 |
else |
|
298 |
{ |
|
299 |
// decoding the image |
|
300 |
iGlxDecoderAO->ConvertImageL(iDecodedBitmap[iAnimCount], NULL, |
|
301 |
iAnimCount, iImageDecoder); |
|
302 |
} |
|
303 |
} |
|
304 |
||
305 |
// ----------------------------------------------------------------------------- |
|
306 |
// HandleRunL |
|
307 |
// ----------------------------------------------------------------------------- |
|
308 |
void CGlxDrmGifTextureCreator::HandleRunL(TRequestStatus& aStatus) |
|
309 |
{ |
|
310 |
TRACER("CGlxDrmGifTextureCreator::HandleRunL()"); |
|
311 |
TInt err = aStatus.Int(); |
|
312 |
GLX_LOG_INFO1("DrmGif: HandleRunL : err=%d", err); |
|
313 |
if (err != KErrNone) |
|
314 |
{ |
|
315 |
ReleaseContent(); |
|
316 |
return; |
|
317 |
} |
|
318 |
||
319 |
GLX_LOG_INFO2("DrmGif: HandleRunL() - Frame=%d/%d", |
|
320 |
iAnimCount, iFrameCount-1); |
|
321 |
if (iAnimCount > 0 && iAnimCount < iFrameCount) |
|
322 |
{ |
|
323 |
TPoint point = |
|
324 |
iImageDecoder->FrameInfo(iAnimCount).iFrameCoordsInPixels.iTl; |
|
325 |
GLX_LOG_INFO2("DrmGif: HandleRunL() point=(%d, %d)", |
|
326 |
point.iX, point.iY ); |
|
327 |
TSize frameSize = iImageDecoder->FrameInfo(iAnimCount).iFrameSizeInPixels; |
|
328 |
GLX_LOG_INFO2("DrmGif: HandleRunL() - frameSize(%d, %d)", |
|
329 |
frameSize.iWidth, frameSize.iHeight); |
|
330 |
// Frame shift is checked, |
|
331 |
// 1) If the subsequent frame sizes differ from the first frame (or) |
|
332 |
// 2) If the subsequent frame co-ordinates differ from the first frame |
|
333 |
if (point != iFrameInfo.iFrameCoordsInPixels.iTl |
|
334 |
|| iFrameInfo.iFrameSizeInPixels != frameSize) |
|
335 |
{ |
|
336 |
iFrameShift = ETrue; |
|
337 |
} |
|
338 |
||
339 |
if (iFrameShift) |
|
340 |
{ |
|
341 |
TSize firstFrameSize = iDecodedBitmap[0]->SizeInPixels(); |
|
342 |
GLX_LOG_INFO2("DrmGif: HandleRunL() - first bitmap size (%d, %d)", |
|
343 |
firstFrameSize.iWidth, firstFrameSize.iHeight); |
|
344 |
||
345 |
TDisplayMode dispMode = iDecodedBitmap[0]->DisplayMode(); |
|
346 |
TInt scanLineLength = CFbsBitmap::ScanLineLength( |
|
347 |
firstFrameSize.iWidth, dispMode); |
|
348 |
||
349 |
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); |
|
350 |
CleanupStack::PushL(bitmap); |
|
351 |
User::LeaveIfError(bitmap->Create(firstFrameSize, dispMode)); |
|
352 |
bitmap->LockHeap(); |
|
353 |
iDecodedBitmap[0]->LockHeap(); |
|
354 |
if (bitmap && bitmap->DataAddress()) |
|
355 |
{ |
|
356 |
memcpy((void*) bitmap->DataAddress(), |
|
357 |
(void*) iDecodedBitmap[0]->DataAddress(), |
|
358 |
scanLineLength * firstFrameSize.iHeight); |
|
359 |
} |
|
360 |
iDecodedBitmap[0]->UnlockHeap(); |
|
361 |
bitmap->UnlockHeap(); |
|
362 |
||
363 |
CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(bitmap); |
|
364 |
CleanupStack::PushL(bitmapDevice); |
|
365 |
||
366 |
CFbsBitGc* bitmapGc = CFbsBitGc::NewL(); |
|
367 |
CleanupStack::PushL(bitmapGc); |
|
368 |
bitmapGc->Activate(bitmapDevice); |
|
369 |
||
370 |
if (iTransparencyPossible) |
|
371 |
{ |
|
372 |
GLX_LOG_INFO("DrmGif: HandleRunL() BitBltMasked"); |
|
373 |
bitmapGc->BitBltMasked(point, iDecodedBitmap[iAnimCount], |
|
374 |
iOrigImageDimensions, iDecodedMask[iAnimCount], |
|
375 |
EFalse); |
|
376 |
} |
|
377 |
else |
|
378 |
{ |
|
379 |
GLX_LOG_INFO("DrmGif: HandleRunL() BitBlt"); |
|
380 |
bitmapGc->BitBlt(point, iDecodedBitmap[iAnimCount]); |
|
381 |
} |
|
382 |
||
383 |
delete iDecodedBitmap[iAnimCount]; |
|
384 |
iDecodedBitmap[iAnimCount] = bitmap; |
|
385 |
CleanupStack::PopAndDestroy(bitmapGc); |
|
386 |
CleanupStack::PopAndDestroy(bitmapDevice); |
|
387 |
CleanupStack::Pop(bitmap); |
|
388 |
} |
|
389 |
} |
|
390 |
||
391 |
if (iAnimCount < iFrameCount - 1) |
|
392 |
{ |
|
393 |
if (!iGlxDecoderAO->IsActive()) |
|
394 |
{ |
|
395 |
iAnimCount++; |
|
396 |
CreateBitmapAndStartDecodingL(); |
|
397 |
} |
|
398 |
} |
|
399 |
else |
|
400 |
{ |
|
401 |
#ifdef _DEBUG |
|
402 |
iStopTime.HomeTime(); |
|
403 |
GLX_LOG_INFO1("DrmGif: HandleRunL() ConvertImageL took <%d> us", |
|
404 |
(TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64()); |
|
405 |
#endif |
|
406 |
iBitmapReady = ETrue; |
|
407 |
iAnimateFlag = ETrue; |
|
408 |
iAnimCount = 0; |
|
409 |
ProcessImageL(); |
|
410 |
||
411 |
//release imagedecoder after the conversion is over |
|
412 |
if (iImageDecoder) |
|
413 |
{ |
|
414 |
delete iImageDecoder; |
|
415 |
iImageDecoder = NULL; |
|
416 |
} |
|
417 |
} |
|
418 |
} |
|
419 |
||
420 |
// ----------------------------------------------------------------------------- |
|
421 |
// ProcessImageL |
|
422 |
// ----------------------------------------------------------------------------- |
|
423 |
void CGlxDrmGifTextureCreator::ProcessImageL() |
|
424 |
{ |
|
425 |
TRACER("CGlxDrmGifTextureCreator::ProcessImageL()"); |
|
426 |
RefreshL(); |
|
427 |
iAnimationTimer->Cancel(); |
|
428 |
if (iAnimateFlag) |
|
429 |
{ |
|
430 |
GLX_LOG_INFO1("DrmGif: ProcessImageL() - Frame Interval <%d> us", |
|
431 |
(TInt)iFrameInfo.iDelay.Int64()); |
|
432 |
TInt interval =((TInt)iFrameInfo.iDelay.Int64()) ? |
|
433 |
((TInt)iFrameInfo.iDelay.Int64()) : KDefaultFrameInterval; |
|
434 |
GLX_LOG_INFO1("DrmGif: ProcessImageL() interval=<%d> us", interval); |
|
435 |
iAnimationTimer->Start(interval, interval, TCallBack(TimerCallbackL, |
|
436 |
this)); |
|
437 |
} |
|
438 |
} |
|
439 |
||
440 |
// ----------------------------------------------------------------------------- |
|
441 |
// CreateImageDecoderL |
|
442 |
// ----------------------------------------------------------------------------- |
|
443 |
void CGlxDrmGifTextureCreator::CreateImageDecoderL(const TDesC& aImageFile) |
|
444 |
{ |
|
445 |
TRACER("CGlxDrmGifTextureCreator::CreateImageDecoderL()"); |
|
446 |
GLX_LOG_URI("DrmGif::CreateImageDecoderL(%S)", &aImageFile); |
|
447 |
||
448 |
CImageDecoder::TOptions options = |
|
449 |
(CImageDecoder::TOptions) (CImageDecoder::EOptionNoDither |
|
450 |
| CImageDecoder::EOptionAlwaysThread); |
|
451 |
// Create a decoder for the image in the named file |
|
452 |
TRAPD(error,iImageDecoder = CImageDecoder::FileNewL(iFsSession, |
|
453 |
aImageFile, options, KNullUid)); |
|
454 |
if (error != KErrNone) |
|
455 |
{ |
|
456 |
User::Leave(error); |
|
457 |
} |
|
458 |
iFrameInfo = iImageDecoder->FrameInfo(); |
|
459 |
iOrigImageDimensions = iImageDecoder->FrameInfo().iOverallSizeInPixels; |
|
460 |
GLX_LOG_INFO1("DrmGif::CreateImageDecoderL() - Gif Frame Interval <%d> us", |
|
461 |
(TInt)iFrameInfo.iDelay.Int64()); |
|
462 |
iFrameCount = iImageDecoder->FrameCount(); |
|
463 |
||
464 |
// We are creating array of KGlxMaxFrameCount frames |
|
465 |
// So re-setting the array-count with the no. |
|
466 |
// It will animate till that no. of frames. |
|
467 |
if (iFrameCount > KGlxMaxFrameCount) |
|
468 |
{ |
|
469 |
iFrameCount = KGlxMaxFrameCount; |
|
470 |
} |
|
471 |
//dont create the timer if it is a singleframe.no need to animate |
|
472 |
if (iFrameCount > 1) |
|
473 |
{ |
|
474 |
iAnimationTimer = CPeriodic::NewL(CActive::EPriorityLow); |
|
475 |
} |
|
476 |
} |
|
477 |
||
478 |
// ----------------------------------------------------------------------------- |
|
479 |
// TimerCallbackL |
|
480 |
// ----------------------------------------------------------------------------- |
|
481 |
TInt CGlxDrmGifTextureCreator::TimerCallbackL(TAny* aThis) |
|
482 |
{ |
|
483 |
TRACER("CGlxDrmGifTextureCreator::TimerCallbackL()"); |
|
484 |
static_cast<CGlxDrmGifTextureCreator*> (aThis)->ProcessTimerEventL(); |
|
485 |
return KErrNone; |
|
486 |
} |
|
487 |
||
488 |
// ----------------------------------------------------------------------------- |
|
489 |
// ProcessTimerEventL |
|
490 |
// ----------------------------------------------------------------------------- |
|
491 |
void CGlxDrmGifTextureCreator::ProcessTimerEventL() |
|
492 |
{ |
|
493 |
TRACER("CGlxDrmGifTextureCreator::ProcessTimerEventL()"); |
|
494 |
ProcessImageL(); |
|
495 |
} |
|
496 |
||
497 |
// ----------------------------------------------------------------------------- |
|
498 |
// SetTexture |
|
499 |
// ----------------------------------------------------------------------------- |
|
500 |
void CGlxDrmGifTextureCreator::SetTexture(TInt aTextureId) |
|
501 |
{ |
|
502 |
TRACER("CGlxDrmGifTextureCreator::SetTexture()"); |
|
503 |
auto_ptr<MulVisualItem> item(new (EMM) MulVisualItem()); |
|
64
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
504 |
if (iMediaList.Count()) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
505 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
506 |
iBinding->PopulateT(*item, iMediaList.Item(iItemIndex), ETrue, aTextureId); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
507 |
iModel->SetData(iItemIndex, item); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
508 |
} |
60 | 509 |
} |