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