26
|
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: Texture Manager
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
|
|
23 |
#include "glxtexturemanagerimpl.h"
|
|
24 |
|
|
25 |
#include <AknIconUtils.h>
|
|
26 |
#include <AknsUtils.h>
|
|
27 |
#include <aknconsts.h>
|
|
28 |
#include <alf/alftexturemanager.h>
|
|
29 |
#include <alf/alfutil.h>
|
|
30 |
#include <mpxmediadrmdefs.h>
|
|
31 |
#include <mpxmediageneraldefs.h>
|
|
32 |
|
|
33 |
#include <glxdrmutility.h>
|
|
34 |
#include <glxmedia.h>
|
|
35 |
#include <glxmediageneraldefs.h>
|
|
36 |
#include <glxthumbnailattributeinfo.h>
|
|
37 |
#include <glxthumbnailutility.h>
|
|
38 |
#include <mglxcache.h>
|
|
39 |
#include <glxresolutionutility.h>
|
|
40 |
#include <glxlog.h>
|
|
41 |
#include <glxtracer.h>
|
|
42 |
#include <glxuiutility.h>
|
|
43 |
#include "mglxtextureobserver.h"
|
|
44 |
|
|
45 |
namespace
|
|
46 |
{
|
|
47 |
const TInt KGlxFirstAlfThumbnailTextureId = 0x10000001;
|
|
48 |
const TInt KGlxLastAlfThumbnailTextureId = 0x20000000;
|
|
49 |
const TInt KGlxFirstThumbnailTextureId = 0x20000001;
|
|
50 |
/** Bitmap size for flat (solid colour) textures */
|
|
51 |
const TInt KGlxFlatTextureSize = 64;
|
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// Constructor
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CGlxTextureManagerImpl::CGlxTextureManagerImpl
|
|
60 |
(CAlfTextureManager& aAlfTextureManager) :
|
|
61 |
iAlfTextureManager(aAlfTextureManager),
|
|
62 |
iNextTextureId( KGlxFirstThumbnailTextureId )
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
// Destructor
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CGlxTextureManagerImpl::~CGlxTextureManagerImpl()
|
|
71 |
{
|
|
72 |
TRACER("CGlxTextureManagerImpl::~CGlxTextureManagerImpl");
|
|
73 |
|
|
74 |
// delete other icon textures
|
|
75 |
// iIconLIst should deleted only once in destructor as
|
|
76 |
// they are using in full applicaiton
|
|
77 |
TInt count = iIconList.Count();
|
|
78 |
for(TInt i = count - 1; i >= 0; i--)
|
|
79 |
{
|
|
80 |
delete iIconList[i].iTexture;
|
|
81 |
}
|
|
82 |
iIconList.Close();
|
|
83 |
|
|
84 |
iThumbnailList.Close();
|
|
85 |
|
|
86 |
iAnimatedTnmList.Close();
|
|
87 |
|
|
88 |
// delete DRM GIF textures
|
|
89 |
count = iDRMGifAnimatedTnmList.Count();
|
|
90 |
GLX_LOG_INFO1("CGlxTextureManagerImpl iDRMGifAnimatedTnmList.Count=%d",count);
|
|
91 |
for(TInt i = count - 1; i >= 0; i--)
|
|
92 |
{
|
|
93 |
GLX_LOG_INFO1("CGlxTextureManagerImpl DRM Gif Texture deleted i=%d",i);
|
|
94 |
for(TInt texCnt = KGlxMaxFrameCount - 1; texCnt >= 0; texCnt--)
|
|
95 |
{
|
|
96 |
delete iDRMGifAnimatedTnmList[i].iTexture[texCnt];
|
|
97 |
}
|
|
98 |
}
|
|
99 |
iDRMGifAnimatedTnmList.Close();
|
|
100 |
|
|
101 |
// delete zoom textures
|
|
102 |
count = iZoomedList.Count();
|
|
103 |
GLX_LOG_INFO1("CGlxTextureManagerImpl iZoomedList.Count=%d",count);
|
|
104 |
for(TInt i = count - 1; i >= 0; i--)
|
|
105 |
{
|
|
106 |
GLX_LOG_INFO1("CGlxTextureManagerImpldeleted i=%d",i);
|
|
107 |
delete iZoomedList[i].iTexture;
|
|
108 |
}
|
|
109 |
iZoomedList.Close();
|
|
110 |
|
|
111 |
delete iMifFilenames;
|
|
112 |
|
|
113 |
if ( iDrmUtility )
|
|
114 |
{
|
|
115 |
iDrmUtility->Close();
|
|
116 |
}
|
|
117 |
|
|
118 |
if ( iCache )
|
|
119 |
{
|
|
120 |
iCache->RemoveObserver(this);
|
|
121 |
iCache->Close();
|
|
122 |
}
|
|
123 |
|
|
124 |
if ( iResUtil )
|
|
125 |
{
|
|
126 |
iResUtil->RemoveObserver(*this);
|
|
127 |
iResUtil->Close();
|
|
128 |
}
|
|
129 |
if(iZoomDecoder)
|
|
130 |
{
|
|
131 |
delete iZoomDecoder;
|
|
132 |
}
|
|
133 |
}
|
|
134 |
|
|
135 |
// -----------------------------------------------------------------------------
|
|
136 |
// NewL
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
CGlxTextureManagerImpl* CGlxTextureManagerImpl::NewL(
|
|
140 |
CAlfTextureManager& aAlfTextureManager)
|
|
141 |
{
|
|
142 |
TRACER("CGlxTextureManagerImpl::NewL");
|
|
143 |
CGlxTextureManagerImpl* self = CGlxTextureManagerImpl::NewLC(aAlfTextureManager);
|
|
144 |
CleanupStack::Pop(self);
|
|
145 |
return self;
|
|
146 |
}
|
|
147 |
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
// NewLC
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
CGlxTextureManagerImpl* CGlxTextureManagerImpl::NewLC(
|
|
153 |
CAlfTextureManager& aAlfTextureManager)
|
|
154 |
{
|
|
155 |
TRACER("CGlxTextureManagerImpl::NewLC");
|
|
156 |
CGlxTextureManagerImpl* self =
|
|
157 |
new (ELeave) CGlxTextureManagerImpl(aAlfTextureManager);
|
|
158 |
CleanupStack::PushL(self);
|
|
159 |
self->ConstructL();
|
|
160 |
return self;
|
|
161 |
}
|
|
162 |
|
|
163 |
// -----------------------------------------------------------------------------
|
|
164 |
// ConstructL
|
|
165 |
// -----------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
void CGlxTextureManagerImpl::ConstructL()
|
|
168 |
{
|
|
169 |
TRACER("CGlxTextureManagerImpl::ConstructL");
|
|
170 |
iMifFilenames = new (ELeave) CDesCArrayFlat(2);
|
|
171 |
|
|
172 |
// get handle to DRM utility
|
|
173 |
iDrmUtility = CGlxDRMUtility::InstanceL();
|
|
174 |
// get handle to the media cache
|
|
175 |
iCache = MGlxCache::InstanceL();
|
|
176 |
iCache->AddObserverL(this);
|
|
177 |
|
|
178 |
// Get instance of Resolution utility and register for notification of
|
|
179 |
// resolution changes
|
|
180 |
/// @todo implement CGlxResolutionUtility this later
|
|
181 |
iResUtil = CGlxResolutionUtility::InstanceL();
|
|
182 |
iResUtil->AddObserverL(*this);
|
|
183 |
// Set the TextureId range. Now we can set our own ID outside this Range
|
|
184 |
iAlfTextureManager.SetAutomaticTextureIdRange(
|
|
185 |
KGlxFirstAlfThumbnailTextureId,
|
|
186 |
KGlxLastAlfThumbnailTextureId);
|
|
187 |
}
|
|
188 |
|
|
189 |
|
|
190 |
// -----------------------------------------------------------------------------
|
|
191 |
// TextureNeedsUpdating
|
|
192 |
// -----------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
TBool CGlxTextureManagerImpl::TextureNeedsUpdating( TGlxMedia aMedia,
|
|
195 |
TGlxIdSpaceId aIdSpaceId, const TSize& aRequiredSize )
|
|
196 |
{
|
|
197 |
TRACER("CGlxTextureManagerImpl::TextureNeedsUpdating");
|
|
198 |
TInt thumbnailIndex = KErrNotFound;
|
|
199 |
TMPXAttribute thumbNailAttribute( 0, 0 );
|
|
200 |
TBool updateTexture = ETrue;
|
|
201 |
TRAPD( err, updateTexture = GetThumbnailAttributeAndIndexL( aRequiredSize,
|
|
202 |
aMedia, aIdSpaceId, thumbnailIndex, thumbNailAttribute ) );
|
|
203 |
// don't update the texture if there's an error
|
|
204 |
return ( err == KErrNone ? updateTexture : EFalse );
|
|
205 |
}
|
|
206 |
|
|
207 |
// -----------------------------------------------------------------------------
|
|
208 |
// CreateIconTextureL
|
|
209 |
// -----------------------------------------------------------------------------
|
|
210 |
//
|
|
211 |
CAlfTexture& CGlxTextureManagerImpl::CreateIconTextureL(
|
|
212 |
const TAknsItemID& aSkinID,
|
|
213 |
TInt aIconResourceId,
|
|
214 |
const TDesC& aFilename,
|
|
215 |
TBool aSetColor,
|
|
216 |
TRgb aDefaultColor,
|
|
217 |
const TAknsItemID& aSkinColorId,
|
|
218 |
TInt aSkinColorIndex,
|
|
219 |
TSize aRequestedSize)
|
|
220 |
{
|
|
221 |
TRACER("CGlxTextureManagerImpl::CreateIconTextureL");
|
|
222 |
// Convert size to POSS
|
|
223 |
TReal32 heightInPoss =
|
|
224 |
iResUtil->PixelsToPoss(TReal32(aRequestedSize.iHeight));
|
|
225 |
|
|
226 |
TReal32 widthInPoss =
|
|
227 |
iResUtil->PixelsToPoss(TReal32(aRequestedSize.iWidth));
|
|
228 |
|
|
229 |
|
|
230 |
CAlfTexture* texture = NULL;
|
|
231 |
//search array for existing item
|
|
232 |
TInt i = iIconList.Count();
|
|
233 |
while(i > 0 && !texture)
|
|
234 |
{
|
|
235 |
i--;
|
|
236 |
TGlxIcon icon = iIconList[i];
|
|
237 |
if( icon.iAvkonSkinId == aSkinID &&
|
|
238 |
icon.iBitmapId == aIconResourceId &&
|
|
239 |
icon.iSetColor == aSetColor &&
|
|
240 |
icon.iDefaultColor == aDefaultColor &&
|
|
241 |
icon.iSkinColorId == aSkinColorId &&
|
|
242 |
icon.iSkinColorIndex == aSkinColorIndex &&
|
|
243 |
icon.iHeightInPoss == heightInPoss &&
|
|
244 |
icon.iWidthInPoss == widthInPoss )
|
|
245 |
{
|
|
246 |
// also compare file names
|
|
247 |
TFileName filename(KNullDesC);
|
|
248 |
if(icon.iFilenameIndex >= 0)
|
|
249 |
{
|
|
250 |
filename = iMifFilenames->MdcaPoint(icon.iFilenameIndex);
|
|
251 |
}
|
|
252 |
if(0 == filename.CompareF(aFilename) )
|
|
253 |
{
|
|
254 |
// match found - use existing texture
|
|
255 |
texture = icon.iTexture;
|
|
256 |
}
|
|
257 |
}
|
|
258 |
}
|
|
259 |
|
|
260 |
if(!texture)
|
|
261 |
{
|
|
262 |
// existing texture not found - prepare to create new one
|
|
263 |
TInt filenameIndex = -1;
|
|
264 |
if(aFilename.Length() > 0)
|
|
265 |
{
|
|
266 |
// is filename already in filename list
|
|
267 |
if(iMifFilenames->MdcaCount())
|
|
268 |
{
|
|
269 |
iMifFilenames->Find(aFilename, filenameIndex);
|
|
270 |
if(filenameIndex == iMifFilenames->MdcaCount())
|
|
271 |
{
|
|
272 |
filenameIndex = -1;
|
|
273 |
}
|
|
274 |
}
|
|
275 |
if(filenameIndex < 0)
|
|
276 |
{
|
|
277 |
// name not in list. Add it
|
|
278 |
iMifFilenames->AppendL(aFilename);
|
|
279 |
filenameIndex = iMifFilenames->MdcaCount() - 1;
|
|
280 |
}
|
|
281 |
}
|
|
282 |
// Create new icon entry
|
|
283 |
TGlxIcon icon;
|
|
284 |
icon.iTextureId = NextTextureId();
|
|
285 |
icon.iTexture = NULL;
|
|
286 |
icon.iAvkonSkinId = aSkinID;
|
|
287 |
icon.iBitmapId = aIconResourceId;
|
|
288 |
icon.iFilenameIndex = filenameIndex;
|
|
289 |
icon.iSetColor = aSetColor;
|
|
290 |
icon.iDefaultColor = aDefaultColor;
|
|
291 |
icon.iSkinColorId = aSkinColorId;
|
|
292 |
icon.iSkinColorIndex = aSkinColorIndex;
|
|
293 |
icon.iHeightInPoss = heightInPoss;
|
|
294 |
icon.iWidthInPoss = widthInPoss;
|
|
295 |
|
|
296 |
// add to list so ProvideBitmapL can use it
|
|
297 |
iIconList.AppendL(icon);
|
|
298 |
|
|
299 |
// trap create texture
|
|
300 |
TRAPD(err, texture = &iAlfTextureManager.CreateTextureL(
|
|
301 |
icon.iTextureId,
|
|
302 |
this,
|
|
303 |
EAlfTextureFlagDefault));
|
|
304 |
if(err)
|
|
305 |
{
|
|
306 |
// if error delete entry and leave
|
|
307 |
iIconList.Remove(iIconList.Count() - 1);
|
|
308 |
User::Leave(err);
|
|
309 |
}
|
|
310 |
else
|
|
311 |
{
|
|
312 |
// if no error add texture to entry
|
|
313 |
iIconList[iIconList.Count() - 1].iTexture = texture;
|
|
314 |
}
|
|
315 |
}
|
|
316 |
|
|
317 |
if (NULL == texture)
|
|
318 |
{
|
|
319 |
User::Leave(KErrNotFound);
|
|
320 |
}
|
|
321 |
|
|
322 |
return *texture;
|
|
323 |
}
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
// -----------------------------------------------------------------------------
|
|
328 |
// CreateNewTextureForMediaL
|
|
329 |
// -----------------------------------------------------------------------------
|
|
330 |
//
|
|
331 |
CAlfTexture& CGlxTextureManagerImpl::CreateNewTextureForMediaL(
|
|
332 |
TSize aSize,
|
|
333 |
const TGlxMedia& aMedia,
|
|
334 |
const TGlxIdSpaceId& aIdSpaceId,
|
|
335 |
MGlxTextureObserver* aObserver,
|
|
336 |
TBool aScaleGridTnm)
|
|
337 |
{
|
|
338 |
TRACER("CGlxTextureManagerImpl::CreateNewTextureForMediaL");
|
|
339 |
TInt thumbnailIndex = KErrNotFound;
|
|
340 |
TMPXAttribute thumbNailAttribute(0,0);
|
|
341 |
TGlxThumbnailIcon thumbData;
|
|
342 |
|
|
343 |
// If the current thumbnail matches what is required then return the current texture otherwise
|
|
344 |
// create a new one.
|
|
345 |
if (!GetThumbnailAttributeAndIndexL(aSize, aMedia, aIdSpaceId, thumbnailIndex, thumbNailAttribute))
|
|
346 |
{
|
|
347 |
// only texture is missing.
|
|
348 |
if ( (NULL != iThumbnailList[thumbnailIndex].iBitmap) && (NULL == iThumbnailList[thumbnailIndex].iTexture))
|
|
349 |
{
|
|
350 |
CAlfTexture* newTexture = &iAlfTextureManager.CreateTextureL(
|
|
351 |
iThumbnailList[thumbnailIndex].iTextureId,
|
|
352 |
this,
|
|
353 |
EAlfTextureFlagDefault);
|
|
354 |
iThumbnailList[thumbnailIndex].iTexture = newTexture ;
|
|
355 |
}
|
|
356 |
return *iThumbnailList[thumbnailIndex].iTexture;
|
|
357 |
}
|
|
358 |
|
|
359 |
// We have 2 scenarios here.
|
|
360 |
// 1) We do not have a thumbnail
|
|
361 |
// 2) The thumbnail we have is not good enough
|
|
362 |
iThumbnailList.ReserveL( iThumbnailList.Count() + 1 );
|
|
363 |
|
|
364 |
CAlfTexture& texture = CreateNewTextureL(aSize, aMedia, aIdSpaceId,
|
|
365 |
aObserver, thumbNailAttribute, thumbData,ETrue,aScaleGridTnm);
|
|
366 |
|
|
367 |
|
|
368 |
if ( thumbnailIndex != KErrNotFound )
|
|
369 |
{
|
|
370 |
// A new texture was created so remove the old one and
|
|
371 |
// update the thumbnail list.
|
|
372 |
iAlfTextureManager.UnloadTexture(iThumbnailList[thumbnailIndex].iTextureId);
|
|
373 |
iThumbnailList.Remove(thumbnailIndex);
|
|
374 |
GLX_LOG_INFO("CGlxTextureManagerImpl CreateNewTextureForMediaL UnloadTexture ");
|
|
375 |
}
|
|
376 |
|
|
377 |
return texture;
|
|
378 |
}
|
|
379 |
|
|
380 |
// -----------------------------------------------------------------------------
|
|
381 |
// CreateFlatColourTextureL
|
|
382 |
// -----------------------------------------------------------------------------
|
|
383 |
//
|
|
384 |
CAlfTexture& CGlxTextureManagerImpl::CreateFlatColourTextureL( TRgb aColour )
|
|
385 |
{
|
|
386 |
TRACER("CGlxTextureManagerImpl::CreateFlatColourTextureL");
|
|
387 |
// Create a picture with the colour
|
|
388 |
CFbsBitmap* picture = new (ELeave) CFbsBitmap;
|
|
389 |
CleanupStack::PushL(picture);
|
|
390 |
User::LeaveIfError(picture->Create(TSize(KGlxFlatTextureSize,
|
|
391 |
KGlxFlatTextureSize), EColor16M ) );
|
|
392 |
|
|
393 |
CFbsBitmapDevice* drawBufDevice = CFbsBitmapDevice::NewL(picture);
|
|
394 |
CleanupStack::PushL(drawBufDevice);
|
|
395 |
|
|
396 |
CFbsBitGc* drawBufContext;
|
|
397 |
User::LeaveIfError(drawBufDevice->CreateContext(drawBufContext));
|
|
398 |
CleanupStack::PushL(drawBufContext);
|
|
399 |
|
|
400 |
// draw the color
|
|
401 |
drawBufContext->Activate(drawBufDevice);
|
|
402 |
drawBufContext->SetBrushColor(aColour);
|
|
403 |
drawBufContext->Clear();
|
|
404 |
|
|
405 |
TInt alpha = aColour.Alpha();
|
|
406 |
|
|
407 |
CleanupStack::PopAndDestroy(drawBufContext);
|
|
408 |
CleanupStack::PopAndDestroy(drawBufDevice);
|
|
409 |
|
|
410 |
CFbsBitmap* mask = NULL;
|
|
411 |
if( alpha != 0 )
|
|
412 |
{
|
|
413 |
mask = new (ELeave) CFbsBitmap();
|
|
414 |
CleanupStack::PushL( mask );
|
|
415 |
User::LeaveIfError( mask->Create(TSize( KGlxFlatTextureSize,
|
|
416 |
KGlxFlatTextureSize ), EGray256 ));
|
|
417 |
|
|
418 |
CFbsBitmapDevice* maskBufDevice = CFbsBitmapDevice::NewL( mask );
|
|
419 |
CleanupStack::PushL( maskBufDevice );
|
|
420 |
|
|
421 |
CFbsBitGc* maskBufContext = NULL;
|
|
422 |
User::LeaveIfError( maskBufDevice->CreateContext( maskBufContext ) );
|
|
423 |
CleanupStack::PushL( maskBufContext );
|
|
424 |
|
|
425 |
// draw the mask
|
|
426 |
maskBufContext->Activate(maskBufDevice);
|
|
427 |
maskBufContext->SetBrushColor( TRgb::Color256( alpha ) );
|
|
428 |
maskBufContext->Clear();
|
|
429 |
|
|
430 |
CleanupStack::PopAndDestroy( maskBufContext );
|
|
431 |
CleanupStack::PopAndDestroy( maskBufDevice );
|
|
432 |
}
|
|
433 |
|
|
434 |
// Manage the texture ids ourself. Get the next id and store the
|
|
435 |
// associated bitmap and mask to ensure that we supply the correct bitmaps
|
|
436 |
// when alf calls back to ProvideBitmap
|
|
437 |
TInt nextTextureId = NextTextureId();
|
|
438 |
iProvideBitmapHolder.iTextureId = nextTextureId;
|
|
439 |
iProvideBitmapHolder.iBitmap = picture;
|
|
440 |
iProvideBitmapHolder.iMaskBitmap = mask;
|
|
441 |
|
|
442 |
CAlfTexture& newTexture = iAlfTextureManager.CreateTextureL(
|
|
443 |
nextTextureId,
|
|
444 |
this,
|
|
445 |
EAlfTextureFlagDefault );
|
|
446 |
// don't want alf to delete this texture
|
|
447 |
newTexture.SetPriority( EAlfTexturePriorityHighest );
|
|
448 |
|
|
449 |
// if we had alpha, release the mask
|
|
450 |
if( alpha != 0 )
|
|
451 |
{
|
|
452 |
CleanupStack::Pop( mask );
|
|
453 |
}
|
|
454 |
|
|
455 |
CleanupStack::Pop( picture );
|
|
456 |
|
|
457 |
return newTexture;
|
|
458 |
}
|
|
459 |
|
|
460 |
|
|
461 |
// -----------------------------------------------------------------------------
|
|
462 |
// RemoveTexture
|
|
463 |
// -----------------------------------------------------------------------------
|
|
464 |
//
|
|
465 |
void CGlxTextureManagerImpl::RemoveTexture( const CAlfTexture& aTexture )
|
|
466 |
{
|
|
467 |
TRACER("CGlxTextureManagerImpl::RemoveTexture");
|
|
468 |
// Find the texture in the iThumbnailList
|
|
469 |
TInt index = iThumbnailList.Find( aTexture, &TGlxThumbnailIcon::MatchTexture );
|
|
470 |
if ( index != KErrNotFound )
|
|
471 |
{
|
|
472 |
iThumbnailList.Remove( index );
|
|
473 |
iAlfTextureManager.UnloadTexture( aTexture.Id() );
|
|
474 |
}
|
|
475 |
else
|
|
476 |
{
|
|
477 |
// Find the texture in the zoomed list
|
|
478 |
index = iZoomedList.Find( aTexture, &TGlxThumbnailIcon::MatchTexture );
|
|
479 |
GLX_LOG_INFO1("CGlxTextureManagerImpl RemoveTexture index=%d",index);
|
|
480 |
if ( index != KErrNotFound )
|
|
481 |
{
|
|
482 |
GLX_LOG_INFO("CGlxTextureManagerImpl RemoveTexture index != KErrNotFound");
|
|
483 |
iAlfTextureManager.UnloadTexture( aTexture.Id() );
|
|
484 |
if(iZoomedList[index].iBitmap)
|
|
485 |
{
|
|
486 |
GLX_LOG_INFO("CGlxTextureManagerImpl RemoveTexture iZoomedList[index].iBitmap delete");
|
|
487 |
delete iZoomedList[index].iBitmap;
|
|
488 |
iZoomedList[index].iBitmap=NULL;
|
|
489 |
iZoomedList.Remove( index );
|
|
490 |
}
|
|
491 |
}
|
|
492 |
// iIconLIst should deleted only once in destructor as
|
|
493 |
// they are using in full applicaiton
|
|
494 |
}
|
|
495 |
|
|
496 |
index = iAnimatedTnmList.Find( aTexture, &TGlxThumbnailIcon::MatchTexture );
|
|
497 |
GLX_LOG_INFO1("CGlxTextureManagerImpl RemoveTexture iAnimatedTnmList index=%d",index);
|
|
498 |
if ( index != KErrNotFound )
|
|
499 |
{
|
|
500 |
if(iAnimatedTnmList[index].iTexture)
|
|
501 |
{
|
|
502 |
GLX_LOG_INFO("RemoveTexture iAnimatedTnmList Stop animation");
|
|
503 |
(iAnimatedTnmList[index].iTexture)->StopAnimation();
|
|
504 |
}
|
|
505 |
iAnimatedTnmList.Remove( index );
|
|
506 |
iAlfTextureManager.UnloadTexture( aTexture.Id() );
|
|
507 |
}
|
|
508 |
}
|
|
509 |
|
|
510 |
// -----------------------------------------------------------------------------
|
|
511 |
// RemoveZoomList
|
|
512 |
// -----------------------------------------------------------------------------
|
|
513 |
//
|
|
514 |
void CGlxTextureManagerImpl::RemoveZoomList()
|
|
515 |
{
|
|
516 |
TRACER("CGlxTextureManagerImpl::RemoveZoomList");
|
|
517 |
TInt count = iZoomedList.Count();
|
|
518 |
GLX_LOG_INFO1("CGlxTextureManagerImpl RemoveZoomList Count()=%d",count);
|
|
519 |
if(iZoomDecoder)
|
|
520 |
{
|
|
521 |
iZoomDecoder->Cancel();
|
|
522 |
}
|
|
523 |
for(TInt i = count - 1; i >= 0; i--)
|
|
524 |
{
|
|
525 |
iAlfTextureManager.UnloadTexture( iZoomedList[i].iTextureId );
|
|
526 |
if( iZoomedList[i].iBitmap)
|
|
527 |
{
|
|
528 |
GLX_LOG_INFO("CGlxTextureManagerImpl RemoveZoomList delete iZoomedList[i]");
|
|
529 |
delete iZoomedList[i].iBitmap;
|
|
530 |
iZoomedList[i].iBitmap=NULL;
|
|
531 |
}
|
|
532 |
iZoomedList.Remove( i );
|
|
533 |
}
|
|
534 |
iZoomedList.Reset();
|
|
535 |
|
|
536 |
}
|
|
537 |
|
|
538 |
// -----------------------------------------------------------------------------
|
|
539 |
// RemoveTexture Using TGlxMediaId&
|
|
540 |
// -----------------------------------------------------------------------------
|
|
541 |
//
|
|
542 |
void CGlxTextureManagerImpl::RemoveTexture(const TGlxMediaId& aMediaId,TBool aAllTexture )
|
|
543 |
{
|
|
544 |
TRACER("CGlxTextureManagerImpl::RemoveTexture 2");
|
|
545 |
//Bug fix for PKAA-7NRBYZ - added aAllTexture param
|
|
546 |
// Find the texture in the iThumbnailList
|
|
547 |
TInt i = iThumbnailList.Count();
|
|
548 |
while(i > 0)
|
|
549 |
{
|
|
550 |
--i;
|
|
551 |
if (iThumbnailList[i].iMediaId == aMediaId)
|
|
552 |
{
|
|
553 |
TInt aTexture = iThumbnailList[i].iTextureId;
|
|
554 |
iThumbnailList.Remove(i);
|
|
555 |
iAlfTextureManager.UnloadTexture(aTexture );
|
|
556 |
//Bug fix for PKAA-7NRBYZ - Delete all the texture only if it is asked.
|
|
557 |
if(!aAllTexture)
|
|
558 |
break;
|
|
559 |
}
|
|
560 |
}
|
|
561 |
|
|
562 |
i = iAnimatedTnmList.Count();
|
|
563 |
|
|
564 |
while(i > 0)
|
|
565 |
{
|
|
566 |
--i;
|
|
567 |
if (iAnimatedTnmList[i].iMediaId == aMediaId)
|
|
568 |
{
|
|
569 |
GLX_LOG_INFO("RemoveTexture 2 iAnimatedTnmList MediaID found");
|
|
570 |
TInt aTexture = iAnimatedTnmList[i].iTextureId;
|
|
571 |
if(iAnimatedTnmList[i].iTexture)
|
|
572 |
{
|
|
573 |
GLX_LOG_INFO("RemoveTexture2 iAnimatedTnmList Stop animation");
|
|
574 |
(iAnimatedTnmList[i].iTexture)->StopAnimation();
|
|
575 |
}
|
|
576 |
iAnimatedTnmList.Remove(i);
|
|
577 |
iAlfTextureManager.UnloadTexture(aTexture );
|
|
578 |
}
|
|
579 |
}
|
|
580 |
|
|
581 |
i = iDRMGifAnimatedTnmList.Count();
|
|
582 |
|
|
583 |
while(i > 0)
|
|
584 |
{
|
|
585 |
--i;
|
|
586 |
if (iDRMGifAnimatedTnmList[i].iMediaId == aMediaId)
|
|
587 |
{
|
|
588 |
GLX_LOG_INFO("RemoveTexture 2 iDRMGifAnimatedTnmList MediaId found");
|
|
589 |
for(TInt textureCnt=0;textureCnt<KGlxMaxFrameCount;textureCnt++)
|
|
590 |
{
|
|
591 |
TInt textureId = iDRMGifAnimatedTnmList[i].iTextureId[textureCnt];
|
|
592 |
iAlfTextureManager.UnloadTexture(textureId);
|
|
593 |
}
|
|
594 |
iDRMGifAnimatedTnmList.Remove(i);
|
|
595 |
}
|
|
596 |
}
|
|
597 |
}
|
|
598 |
|
|
599 |
// -----------------------------------------------------------------------------
|
|
600 |
// FlushTextures Removes All Textures
|
|
601 |
// -----------------------------------------------------------------------------
|
|
602 |
//
|
|
603 |
void CGlxTextureManagerImpl::FlushTextures()
|
|
604 |
{
|
|
605 |
TRACER("CGlxTextureManagerImpl::FlushTextures");
|
|
606 |
|
|
607 |
TInt textureID ;
|
|
608 |
|
|
609 |
TInt i = iThumbnailList.Count();
|
|
610 |
while(i > 0)
|
|
611 |
{
|
|
612 |
--i;
|
|
613 |
textureID = iThumbnailList[i].iTextureId;
|
|
614 |
iAlfTextureManager.UnloadTexture(textureID );
|
|
615 |
iThumbnailList[i].iTexture = NULL;
|
|
616 |
}
|
|
617 |
|
|
618 |
i = iIconList.Count();
|
|
619 |
while(i > 0)
|
|
620 |
{
|
|
621 |
--i;
|
|
622 |
textureID = iIconList[i].iTextureId;
|
|
623 |
iAlfTextureManager.UnloadTexture(textureID );
|
|
624 |
iIconList[i].iTexture = NULL;
|
|
625 |
}
|
|
626 |
|
|
627 |
i = iZoomedList.Count();
|
|
628 |
while(i > 0)
|
|
629 |
{
|
|
630 |
--i;
|
|
631 |
textureID = iZoomedList[i].iTextureId;
|
|
632 |
iAlfTextureManager.UnloadTexture(textureID );
|
|
633 |
iZoomedList[i].iTexture = NULL;
|
|
634 |
}
|
|
635 |
|
|
636 |
i = iAnimatedTnmList.Count();
|
|
637 |
while(i > 0)
|
|
638 |
{
|
|
639 |
--i;
|
|
640 |
textureID = iAnimatedTnmList[i].iTextureId;
|
|
641 |
if(iAnimatedTnmList[i].iTexture)
|
|
642 |
{
|
|
643 |
GLX_LOG_INFO("FlushTextures iAnimatedTnmList Stop animation");
|
|
644 |
(iAnimatedTnmList[i].iTexture)->StopAnimation();
|
|
645 |
}
|
|
646 |
iAlfTextureManager.UnloadTexture(textureID);
|
|
647 |
iAnimatedTnmList[i].iTexture = NULL;
|
|
648 |
}
|
|
649 |
|
|
650 |
i = iDRMGifAnimatedTnmList.Count();
|
|
651 |
while(i > 0)
|
|
652 |
{
|
|
653 |
--i;
|
|
654 |
GLX_LOG_INFO("RemoveTexture 2 iDRMGifAnimatedTnmList MediaId found");
|
|
655 |
for (TInt textureCnt = 0; textureCnt < KGlxMaxFrameCount; textureCnt++)
|
|
656 |
{
|
|
657 |
TInt aTexture = iDRMGifAnimatedTnmList[i].iTextureId[textureCnt];
|
|
658 |
iAlfTextureManager.UnloadTexture(aTexture);
|
|
659 |
iDRMGifAnimatedTnmList[i].iTexture[textureCnt] = NULL;
|
|
660 |
}
|
|
661 |
}
|
|
662 |
}
|
|
663 |
|
|
664 |
// -----------------------------------------------------------------------------
|
|
665 |
// GetThumbnailAttributeAndIndexL
|
|
666 |
// -----------------------------------------------------------------------------
|
|
667 |
//
|
|
668 |
TBool CGlxTextureManagerImpl::GetThumbnailAttributeAndIndexL( TSize aSize,
|
|
669 |
const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId,
|
|
670 |
TInt& aThumbnailIndex, TMPXAttribute& aThumbnailAttribute )
|
|
671 |
{
|
|
672 |
TRACER("CGlxTextureManagerImpl::GetThumbnailAttributeAndIndexL");
|
|
673 |
GLX_LOG_INFO( "CGlxTextureManagerImpl::GetThumbnailAttributeAndIndexL" );
|
|
674 |
aThumbnailIndex = KErrNotFound;
|
|
675 |
|
|
676 |
aThumbnailAttribute = SelectAttributeL(aSize, aMedia); // Find Thumbnail attributes
|
|
677 |
|
|
678 |
TInt i = iThumbnailList.Count();
|
|
679 |
TTime reqTime;
|
|
680 |
aMedia.GetLastModifiedDate(reqTime);
|
|
681 |
while(i > 0 && aThumbnailIndex == KErrNotFound)
|
|
682 |
{
|
|
683 |
--i;
|
|
684 |
if ((iThumbnailList[i].iMediaId == aMedia.Id()) &&
|
|
685 |
(iThumbnailList[i].iIdSpaceId == aIdSpaceId) &&
|
|
686 |
(iThumbnailList[i].iImageDate == reqTime) &&
|
|
687 |
(iThumbnailList[i].iRequiredSize == aSize))
|
|
688 |
{
|
|
689 |
aThumbnailIndex = i;
|
|
690 |
if ( iThumbnailList[aThumbnailIndex].iAttribId == aThumbnailAttribute)
|
|
691 |
{
|
|
692 |
// We have found that the best match already exists
|
|
693 |
// No need to do anything
|
|
694 |
return EFalse;
|
|
695 |
}
|
|
696 |
}
|
|
697 |
}
|
|
698 |
return ETrue;
|
|
699 |
}
|
|
700 |
// -----------------------------------------------------------------------------
|
|
701 |
// CreateNewTextureL
|
|
702 |
// -----------------------------------------------------------------------------
|
|
703 |
CAlfTexture* CGlxTextureManagerImpl::CreateZoomedTextureL()
|
|
704 |
{
|
|
705 |
TRACER("CGlxTextureManagerImpl::CreateZoomedTextureL");
|
|
706 |
TInt count = iZoomedList.Count();
|
|
707 |
TInt index = 0 ;
|
|
708 |
|
|
709 |
for (index = count-1; index >=0 ; index--)
|
|
710 |
{
|
|
711 |
if (NULL == iZoomedList[index].iTexture)
|
|
712 |
{
|
|
713 |
if (NULL != iZoomedList[index].iBitmap)
|
|
714 |
{
|
|
715 |
// If we got this far we need to create a new texture
|
|
716 |
iZoomedList[index].iTextureId = NextTextureId();
|
|
717 |
iZoomedList[index].iTexture = &iAlfTextureManager.CreateTextureL(
|
|
718 |
iZoomedList[index].iTextureId,
|
|
719 |
this,
|
|
720 |
EAlfTextureFlagDefault);
|
|
721 |
return iZoomedList[index].iTexture ;
|
|
722 |
}
|
|
723 |
}
|
|
724 |
}
|
|
725 |
return NULL;
|
|
726 |
}
|
|
727 |
// -----------------------------------------------------------------------------
|
|
728 |
// CreateNewTextureL
|
|
729 |
// -----------------------------------------------------------------------------
|
|
730 |
CAlfTexture& CGlxTextureManagerImpl::CreateNewTextureL( TSize aSize,
|
|
731 |
const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId,
|
|
732 |
MGlxTextureObserver* aObserver, TMPXAttribute& aAttribute,
|
|
733 |
TGlxThumbnailIcon& aThumbData,TBool aIsThumbnailTexture, TBool aScaleGridTnm )
|
|
734 |
{
|
|
735 |
TRACER("CGlxTextureManagerImpl::CreateNewTextureL");
|
|
736 |
// This method only works if the call to CreateTextureL which in turn calls ProvideBitmapL behaves ina synchronous manor
|
|
737 |
|
|
738 |
// First find if there is an existing texture
|
|
739 |
// Find the texture in the iThumbnailList
|
|
740 |
|
|
741 |
// We have 2 scenarios here.
|
|
742 |
// 1) We do not have a thumbnail
|
|
743 |
// 2) The thumbnail we have is not good enough
|
|
744 |
|
|
745 |
aThumbData.iTextureId = NextTextureId();
|
|
746 |
aThumbData.iTexture = NULL;
|
|
747 |
aThumbData.iAttribId = aAttribute;
|
|
748 |
aThumbData.iMediaId = aMedia.Id();
|
|
749 |
aThumbData.iIdSpaceId = aIdSpaceId;
|
|
750 |
//Get the ThumbData creation date
|
|
751 |
aMedia.GetLastModifiedDate(aThumbData.iImageDate);
|
|
752 |
const CGlxThumbnailAttribute* thumb = aMedia.ThumbnailAttribute(aAttribute);
|
|
753 |
__ASSERT_DEBUG(thumb, Panic(EGlxPanicLogicError)); // thumb should not be NULL
|
|
754 |
aThumbData.iBitmap = thumb->iBitmap;
|
|
755 |
CFbsBitmap *scaledBitmap = NULL;
|
|
756 |
|
|
757 |
if(aScaleGridTnm)
|
|
758 |
{
|
|
759 |
#ifdef _DEBUG
|
|
760 |
TTime startTime, stopTime;
|
|
761 |
startTime.HomeTime();
|
|
762 |
#endif
|
|
763 |
TSize origSize;
|
|
764 |
aMedia.GetDimensions(origSize);
|
|
765 |
scaledBitmap = new (ELeave) CFbsBitmap();
|
|
766 |
CleanupStack::PushL(scaledBitmap);
|
|
767 |
ScaleGridTnmToFsL(origSize,aSize,scaledBitmap,thumb);
|
|
768 |
aThumbData.iBitmap = scaledBitmap;
|
|
769 |
|
|
770 |
#ifdef _DEBUG
|
|
771 |
stopTime.HomeTime();
|
|
772 |
GLX_LOG_INFO1("=>GRID TNM SCALE TO FS took <%d> us",
|
|
773 |
(TInt)stopTime.MicroSecondsFrom(startTime).Int64());
|
|
774 |
#endif
|
|
775 |
}
|
|
776 |
|
|
777 |
if( aIsThumbnailTexture )
|
|
778 |
{
|
|
779 |
//Add to the thumbnail list
|
|
780 |
GLX_LOG_INFO("CGlxTextureManagerImpl::CreateNewTextureL iThumbnailList.AppendL");
|
|
781 |
iThumbnailList.AppendL(aThumbData);
|
|
782 |
}
|
|
783 |
else
|
|
784 |
{
|
|
785 |
GLX_LOG_INFO1("CGlxTextureManagerImpl::CreateNewTextureL,count=%d",iZoomedList.Count());
|
|
786 |
iZoomedList.AppendL(aThumbData);
|
|
787 |
}
|
|
788 |
|
|
789 |
// If we got this far we need to create a new texture
|
|
790 |
CAlfTexture* newTexture = &iAlfTextureManager.CreateTextureL(
|
|
791 |
aThumbData.iTextureId,
|
|
792 |
this,
|
|
793 |
EAlfTextureFlagDefault);
|
|
794 |
|
|
795 |
|
|
796 |
if( aIsThumbnailTexture )
|
|
797 |
{
|
|
798 |
GLX_LOG_INFO("CGlxTextureManagerImpl::CreateNewTextureL aIsThumbnailTexture ");
|
|
799 |
TInt index = iThumbnailList.Count()-1;
|
|
800 |
iThumbnailList[index].iTexture = newTexture;
|
|
801 |
iThumbnailList[index].iRequiredSize = aSize;
|
|
802 |
}
|
|
803 |
else
|
|
804 |
{
|
|
805 |
GLX_LOG_INFO("CGlxTextureManagerImpl::CreateNewTextureL else aIsThumbnailTexture ");
|
|
806 |
TInt index = iZoomedList.Count()-1;
|
|
807 |
iZoomedList[index].iTexture = newTexture;
|
|
808 |
iZoomedList[index].iRequiredSize = aSize;
|
|
809 |
iZoomedList[index].iBitmap=NULL;
|
|
810 |
}
|
|
811 |
|
|
812 |
if (aObserver)
|
|
813 |
{
|
|
814 |
GLX_LOG_INFO("CGlxTextureManagerImpl::CreateNewTextureL aObserver ");
|
|
815 |
aThumbData.iObserver = aObserver;
|
|
816 |
aThumbData.iObserver->TextureContentChangedL( ETrue , newTexture);
|
|
817 |
}
|
|
818 |
|
|
819 |
if(scaledBitmap)
|
|
820 |
{
|
|
821 |
CleanupStack::PopAndDestroy(scaledBitmap);
|
|
822 |
}
|
|
823 |
|
|
824 |
return *newTexture;
|
|
825 |
}
|
|
826 |
|
|
827 |
// -----------------------------------------------------------------------------
|
|
828 |
// CreateZoomedTextureL
|
|
829 |
// -----------------------------------------------------------------------------
|
|
830 |
//
|
|
831 |
CAlfTexture& CGlxTextureManagerImpl::CreateZoomedTextureL(
|
|
832 |
const TGlxMedia& aMedia, const TMPXAttribute& aAttribute,
|
|
833 |
TGlxIdSpaceId aIdSpaceId, MGlxTextureObserver* aObserver)
|
|
834 |
{
|
|
835 |
TRACER("CGlxTextureManagerImpl::CreateZoomedTextureL");
|
|
836 |
if(!iZoomDecoder)
|
|
837 |
{
|
|
838 |
GLX_LOG_INFO("CGlxTextureManagerImpl:: CreateZoomedTextureL,iZoomDecoder == NULL");
|
|
839 |
iZoomDecoder = CGlxBitmapDecoderWrapper::NewL(this);
|
|
840 |
}
|
|
841 |
|
|
842 |
TGlxThumbnailIcon aThumbData;
|
|
843 |
|
|
844 |
aThumbData.iTextureId = NextTextureId();
|
|
845 |
aThumbData.iTexture = NULL;
|
|
846 |
aThumbData.iAttribId = aAttribute;
|
|
847 |
aThumbData.iMediaId = aMedia.Id();
|
|
848 |
aThumbData.iIdSpaceId = aIdSpaceId;
|
|
849 |
|
|
850 |
//Add to the thumbnail list
|
|
851 |
iZoomedList.AppendL(aThumbData);
|
|
852 |
|
|
853 |
TInt index = iZoomedList.Count()-1;
|
|
854 |
GLX_LOG_INFO1("CGlxTextureManagerImpl:: CreateZoomedTextureL,index=%d",index);
|
|
855 |
|
|
856 |
iZoomedList[index].iTexture = NULL;
|
|
857 |
aMedia.GetDimensions( iZoomedList[index].iRequiredSize );
|
|
858 |
|
|
859 |
iZoomedList[index].iBitmap=NULL;
|
|
860 |
iZoomedList[index].iObserver = aObserver ;
|
|
861 |
|
|
862 |
iZoomDecoder->DoDecodeImageL(aMedia.Uri(), iZoomedList.Count()-1);
|
|
863 |
return *(iZoomedList[index].iTexture);
|
|
864 |
}
|
|
865 |
|
|
866 |
// -----------------------------------------------------------------------------
|
|
867 |
// CreateAnimatedGifTextureL
|
|
868 |
// -----------------------------------------------------------------------------
|
|
869 |
//
|
|
870 |
CAlfTexture& CGlxTextureManagerImpl::CreateAnimatedGifTextureL(
|
|
871 |
const TDesC& aFilename, const TSize& aSize,const TGlxMedia& aMedia,
|
|
872 |
TGlxIdSpaceId aIdSpaceId)
|
|
873 |
{
|
|
874 |
TRACER("CGlxTextureManagerImpl::CreateAnimatedGifTextureL");
|
|
875 |
TInt thumbnailIndex = KErrNotFound;
|
|
876 |
|
|
877 |
// If the current thumbnail matches what is required then return the current texture otherwise
|
|
878 |
// create a new one.
|
|
879 |
if (!GetAnimatedGifThumbnailIndex( aSize, aMedia, aIdSpaceId,thumbnailIndex))
|
|
880 |
{
|
|
881 |
GLX_LOG_INFO("CreateAnimatedGifTextureL Texture already present");
|
|
882 |
// only texture is missing.
|
|
883 |
if ((NULL == iAnimatedTnmList[thumbnailIndex].iTexture))
|
|
884 |
{
|
|
885 |
CAlfTexture& newTexture = iAlfTextureManager.LoadTextureL(aFilename,aSize,
|
|
886 |
EAlfTextureFlagDefault,iAnimatedTnmList[thumbnailIndex].iTextureId );
|
|
887 |
iAnimatedTnmList[thumbnailIndex].iTexture = &newTexture ;
|
|
888 |
}
|
|
889 |
// While reloading texture, Need to start animaiton with
|
|
890 |
// explicit call as we stopped animation while unloading texture
|
|
891 |
// This is not required when creating a new texture as Alf
|
|
892 |
// starts animation by default on those textures.
|
|
893 |
(iAnimatedTnmList[thumbnailIndex].iTexture)->StartAnimation();
|
|
894 |
return *iAnimatedTnmList[thumbnailIndex].iTexture;
|
|
895 |
}
|
|
896 |
|
|
897 |
TGlxThumbnailIcon thumbData;
|
|
898 |
thumbData.iTextureId = NextTextureId();
|
|
899 |
thumbData.iTexture = NULL;
|
|
900 |
thumbData.iMediaId = aMedia.Id();
|
|
901 |
thumbData.iIdSpaceId = aIdSpaceId;
|
|
902 |
|
|
903 |
iAnimatedTnmList.ReserveL( iAnimatedTnmList.Count() + 1 );
|
|
904 |
|
|
905 |
iAnimatedTnmList.AppendL(thumbData);
|
|
906 |
|
|
907 |
CAlfTexture& newTexture = iAlfTextureManager.LoadTextureL(aFilename,aSize,
|
|
908 |
EAlfTextureFlagDefault,thumbData.iTextureId );
|
|
909 |
|
|
910 |
TInt index = iAnimatedTnmList.Count()-1;
|
|
911 |
iAnimatedTnmList[index].iTexture = &newTexture;
|
|
912 |
iAnimatedTnmList[index].iRequiredSize = aSize;
|
|
913 |
|
|
914 |
return newTexture;
|
|
915 |
}
|
|
916 |
|
|
917 |
|
|
918 |
// -----------------------------------------------------------------------------
|
|
919 |
// UpdateTexture
|
|
920 |
// -----------------------------------------------------------------------------
|
|
921 |
//
|
|
922 |
void CGlxTextureManagerImpl::UpdateTexture()
|
|
923 |
{
|
|
924 |
TRACER("CGlxTextureManagerImpl::UpdateTexture");
|
|
925 |
TInt count = iIconList.Count();
|
|
926 |
for(TInt i = count - 1; i >= 0; i--)
|
|
927 |
{
|
|
928 |
//to-check
|
|
929 |
// TRAP_IGNORE(DoHandleResolutionChangedL(i);)
|
|
930 |
}
|
|
931 |
}
|
|
932 |
|
|
933 |
// -----------------------------------------------------------------------------
|
|
934 |
// HandleResolutionChanged
|
|
935 |
// -----------------------------------------------------------------------------
|
|
936 |
//
|
|
937 |
void CGlxTextureManagerImpl::HandleResolutionChangedL()
|
|
938 |
{
|
|
939 |
TRACER("CGlxTextureManagerImpl::HandleResolutionChangedL");
|
|
940 |
UpdateTexture();
|
|
941 |
}
|
|
942 |
|
|
943 |
// -----------------------------------------------------------------------------
|
|
944 |
// ProvideBitmapL
|
|
945 |
// -----------------------------------------------------------------------------
|
|
946 |
//
|
|
947 |
void CGlxTextureManagerImpl::ProvideBitmapL(TInt aTextureId,
|
|
948 |
CFbsBitmap*& aBitmap,
|
|
949 |
CFbsBitmap*& aMaskBitmap)
|
|
950 |
{
|
|
951 |
TRACER("CGlxTextureManagerImpl::ProvideBitmapL");
|
|
952 |
// Test whether we've already created bitmaps for the given texture id
|
|
953 |
if ( aTextureId == iProvideBitmapHolder.iTextureId )
|
|
954 |
{
|
|
955 |
GLX_LOG_INFO("CGlxTextureManagerImpl::ProvideBitmapL aTextureId");
|
|
956 |
aBitmap = iProvideBitmapHolder.iBitmap;
|
|
957 |
aMaskBitmap = iProvideBitmapHolder.iMaskBitmap;
|
|
958 |
// reset the flags to prevent multiple calls into here
|
|
959 |
iProvideBitmapHolder.iTextureId = KErrNotFound;
|
|
960 |
iProvideBitmapHolder.iBitmap = NULL;
|
|
961 |
iProvideBitmapHolder.iMaskBitmap = NULL;
|
|
962 |
return;
|
|
963 |
}
|
|
964 |
|
|
965 |
// loop to search the zoomed thumbnail list
|
|
966 |
TInt i = iZoomedList.Count();
|
|
967 |
GLX_LOG_INFO1("CGlxTextureManagerImpl::ProvideBitmapL iZoomedList.Count=%d",i);
|
|
968 |
while(i > 0)
|
|
969 |
{
|
|
970 |
--i;
|
|
971 |
if (iZoomedList[i].iTextureId == aTextureId)
|
|
972 |
{
|
|
973 |
// We have found the texture, create a duplicate as alf destroys
|
|
974 |
// the bitmap once the texture's been created.
|
|
975 |
GLX_LOG_INFO1("CGlxTextureManagerImpl::ProvideBitmapL i=%d",i);
|
|
976 |
aBitmap = CreateDuplicateBitmapL( *iZoomedList[i].iBitmap );
|
|
977 |
return;
|
|
978 |
}
|
|
979 |
}
|
|
980 |
// add loop to search the iThumbnailList for the aTextureId
|
|
981 |
i = iThumbnailList.Count();
|
|
982 |
while(i > 0)
|
|
983 |
{
|
|
984 |
--i;
|
|
985 |
if ((iThumbnailList[i].iTextureId == aTextureId))
|
|
986 |
{
|
|
987 |
// We have found the texture, create a duplicate as alf destroys
|
|
988 |
// the bitmap once the texture's been created.
|
|
989 |
aBitmap = CreateDuplicateBitmapL( *iThumbnailList[i].iBitmap );
|
|
990 |
return;
|
|
991 |
}
|
|
992 |
}
|
|
993 |
|
|
994 |
// add loop to search the iDRMGifAnimatedTnmList for the aTextureId
|
|
995 |
i = iDRMGifAnimatedTnmList.Count();
|
|
996 |
while (i > 0)
|
|
997 |
{
|
|
998 |
--i;
|
|
999 |
for(TInt textureCnt=0;textureCnt<KGlxMaxFrameCount;textureCnt++)
|
|
1000 |
{
|
|
1001 |
if (iDRMGifAnimatedTnmList[i].iBitmap[textureCnt] &&
|
|
1002 |
(iDRMGifAnimatedTnmList[i].iTextureId[textureCnt] == aTextureId))
|
|
1003 |
{
|
|
1004 |
// We have found the texture, create a duplicate as alf destroys
|
|
1005 |
// the bitmap once the texture's been created.
|
|
1006 |
aBitmap = CreateDuplicateBitmapL(*iDRMGifAnimatedTnmList[i].iBitmap[textureCnt]);
|
|
1007 |
if(iDRMGifAnimatedTnmList[i].iBitmapMask[textureCnt])
|
|
1008 |
{
|
|
1009 |
aMaskBitmap = CreateDuplicateBitmapL(*iDRMGifAnimatedTnmList[i].iBitmapMask[textureCnt]);
|
|
1010 |
}
|
|
1011 |
return;
|
|
1012 |
}
|
|
1013 |
}
|
|
1014 |
}
|
|
1015 |
|
|
1016 |
// find in iIconList
|
|
1017 |
i = iIconList.Count();
|
|
1018 |
TBool found = EFalse;
|
|
1019 |
TGlxIcon icon;
|
|
1020 |
while(i > 0 && !found)
|
|
1021 |
{
|
|
1022 |
i--;
|
|
1023 |
if(iIconList[i].iTextureId == aTextureId)
|
|
1024 |
{
|
|
1025 |
icon = iIconList[i];
|
|
1026 |
found = ETrue;
|
|
1027 |
}
|
|
1028 |
}
|
|
1029 |
|
|
1030 |
if(!found)
|
|
1031 |
{
|
|
1032 |
User::Leave(KErrNotFound);
|
|
1033 |
}
|
|
1034 |
|
|
1035 |
TInt bitmapId = icon.iBitmapId;
|
|
1036 |
TInt maskId = bitmapId;
|
|
1037 |
if(bitmapId)
|
|
1038 |
{
|
|
1039 |
maskId++;
|
|
1040 |
}
|
|
1041 |
|
|
1042 |
TFileName filename(KNullDesC);
|
|
1043 |
if(icon.iFilenameIndex >= 0)
|
|
1044 |
{
|
|
1045 |
filename = iMifFilenames->MdcaPoint(icon.iFilenameIndex);
|
|
1046 |
}
|
|
1047 |
|
|
1048 |
if(icon.iSetColor)
|
|
1049 |
{
|
|
1050 |
AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
|
|
1051 |
icon.iAvkonSkinId,
|
|
1052 |
icon.iSkinColorId,
|
|
1053 |
icon.iSkinColorIndex,
|
|
1054 |
aBitmap,
|
|
1055 |
aMaskBitmap,
|
|
1056 |
filename,
|
|
1057 |
bitmapId,
|
|
1058 |
maskId,
|
|
1059 |
icon.iDefaultColor );
|
|
1060 |
}
|
|
1061 |
else
|
|
1062 |
{
|
|
1063 |
AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
|
|
1064 |
icon.iAvkonSkinId,
|
|
1065 |
aBitmap,
|
|
1066 |
aMaskBitmap,
|
|
1067 |
filename,
|
|
1068 |
bitmapId,
|
|
1069 |
maskId );
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
// Leave if bitmap or mask is NULL.
|
|
1073 |
|
|
1074 |
if (NULL == aBitmap)
|
|
1075 |
{
|
|
1076 |
User::Leave(KErrNotFound);
|
|
1077 |
}
|
|
1078 |
|
|
1079 |
// set size
|
|
1080 |
// In preference use requested size if there is one
|
|
1081 |
TInt height =TInt(iResUtil->PossToPixels(icon.iHeightInPoss));
|
|
1082 |
TInt width =TInt(iResUtil->PossToPixels(icon.iWidthInPoss));
|
|
1083 |
|
|
1084 |
TSize size(width, height);
|
|
1085 |
|
|
1086 |
// Disable compression so that the bitmap may be able to be
|
|
1087 |
// duplicated inside HUITK when BITGDI renderer is in use.
|
|
1088 |
AknIconUtils::DisableCompression( aBitmap );
|
|
1089 |
|
|
1090 |
if ( size == TSize(0, 0) )
|
|
1091 |
{
|
|
1092 |
// If no requested size use original size of the graphic
|
|
1093 |
TAknContentDimensions origDim;
|
|
1094 |
AknIconUtils::GetContentDimensions(aBitmap, origDim);
|
|
1095 |
size = TSize(origDim.iWidth, origDim.iHeight);
|
|
1096 |
|
|
1097 |
// But if the original size is small make smallest dimension 64
|
|
1098 |
// and keep aspect ratio
|
|
1099 |
if ( size.iHeight < 64 && size.iWidth < 64 )
|
|
1100 |
{
|
|
1101 |
if(origDim.iWidth < origDim.iHeight)
|
|
1102 |
{
|
|
1103 |
size = TSize(64, 64.0F * origDim.iHeight / origDim.iWidth);
|
|
1104 |
}
|
|
1105 |
else
|
|
1106 |
{
|
|
1107 |
size = TSize(64.0F * origDim.iWidth / origDim.iHeight, 64);
|
|
1108 |
}
|
|
1109 |
}
|
|
1110 |
}
|
|
1111 |
AknIconUtils::SetSize(aBitmap, size, EAspectRatioNotPreserved);
|
|
1112 |
}
|
|
1113 |
|
|
1114 |
// -----------------------------------------------------------------------------
|
|
1115 |
// SelectAttributeL
|
|
1116 |
// -----------------------------------------------------------------------------
|
|
1117 |
//
|
|
1118 |
TMPXAttribute CGlxTextureManagerImpl::SelectAttributeL( TSize& aSize,
|
|
1119 |
const TGlxMedia& aMedia )
|
|
1120 |
{
|
|
1121 |
TRACER("CGlxTextureManagerImpl::SelectAttributeL");
|
|
1122 |
const CGlxMedia& media = *aMedia.Properties();
|
|
1123 |
if ( !aMedia.Properties() || media.Count() == 0 )
|
|
1124 |
{
|
|
1125 |
GLX_LOG_INFO("SelectAttributeL - NULL CGlxMedia / No Attribs");
|
|
1126 |
User::Leave( KErrArgument );
|
|
1127 |
}
|
|
1128 |
// first check if DRM protected
|
|
1129 |
TBool drmInvalid = EFalse;
|
|
1130 |
if ( aMedia.GetDrmProtected(drmInvalid) && drmInvalid )
|
|
1131 |
{
|
|
1132 |
// require URI attribute
|
|
1133 |
TMPXGeneralCategory cat = aMedia.Category();
|
|
1134 |
// get URI
|
|
1135 |
const TDesC& uri = aMedia.Uri();
|
|
1136 |
if( (uri.Length() == 0) || (EMPXNoCategory == cat) )
|
|
1137 |
{
|
|
1138 |
User::Leave( KErrArgument );
|
|
1139 |
}
|
|
1140 |
|
|
1141 |
// check if rights have expired
|
|
1142 |
TBool checkViewRights = (cat==EMPXImage);
|
|
1143 |
|
|
1144 |
//Since uri can be either focused or unfocused item
|
|
1145 |
//better call ItemRightsValidityCheckL which doesn't modify lastconsumedUri.
|
|
1146 |
CreateImageViewerInstanceL();
|
|
1147 |
if(iImageViewerInstance->IsPrivate())
|
|
1148 |
{
|
|
1149 |
drmInvalid = !iDrmUtility->ItemRightsValidityCheckL(iImageViewerInstance->ImageFileHandle(), checkViewRights);
|
|
1150 |
}
|
|
1151 |
else
|
|
1152 |
{
|
|
1153 |
drmInvalid = !iDrmUtility->ItemRightsValidityCheckL(uri, checkViewRights);
|
|
1154 |
}
|
|
1155 |
DeleteImageViewerInstance();
|
|
1156 |
CGlxMedia* properties = const_cast<CGlxMedia*>(aMedia.Properties());
|
|
1157 |
if( !drmInvalid )
|
|
1158 |
{
|
|
1159 |
properties->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, EGlxDrmRightsValid);
|
|
1160 |
}
|
|
1161 |
else
|
|
1162 |
{
|
|
1163 |
properties->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, EGlxDrmRightsInvalid);
|
|
1164 |
}
|
|
1165 |
}
|
|
1166 |
|
|
1167 |
// if invalid need dimensions
|
|
1168 |
if ( drmInvalid )
|
|
1169 |
{
|
|
1170 |
TSize dimensions(0,0);
|
|
1171 |
if(!aMedia.GetDimensions(dimensions))
|
|
1172 |
{
|
|
1173 |
User::Leave( KErrArgument );
|
|
1174 |
}
|
|
1175 |
|
|
1176 |
aSize = iDrmUtility->DRMThumbnailSize(dimensions);
|
|
1177 |
}
|
|
1178 |
|
|
1179 |
// Get the index for the attribute
|
|
1180 |
TInt index = GlxThumbnailUtility::ClosestThumbnail( aSize,
|
|
1181 |
media, !drmInvalid );
|
|
1182 |
// check it's valid
|
|
1183 |
if (KErrNotFound == index)
|
|
1184 |
{
|
|
1185 |
GLX_LOG_INFO("GlxThumbnailUtility::ClosestThumbnail fail ");
|
|
1186 |
User::Leave( KErrArgument );
|
|
1187 |
}
|
|
1188 |
|
|
1189 |
return media.Attribute(index);
|
|
1190 |
}
|
|
1191 |
|
|
1192 |
|
|
1193 |
// -----------------------------------------------------------------------------
|
|
1194 |
// CreateDuplicateBitmapL
|
|
1195 |
// -----------------------------------------------------------------------------
|
|
1196 |
//
|
|
1197 |
CFbsBitmap* CGlxTextureManagerImpl::CreateDuplicateBitmapL(CFbsBitmap& aOriginalBitmap )
|
|
1198 |
{
|
|
1199 |
TRACER("CGlxTextureManagerImpl::CreateDuplicateBitmapL");
|
|
1200 |
CFbsBitmap* duplicateBitmap = new( ELeave) CFbsBitmap();
|
|
1201 |
TInt err=duplicateBitmap->Duplicate( aOriginalBitmap.Handle());
|
|
1202 |
if ( err != KErrNone )
|
|
1203 |
{
|
|
1204 |
delete duplicateBitmap;
|
|
1205 |
duplicateBitmap = NULL;
|
|
1206 |
GLX_LOG_INFO1("CGlxTextureManagerImpl::CreateDuplicateBitmapL fail =%d",err);
|
|
1207 |
}
|
|
1208 |
|
|
1209 |
return duplicateBitmap;
|
|
1210 |
}
|
|
1211 |
|
|
1212 |
// -----------------------------------------------------------------------------
|
|
1213 |
// NextTextureId
|
|
1214 |
// -----------------------------------------------------------------------------
|
|
1215 |
//
|
|
1216 |
TInt CGlxTextureManagerImpl::NextTextureId()
|
|
1217 |
{
|
|
1218 |
TRACER("CGlxTextureManagerImpl::NextTextureId");
|
|
1219 |
return ++iNextTextureId;
|
|
1220 |
}
|
|
1221 |
|
|
1222 |
|
|
1223 |
// -----------------------------------------------------------------------------
|
|
1224 |
// HandleBitmapDecodedL
|
|
1225 |
// -----------------------------------------------------------------------------
|
|
1226 |
//
|
|
1227 |
void CGlxTextureManagerImpl::HandleBitmapDecodedL(TInt aThumbnailIndex,CFbsBitmap* aBitmap)
|
|
1228 |
{
|
|
1229 |
TRACER("CGlxTextureManagerImpl::HandleBitmapDecodedL");
|
|
1230 |
CAlfTexture* newTexture = NULL;
|
|
1231 |
TBool textureCreated = ETrue;
|
|
1232 |
TInt textureID = -1;
|
|
1233 |
TInt textureToBeUnloaded = -1;
|
|
1234 |
|
|
1235 |
//check if the image is decoded
|
|
1236 |
if ( aBitmap )
|
|
1237 |
{
|
|
1238 |
iZoomedList[aThumbnailIndex].iBitmap = aBitmap;
|
|
1239 |
|
|
1240 |
CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL();
|
|
1241 |
CleanupClosePushL(*uiUtility);
|
|
1242 |
TBool foregroundStatus = uiUtility->GetForegroundStatus();
|
|
1243 |
CleanupStack::PopAndDestroy(uiUtility);
|
|
1244 |
|
|
1245 |
// Photos not in foreground; do not create zoom texture
|
|
1246 |
if (!foregroundStatus)
|
|
1247 |
{
|
|
1248 |
GLX_LOG_INFO("CGlxTextureManagerImpl HandleBitmapDecodedL - Not in foreground; do not create zoom texture");
|
|
1249 |
return;
|
|
1250 |
}
|
|
1251 |
|
|
1252 |
//if we already have a texture then dont unload the texture before creating
|
|
1253 |
//the next one. It might happen that because of low memory we might not be able
|
|
1254 |
//to create a new texture.
|
|
1255 |
if(iZoomedList[aThumbnailIndex].iTexture)
|
|
1256 |
{
|
|
1257 |
textureID = NextTextureId();
|
|
1258 |
textureToBeUnloaded = iZoomedList[aThumbnailIndex].iTextureId ;
|
|
1259 |
iZoomedList[aThumbnailIndex].iTextureId = textureID ;
|
|
1260 |
}
|
|
1261 |
else
|
|
1262 |
{
|
|
1263 |
textureID = iZoomedList[aThumbnailIndex].iTextureId;
|
|
1264 |
}
|
|
1265 |
|
|
1266 |
TRAPD(err, newTexture = &iAlfTextureManager.CreateTextureL(
|
|
1267 |
textureID, this, EAlfTextureFlagDefault));
|
|
1268 |
if ( KErrNone != err && KErrNoMemory == err )
|
|
1269 |
{
|
|
1270 |
GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded ReleaseRam : START RAM RELEASE");
|
|
1271 |
iCache->ReleaseRAML(ETrue);
|
|
1272 |
TRAPD(err, newTexture = &iAlfTextureManager.CreateTextureL(textureID, this, EAlfTextureFlagDefault));
|
|
1273 |
if ( KErrNone != err && KErrNoMemory == err )
|
|
1274 |
{
|
|
1275 |
GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded CreateTextureL : LOW MEMORY CONDITION");
|
|
1276 |
textureCreated = EFalse;
|
|
1277 |
}
|
|
1278 |
}
|
|
1279 |
}
|
|
1280 |
else
|
|
1281 |
{
|
|
1282 |
textureCreated = EFalse;
|
|
1283 |
}
|
|
1284 |
|
|
1285 |
|
|
1286 |
|
|
1287 |
if (textureCreated && (NULL != newTexture))
|
|
1288 |
{
|
|
1289 |
GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded textureCreated && newTexture");
|
|
1290 |
//If the new texture is created then unload the old texture and store the new texture and textureID.
|
|
1291 |
if(iZoomedList[aThumbnailIndex].iTexture)
|
|
1292 |
{
|
|
1293 |
GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded Unloading Old Texture");
|
|
1294 |
iAlfTextureManager.UnloadTexture(textureToBeUnloaded );
|
|
1295 |
}
|
|
1296 |
iZoomedList[aThumbnailIndex].iTextureId = textureID;
|
|
1297 |
iZoomedList[aThumbnailIndex].iTexture = newTexture;
|
|
1298 |
}
|
|
1299 |
|
|
1300 |
if (iZoomedList[aThumbnailIndex].iObserver)
|
|
1301 |
{
|
|
1302 |
GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded TextureContentChangedL");
|
|
1303 |
iZoomedList[aThumbnailIndex].iObserver->TextureContentChangedL( textureCreated ,iZoomedList[aThumbnailIndex].iTexture);
|
|
1304 |
}
|
|
1305 |
GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecodedL Exit ");
|
|
1306 |
}
|
|
1307 |
|
|
1308 |
// -----------------------------------------------------------------------------
|
|
1309 |
// HandleAttributesAvailableL
|
|
1310 |
// -----------------------------------------------------------------------------
|
|
1311 |
//
|
|
1312 |
void CGlxTextureManagerImpl::HandleAttributesAvailableL(
|
|
1313 |
const TGlxIdSpaceId& /*aIdSpaceId*/, const TGlxMediaId& /*aMediaId*/,
|
|
1314 |
const RArray<TMPXAttribute>& /*aAttributes*/,
|
|
1315 |
const CGlxMedia* /*aMedia*/)
|
|
1316 |
{
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
// -----------------------------------------------------------------------------
|
|
1320 |
// CleanupTextureCacheL
|
|
1321 |
// -----------------------------------------------------------------------------
|
|
1322 |
//
|
|
1323 |
void CGlxTextureManagerImpl::CleanupMedia(const TGlxMediaId& aMediaId)
|
|
1324 |
{
|
|
1325 |
TRACER("CGlxTextureManagerImpl::CleanupMedia");
|
|
1326 |
RemoveTexture(aMediaId, EFalse);
|
|
1327 |
}
|
|
1328 |
|
|
1329 |
// -----------------------------------------------------------------------------
|
|
1330 |
// ScaleGridTnmToFsL
|
|
1331 |
// -----------------------------------------------------------------------------
|
|
1332 |
//
|
|
1333 |
void CGlxTextureManagerImpl::ScaleGridTnmToFsL(TSize aSrcSize, TSize aDestSize,
|
|
1334 |
CFbsBitmap *aScaledBitmap, const CGlxThumbnailAttribute* thumb)
|
|
1335 |
{
|
|
1336 |
TRACER("CGlxTextureManagerImpl::ScaleGridTnmToFsL");
|
|
1337 |
// Scale the Image to required size if the thumbnail is smaller.Instead of Displaying Small thumbnail
|
|
1338 |
// Calculate destination rect to maintain aspect ratio
|
|
1339 |
TReal aspectRatio = (TReal)aDestSize.iWidth/(TReal)aDestSize.iHeight ;
|
|
1340 |
TReal thumbAspectRatio = (TReal)aSrcSize.iWidth/(TReal)aSrcSize.iHeight ;
|
|
1341 |
TSize destinationSize ;
|
|
1342 |
if(thumbAspectRatio >= aspectRatio)
|
|
1343 |
{
|
|
1344 |
destinationSize.iWidth = aDestSize.iWidth ;
|
|
1345 |
destinationSize.iHeight = aDestSize.iWidth*aSrcSize.iHeight/aSrcSize.iWidth ;
|
|
1346 |
}
|
|
1347 |
else
|
|
1348 |
{
|
|
1349 |
destinationSize.iHeight = aDestSize.iHeight ;
|
|
1350 |
destinationSize.iWidth = aDestSize.iHeight*aSrcSize.iWidth/aSrcSize.iHeight ;
|
|
1351 |
}
|
|
1352 |
aScaledBitmap->Create(destinationSize,thumb->iBitmap->DisplayMode());
|
|
1353 |
CFbsBitmapDevice *bitmapDevice = CFbsBitmapDevice::NewL(aScaledBitmap);
|
|
1354 |
CleanupStack::PushL(bitmapDevice);
|
|
1355 |
CFbsBitGc * bitmapGc = CFbsBitGc::NewL();
|
|
1356 |
CleanupStack::PushL(bitmapGc);
|
|
1357 |
bitmapGc->Activate(bitmapDevice);
|
|
1358 |
bitmapGc->DrawBitmap(TRect(destinationSize),thumb->iBitmap);
|
|
1359 |
CleanupStack::PopAndDestroy(bitmapGc);
|
|
1360 |
CleanupStack::PopAndDestroy(bitmapDevice);
|
|
1361 |
GLX_LOG_INFO2("===== Actual Image Size %d x %d",aSrcSize.iWidth,aSrcSize.iHeight);
|
|
1362 |
GLX_LOG_INFO2("===== Scaled Image Size %d x %d",destinationSize.iWidth,destinationSize.iHeight);
|
|
1363 |
}
|
|
1364 |
|
|
1365 |
|
|
1366 |
// -----------------------------------------------------------------------------
|
|
1367 |
// GetAnimatedGifThumbnailIndex
|
|
1368 |
// -----------------------------------------------------------------------------
|
|
1369 |
//
|
|
1370 |
TBool CGlxTextureManagerImpl::GetAnimatedGifThumbnailIndex( TSize aSize,
|
|
1371 |
const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId,
|
|
1372 |
TInt& aThumbnailIndex)
|
|
1373 |
{
|
|
1374 |
TRACER("CGlxTextureManagerImpl::GetAnimatedGifThumbnailIndex");
|
|
1375 |
aThumbnailIndex = KErrNotFound;
|
|
1376 |
|
|
1377 |
TInt i = iAnimatedTnmList.Count();
|
|
1378 |
|
|
1379 |
while(i > 0 && aThumbnailIndex == KErrNotFound)
|
|
1380 |
{
|
|
1381 |
--i;
|
|
1382 |
if ((iAnimatedTnmList[i].iMediaId == aMedia.Id()) &&
|
|
1383 |
(iAnimatedTnmList[i].iIdSpaceId == aIdSpaceId) &&
|
|
1384 |
(iAnimatedTnmList[i].iRequiredSize == aSize))
|
|
1385 |
{
|
|
1386 |
aThumbnailIndex = i;
|
|
1387 |
GLX_LOG_INFO( "GetAnimatedGifThumbnailIndex textureid present" );
|
|
1388 |
// We have found that the best match already exists
|
|
1389 |
// No need to do anything
|
|
1390 |
return EFalse;
|
|
1391 |
}
|
|
1392 |
}
|
|
1393 |
return ETrue;
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
// -----------------------------------------------------------------------------
|
|
1397 |
// CreateImageViewerInstanceL
|
|
1398 |
// -----------------------------------------------------------------------------
|
|
1399 |
//
|
|
1400 |
void CGlxTextureManagerImpl::CreateImageViewerInstanceL()
|
|
1401 |
{
|
|
1402 |
TRACER("CGlxTextureManagerImpl::CreateImageViewerInstanceL");
|
|
1403 |
iImageViewerInstance = CGlxImageViewerManager::InstanceL();
|
|
1404 |
__ASSERT_ALWAYS(iImageViewerInstance, Panic(EGlxPanicNullPointer));
|
|
1405 |
}
|
|
1406 |
|
|
1407 |
// -----------------------------------------------------------------------------
|
|
1408 |
// DeleteImageViewerInstance
|
|
1409 |
// -----------------------------------------------------------------------------
|
|
1410 |
//
|
|
1411 |
void CGlxTextureManagerImpl::DeleteImageViewerInstance()
|
|
1412 |
{
|
|
1413 |
TRACER("CGlxTextureManagerImpl::DeleteImageViewerInstance");
|
|
1414 |
if ( iImageViewerInstance )
|
|
1415 |
{
|
|
1416 |
iImageViewerInstance->DeleteInstance();
|
|
1417 |
}
|
|
1418 |
}
|
|
1419 |
|
|
1420 |
// -----------------------------------------------------------------------------
|
|
1421 |
// AnimateMediaItem
|
|
1422 |
// -----------------------------------------------------------------------------
|
|
1423 |
//
|
|
1424 |
void CGlxTextureManagerImpl::AnimateMediaItem(const TGlxMediaId& aMediaId,
|
|
1425 |
TBool aState)
|
|
1426 |
{
|
|
1427 |
TRACER("CGlxTextureManagerImpl::AnimateMediaItem");
|
|
1428 |
TInt index = iAnimatedTnmList.Find(aMediaId,
|
|
1429 |
&TGlxThumbnailIcon::MatchMediaId);
|
|
1430 |
if (index != KErrNotFound)
|
|
1431 |
{
|
|
1432 |
if (iAnimatedTnmList[index].iTexture)
|
|
1433 |
{
|
|
1434 |
if (aState)
|
|
1435 |
{
|
|
1436 |
GLX_LOG_INFO("AnimateMediaItem - Start animation");
|
|
1437 |
(iAnimatedTnmList[index].iTexture)->StartAnimation();
|
|
1438 |
}
|
|
1439 |
else
|
|
1440 |
{
|
|
1441 |
GLX_LOG_INFO("AnimateMediaItem - Stop animation");
|
|
1442 |
(iAnimatedTnmList[index].iTexture)->StopAnimation();
|
|
1443 |
}
|
|
1444 |
}
|
|
1445 |
}
|
|
1446 |
}
|
|
1447 |
|
|
1448 |
// -----------------------------------------------------------------------------
|
|
1449 |
// CreateDRMAnimatedGifTextureL
|
|
1450 |
// -----------------------------------------------------------------------------
|
|
1451 |
//
|
|
1452 |
CAlfTexture& CGlxTextureManagerImpl::CreateDRMAnimatedGifTextureL(const TGlxMedia& aMedia,
|
|
1453 |
TGlxIdSpaceId aIdSpaceId,TInt aFrameNumber, CFbsBitmap* aBitmap, CFbsBitmap* aBitmapMask)
|
|
1454 |
{
|
|
1455 |
TRACER("CGlxTextureManagerImpl::CreateDRMAnimatedGifTextureL");
|
|
1456 |
TInt thumbnailIndex = KErrNotFound;
|
|
1457 |
|
|
1458 |
// If the current thumbnail matches what is required then return the current texture otherwise
|
|
1459 |
// create a new one.
|
|
1460 |
if (!GetDRMAnimatedGifThumbnailIndex( aMedia, aIdSpaceId,thumbnailIndex))
|
|
1461 |
{
|
|
1462 |
GLX_LOG_INFO("CreateDRMAnimatedGifTextureL Texture already present");
|
|
1463 |
// only texture is missing.
|
|
1464 |
if ((NULL == iDRMGifAnimatedTnmList[thumbnailIndex].iTexture[aFrameNumber]))
|
|
1465 |
{
|
|
1466 |
if(NULL == iDRMGifAnimatedTnmList[thumbnailIndex].iBitmap[aFrameNumber])
|
|
1467 |
{
|
|
1468 |
iDRMGifAnimatedTnmList[thumbnailIndex].iTextureId[aFrameNumber] = NextTextureId();
|
|
1469 |
iDRMGifAnimatedTnmList[thumbnailIndex].iBitmap[aFrameNumber] = aBitmap;
|
|
1470 |
iDRMGifAnimatedTnmList[thumbnailIndex].iBitmapMask[aFrameNumber] = aBitmapMask;
|
|
1471 |
}
|
|
1472 |
CAlfTexture* newTexture = &iAlfTextureManager.CreateTextureL(
|
|
1473 |
iDRMGifAnimatedTnmList[thumbnailIndex].iTextureId[aFrameNumber],
|
|
1474 |
this,
|
|
1475 |
EAlfTextureFlagDefault);
|
|
1476 |
iDRMGifAnimatedTnmList[thumbnailIndex].iTexture[aFrameNumber] = newTexture;
|
|
1477 |
}
|
|
1478 |
return *iDRMGifAnimatedTnmList[thumbnailIndex].iTexture[aFrameNumber];
|
|
1479 |
}
|
|
1480 |
|
|
1481 |
TGlxDRMGifThumbnailIcon thumbData;
|
|
1482 |
thumbData.iTextureId[aFrameNumber] = NextTextureId();
|
|
1483 |
thumbData.iMediaId = aMedia.Id();
|
|
1484 |
thumbData.iIdSpaceId = aIdSpaceId;
|
|
1485 |
for(TInt i=0;i<KGlxMaxFrameCount;i++)
|
|
1486 |
{
|
|
1487 |
thumbData.iTexture[i] = NULL;
|
|
1488 |
thumbData.iBitmap[i] = NULL;
|
|
1489 |
thumbData.iBitmapMask[i] = NULL;
|
|
1490 |
}
|
|
1491 |
thumbData.iBitmap[aFrameNumber] = aBitmap;
|
|
1492 |
thumbData.iBitmapMask[aFrameNumber] = aBitmapMask;
|
|
1493 |
|
|
1494 |
iDRMGifAnimatedTnmList.ReserveL( iDRMGifAnimatedTnmList.Count() + 1 );
|
|
1495 |
|
|
1496 |
iDRMGifAnimatedTnmList.AppendL(thumbData);
|
|
1497 |
|
|
1498 |
CAlfTexture* newTexture = &iAlfTextureManager.CreateTextureL(
|
|
1499 |
thumbData.iTextureId[aFrameNumber],
|
|
1500 |
this,
|
|
1501 |
EAlfTextureFlagDefault);
|
|
1502 |
|
|
1503 |
TInt index = iDRMGifAnimatedTnmList.Count()-1;
|
|
1504 |
iDRMGifAnimatedTnmList[index].iTexture[aFrameNumber] = newTexture;
|
|
1505 |
|
|
1506 |
return *newTexture;
|
|
1507 |
}
|
|
1508 |
|
|
1509 |
|
|
1510 |
// -----------------------------------------------------------------------------
|
|
1511 |
// GetAnimatedGifThumbnailIndex
|
|
1512 |
// -----------------------------------------------------------------------------
|
|
1513 |
//
|
|
1514 |
TBool CGlxTextureManagerImpl::GetDRMAnimatedGifThumbnailIndex(const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId,
|
|
1515 |
TInt& aThumbnailIndex)
|
|
1516 |
{
|
|
1517 |
TRACER("CGlxTextureManagerImpl::GetDRMAnimatedGifThumbnailIndex");
|
|
1518 |
aThumbnailIndex = KErrNotFound;
|
|
1519 |
|
|
1520 |
TInt i = iDRMGifAnimatedTnmList.Count();
|
|
1521 |
|
|
1522 |
while (i > 0 && aThumbnailIndex == KErrNotFound)
|
|
1523 |
{
|
|
1524 |
--i;
|
|
1525 |
if ((iDRMGifAnimatedTnmList[i].iMediaId == aMedia.Id())
|
|
1526 |
&& (iDRMGifAnimatedTnmList[i].iIdSpaceId == aIdSpaceId))
|
|
1527 |
{
|
|
1528 |
aThumbnailIndex = i;
|
|
1529 |
GLX_LOG_INFO( "GetDRMAnimatedGifThumbnailIndex textureid present" );
|
|
1530 |
// We have found that the best match already exists
|
|
1531 |
// No need to do anything
|
|
1532 |
return EFalse;
|
|
1533 |
}
|
|
1534 |
}
|
|
1535 |
return ETrue;
|
|
1536 |
}
|