|
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 "mglxtextureobserver.h" |
|
43 |
|
44 namespace |
|
45 { |
|
46 const TInt KGlxFirstAlfThumbnailTextureId = 0x10000001; |
|
47 const TInt KGlxLastAlfThumbnailTextureId = 0x20000000; |
|
48 const TInt KGlxFirstThumbnailTextureId = 0x20000001; |
|
49 /** Bitmap size for flat (solid colour) textures */ |
|
50 const TInt KGlxFlatTextureSize = 64; |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // Constructor |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CGlxTextureManagerImpl::CGlxTextureManagerImpl |
|
59 (CAlfTextureManager& aAlfTextureManager) : |
|
60 iAlfTextureManager(aAlfTextureManager), |
|
61 iNextTextureId( KGlxFirstThumbnailTextureId ) |
|
62 { |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // Destructor |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CGlxTextureManagerImpl::~CGlxTextureManagerImpl() |
|
70 { |
|
71 TRACER("CGlxTextureManagerImpl::~CGlxTextureManagerImpl"); |
|
72 |
|
73 // delete other icon textures |
|
74 // iIconLIst should deleted only once in destructor as |
|
75 // they are using in full applicaiton |
|
76 TInt count = iIconList.Count(); |
|
77 for(TInt i = count - 1; i >= 0; i--) |
|
78 { |
|
79 delete iIconList[i].iTexture; |
|
80 } |
|
81 iIconList.Close(); |
|
82 |
|
83 iThumbnailList.Close(); |
|
84 |
|
85 // delete zoom textures |
|
86 count = iZoomedList.Count(); |
|
87 GLX_LOG_INFO1("CGlxTextureManagerImpl iZoomedList.Count=%d",count); |
|
88 for(TInt i = count - 1; i >= 0; i--) |
|
89 { |
|
90 GLX_LOG_INFO1("CGlxTextureManagerImpldeleted i=%d",i); |
|
91 delete iZoomedList[i].iTexture; |
|
92 } |
|
93 iZoomedList.Close(); |
|
94 |
|
95 delete iMifFilenames; |
|
96 |
|
97 if ( iDrmUtility ) |
|
98 { |
|
99 iDrmUtility->Close(); |
|
100 } |
|
101 |
|
102 if ( iCache ) |
|
103 { |
|
104 iCache->RemoveObserver(this); |
|
105 iCache->Close(); |
|
106 } |
|
107 |
|
108 if ( iResUtil ) |
|
109 { |
|
110 iResUtil->RemoveObserver(*this); |
|
111 iResUtil->Close(); |
|
112 } |
|
113 if(iZoomDecoder) |
|
114 { |
|
115 delete iZoomDecoder; |
|
116 } |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // NewL |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 CGlxTextureManagerImpl* CGlxTextureManagerImpl::NewL( |
|
124 CAlfTextureManager& aAlfTextureManager) |
|
125 { |
|
126 TRACER("CGlxTextureManagerImpl::NewL"); |
|
127 CGlxTextureManagerImpl* self = CGlxTextureManagerImpl::NewLC(aAlfTextureManager); |
|
128 CleanupStack::Pop(self); |
|
129 return self; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // NewLC |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 CGlxTextureManagerImpl* CGlxTextureManagerImpl::NewLC( |
|
137 CAlfTextureManager& aAlfTextureManager) |
|
138 { |
|
139 TRACER("CGlxTextureManagerImpl::NewLC"); |
|
140 CGlxTextureManagerImpl* self = |
|
141 new (ELeave) CGlxTextureManagerImpl(aAlfTextureManager); |
|
142 CleanupStack::PushL(self); |
|
143 self->ConstructL(); |
|
144 return self; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // ConstructL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CGlxTextureManagerImpl::ConstructL() |
|
152 { |
|
153 TRACER("CGlxTextureManagerImpl::ConstructL"); |
|
154 iMifFilenames = new (ELeave) CDesCArrayFlat(2); |
|
155 |
|
156 // get handle to DRM utility |
|
157 iDrmUtility = CGlxDRMUtility::InstanceL(); |
|
158 // get handle to the media cache |
|
159 iCache = MGlxCache::InstanceL(); |
|
160 iCache->AddObserverL(this); |
|
161 |
|
162 // Get instance of Resolution utility and register for notification of |
|
163 // resolution changes |
|
164 /// @todo implement CGlxResolutionUtility this later |
|
165 iResUtil = CGlxResolutionUtility::InstanceL(); |
|
166 iResUtil->AddObserverL(*this); |
|
167 // Set the TextureId range. Now we can set our own ID outside this Range |
|
168 iAlfTextureManager.SetAutomaticTextureIdRange( |
|
169 KGlxFirstAlfThumbnailTextureId, |
|
170 KGlxLastAlfThumbnailTextureId); |
|
171 } |
|
172 |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // TextureNeedsUpdating |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 TBool CGlxTextureManagerImpl::TextureNeedsUpdating( TGlxMedia aMedia, |
|
179 TGlxIdSpaceId aIdSpaceId, const TSize& aRequiredSize ) |
|
180 { |
|
181 TRACER("CGlxTextureManagerImpl::TextureNeedsUpdating"); |
|
182 TInt thumbnailIndex = KErrNotFound; |
|
183 TMPXAttribute thumbNailAttribute( 0, 0 ); |
|
184 TBool updateTexture = ETrue; |
|
185 TRAPD( err, updateTexture = GetThumbnailAttributeAndIndexL( aRequiredSize, |
|
186 aMedia, aIdSpaceId, thumbnailIndex, thumbNailAttribute ) ); |
|
187 // don't update the texture if there's an error |
|
188 return ( err == KErrNone ? updateTexture : EFalse ); |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CreateIconTextureL |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 CAlfTexture& CGlxTextureManagerImpl::CreateIconTextureL( |
|
196 const TAknsItemID& aSkinID, |
|
197 TInt aIconResourceId, |
|
198 const TDesC& aFilename, |
|
199 TBool aSetColor, |
|
200 TRgb aDefaultColor, |
|
201 const TAknsItemID& aSkinColorId, |
|
202 TInt aSkinColorIndex, |
|
203 TSize aRequestedSize) |
|
204 { |
|
205 TRACER("CGlxTextureManagerImpl::CreateIconTextureL"); |
|
206 // Convert size to POSS |
|
207 TReal32 heightInPoss = |
|
208 iResUtil->PixelsToPoss(TReal32(aRequestedSize.iHeight)); |
|
209 |
|
210 TReal32 widthInPoss = |
|
211 iResUtil->PixelsToPoss(TReal32(aRequestedSize.iWidth)); |
|
212 |
|
213 |
|
214 CAlfTexture* texture = NULL; |
|
215 //search array for existing item |
|
216 TInt i = iIconList.Count(); |
|
217 while(i > 0 && !texture) |
|
218 { |
|
219 i--; |
|
220 TGlxIcon icon = iIconList[i]; |
|
221 if( icon.iAvkonSkinId == aSkinID && |
|
222 icon.iBitmapId == aIconResourceId && |
|
223 icon.iSetColor == aSetColor && |
|
224 icon.iDefaultColor == aDefaultColor && |
|
225 icon.iSkinColorId == aSkinColorId && |
|
226 icon.iSkinColorIndex == aSkinColorIndex && |
|
227 icon.iHeightInPoss == heightInPoss && |
|
228 icon.iWidthInPoss == widthInPoss ) |
|
229 { |
|
230 // also compare file names |
|
231 TFileName filename(KNullDesC); |
|
232 if(icon.iFilenameIndex >= 0) |
|
233 { |
|
234 filename = iMifFilenames->MdcaPoint(icon.iFilenameIndex); |
|
235 } |
|
236 if(0 == filename.CompareF(aFilename) ) |
|
237 { |
|
238 // match found - use existing texture |
|
239 texture = icon.iTexture; |
|
240 } |
|
241 } |
|
242 } |
|
243 |
|
244 if(!texture) |
|
245 { |
|
246 // existing texture not found - prepare to create new one |
|
247 TInt filenameIndex = -1; |
|
248 if(aFilename.Length() > 0) |
|
249 { |
|
250 // is filename already in filename list |
|
251 if(iMifFilenames->MdcaCount()) |
|
252 { |
|
253 iMifFilenames->Find(aFilename, filenameIndex); |
|
254 if(filenameIndex == iMifFilenames->MdcaCount()) |
|
255 { |
|
256 filenameIndex = -1; |
|
257 } |
|
258 } |
|
259 if(filenameIndex < 0) |
|
260 { |
|
261 // name not in list. Add it |
|
262 iMifFilenames->AppendL(aFilename); |
|
263 filenameIndex = iMifFilenames->MdcaCount() - 1; |
|
264 } |
|
265 } |
|
266 // Create new icon entry |
|
267 TGlxIcon icon; |
|
268 icon.iTextureId = NextTextureId(); |
|
269 icon.iTexture = NULL; |
|
270 icon.iAvkonSkinId = aSkinID; |
|
271 icon.iBitmapId = aIconResourceId; |
|
272 icon.iFilenameIndex = filenameIndex; |
|
273 icon.iSetColor = aSetColor; |
|
274 icon.iDefaultColor = aDefaultColor; |
|
275 icon.iSkinColorId = aSkinColorId; |
|
276 icon.iSkinColorIndex = aSkinColorIndex; |
|
277 icon.iHeightInPoss = heightInPoss; |
|
278 icon.iWidthInPoss = widthInPoss; |
|
279 |
|
280 // add to list so ProvideBitmapL can use it |
|
281 iIconList.AppendL(icon); |
|
282 |
|
283 // trap create texture |
|
284 TRAPD(err, texture = &iAlfTextureManager.CreateTextureL( |
|
285 icon.iTextureId, |
|
286 this, |
|
287 EAlfTextureFlagDefault)); |
|
288 if(err) |
|
289 { |
|
290 // if error delete entry and leave |
|
291 iIconList.Remove(iIconList.Count() - 1); |
|
292 User::Leave(err); |
|
293 } |
|
294 else |
|
295 { |
|
296 // if no error add texture to entry |
|
297 iIconList[iIconList.Count() - 1].iTexture = texture; |
|
298 } |
|
299 } |
|
300 |
|
301 User::LeaveIfNull(texture); //should not be possible |
|
302 return *texture; |
|
303 } |
|
304 |
|
305 |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // CreateNewTextureForMediaL |
|
309 // ----------------------------------------------------------------------------- |
|
310 // |
|
311 CAlfTexture& CGlxTextureManagerImpl::CreateNewTextureForMediaL( |
|
312 TSize aSize, |
|
313 const TGlxMedia& aMedia, |
|
314 const TGlxIdSpaceId& aIdSpaceId, |
|
315 MGlxTextureObserver* aObserver, |
|
316 TBool aScaleGridTnm) |
|
317 { |
|
318 TRACER("CGlxTextureManagerImpl::CreateNewTextureForMediaL"); |
|
319 TInt thumbnailIndex = KErrNotFound; |
|
320 TMPXAttribute thumbNailAttribute(0,0); |
|
321 TGlxThumbnailIcon thumbData; |
|
322 |
|
323 // If the current thumbnail matches what is required then return the current texture otherwise |
|
324 // create a new one. |
|
325 if (!GetThumbnailAttributeAndIndexL(aSize, aMedia, aIdSpaceId, thumbnailIndex, thumbNailAttribute)) |
|
326 { |
|
327 return *iThumbnailList[thumbnailIndex].iTexture; |
|
328 } |
|
329 |
|
330 // We have 2 scenarios here. |
|
331 // 1) We do not have a thumbnail |
|
332 // 2) The thumbnail we have is not good enough |
|
333 iThumbnailList.ReserveL( iThumbnailList.Count() + 1 ); |
|
334 |
|
335 CAlfTexture& texture = CreateNewTextureL(aSize, aMedia, aIdSpaceId, |
|
336 aObserver, thumbNailAttribute, thumbData,ETrue,aScaleGridTnm); |
|
337 |
|
338 |
|
339 if ( thumbnailIndex != KErrNotFound ) |
|
340 { |
|
341 // A new texture was created so remove the old one and |
|
342 // update the thumbnail list. |
|
343 iAlfTextureManager.UnloadTexture(iThumbnailList[thumbnailIndex].iTextureId); |
|
344 iThumbnailList.Remove(thumbnailIndex); |
|
345 GLX_LOG_INFO("CGlxTextureManagerImpl CreateNewTextureForMediaL UnloadTexture "); |
|
346 } |
|
347 |
|
348 return texture; |
|
349 } |
|
350 |
|
351 // ----------------------------------------------------------------------------- |
|
352 // CreateFlatColourTextureL |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 CAlfTexture& CGlxTextureManagerImpl::CreateFlatColourTextureL( TRgb aColour ) |
|
356 { |
|
357 TRACER("CGlxTextureManagerImpl::CreateFlatColourTextureL"); |
|
358 // Create a picture with the colour |
|
359 CFbsBitmap* picture = new (ELeave) CFbsBitmap; |
|
360 CleanupStack::PushL(picture); |
|
361 User::LeaveIfError(picture->Create(TSize(KGlxFlatTextureSize, |
|
362 KGlxFlatTextureSize), EColor64K ) ); |
|
363 |
|
364 CFbsBitmapDevice* drawBufDevice = CFbsBitmapDevice::NewL(picture); |
|
365 CleanupStack::PushL(drawBufDevice); |
|
366 |
|
367 CFbsBitGc* drawBufContext; |
|
368 User::LeaveIfError(drawBufDevice->CreateContext(drawBufContext)); |
|
369 CleanupStack::PushL(drawBufContext); |
|
370 |
|
371 // draw the color |
|
372 drawBufContext->Activate(drawBufDevice); |
|
373 drawBufContext->SetBrushColor(aColour); |
|
374 drawBufContext->Clear(); |
|
375 |
|
376 TInt alpha = aColour.Alpha(); |
|
377 |
|
378 CleanupStack::PopAndDestroy(drawBufContext); |
|
379 CleanupStack::PopAndDestroy(drawBufDevice); |
|
380 |
|
381 CFbsBitmap* mask = NULL; |
|
382 if( alpha != 0 ) |
|
383 { |
|
384 mask = new (ELeave) CFbsBitmap(); |
|
385 CleanupStack::PushL( mask ); |
|
386 User::LeaveIfError( mask->Create(TSize( KGlxFlatTextureSize, |
|
387 KGlxFlatTextureSize ), EGray256 )); |
|
388 |
|
389 CFbsBitmapDevice* maskBufDevice = CFbsBitmapDevice::NewL( mask ); |
|
390 CleanupStack::PushL( maskBufDevice ); |
|
391 |
|
392 CFbsBitGc* maskBufContext = NULL; |
|
393 User::LeaveIfError( maskBufDevice->CreateContext( maskBufContext ) ); |
|
394 CleanupStack::PushL( maskBufContext ); |
|
395 |
|
396 // draw the mask |
|
397 maskBufContext->Activate(maskBufDevice); |
|
398 maskBufContext->SetBrushColor( TRgb::Color256( alpha ) ); |
|
399 maskBufContext->Clear(); |
|
400 |
|
401 CleanupStack::PopAndDestroy( maskBufContext ); |
|
402 CleanupStack::PopAndDestroy( maskBufDevice ); |
|
403 } |
|
404 |
|
405 // Manage the texture ids ourself. Get the next id and store the |
|
406 // associated bitmap and mask to ensure that we supply the correct bitmaps |
|
407 // when alf calls back to ProvideBitmap |
|
408 TInt nextTextureId = NextTextureId(); |
|
409 iProvideBitmapHolder.iTextureId = nextTextureId; |
|
410 iProvideBitmapHolder.iBitmap = picture; |
|
411 iProvideBitmapHolder.iMaskBitmap = mask; |
|
412 |
|
413 CAlfTexture& newTexture = iAlfTextureManager.CreateTextureL( |
|
414 nextTextureId, |
|
415 this, |
|
416 EAlfTextureFlagDefault ); |
|
417 // don't want alf to delete this texture |
|
418 newTexture.SetPriority( EAlfTexturePriorityHighest ); |
|
419 |
|
420 // if we had alpha, release the mask |
|
421 if( alpha != 0 ) |
|
422 { |
|
423 CleanupStack::Pop( mask ); |
|
424 } |
|
425 |
|
426 CleanupStack::Pop( picture ); |
|
427 |
|
428 return newTexture; |
|
429 } |
|
430 |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // RemoveTexture |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 void CGlxTextureManagerImpl::RemoveTexture( const CAlfTexture& aTexture ) |
|
437 { |
|
438 TRACER("CGlxTextureManagerImpl::RemoveTexture"); |
|
439 // Find the texture in the iThumbnailList |
|
440 TInt index = iThumbnailList.Find( aTexture, &TGlxThumbnailIcon::MatchTexture ); |
|
441 if ( index != KErrNotFound ) |
|
442 { |
|
443 iThumbnailList.Remove( index ); |
|
444 iAlfTextureManager.UnloadTexture( aTexture.Id() ); |
|
445 } |
|
446 else |
|
447 { |
|
448 // Find the texture in the zoomed list |
|
449 index = iZoomedList.Find( aTexture, &TGlxThumbnailIcon::MatchTexture ); |
|
450 GLX_LOG_INFO1("CGlxTextureManagerImpl RemoveTexture index=%d",index); |
|
451 if ( index != KErrNotFound ) |
|
452 { |
|
453 GLX_LOG_INFO("CGlxTextureManagerImpl RemoveTexture index != KErrNotFound"); |
|
454 iAlfTextureManager.UnloadTexture( aTexture.Id() ); |
|
455 if(iZoomedList[index].iBitmap) |
|
456 { |
|
457 GLX_LOG_INFO("CGlxTextureManagerImpl RemoveTexture iZoomedList[index].iBitmap delete"); |
|
458 delete iZoomedList[index].iBitmap; |
|
459 iZoomedList[index].iBitmap=NULL; |
|
460 iZoomedList.Remove( index ); |
|
461 } |
|
462 } |
|
463 // iIconLIst should deleted only once in destructor as |
|
464 // they are using in full applicaiton |
|
465 } |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // RemoveZoomList |
|
470 // ----------------------------------------------------------------------------- |
|
471 // |
|
472 void CGlxTextureManagerImpl::RemoveZoomList() |
|
473 { |
|
474 TRACER("CGlxTextureManagerImpl::RemoveZoomList"); |
|
475 TInt count = iZoomedList.Count(); |
|
476 GLX_LOG_INFO1("CGlxTextureManagerImpl RemoveZoomList Count()=%d",count); |
|
477 if(iZoomDecoder) |
|
478 { |
|
479 iZoomDecoder->Cancel(); |
|
480 } |
|
481 for(TInt i = count - 1; i >= 0; i--) |
|
482 { |
|
483 iAlfTextureManager.UnloadTexture( iZoomedList[i].iTextureId ); |
|
484 if( iZoomedList[i].iBitmap) |
|
485 { |
|
486 GLX_LOG_INFO("CGlxTextureManagerImpl RemoveZoomList delete iZoomedList[i]"); |
|
487 delete iZoomedList[i].iBitmap; |
|
488 iZoomedList[i].iBitmap=NULL; |
|
489 } |
|
490 iZoomedList.Remove( i ); |
|
491 } |
|
492 iZoomedList.Reset(); |
|
493 |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // RemoveTexture Using TGlxMediaId& |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 void CGlxTextureManagerImpl::RemoveTexture(const TGlxMediaId& aMediaId,TBool aAllTexture ) |
|
501 { |
|
502 TRACER("CGlxTextureManagerImpl::RemoveTexture 2"); |
|
503 //Bug fix for PKAA-7NRBYZ - added bAllTexture param |
|
504 // Find the texture in the iThumbnailList |
|
505 TInt i = iThumbnailList.Count(); |
|
506 while(i > 0) |
|
507 { |
|
508 --i; |
|
509 if (iThumbnailList[i].iMediaId == aMediaId) |
|
510 { |
|
511 TInt aTexture = iThumbnailList[i].iTextureId; |
|
512 iThumbnailList.Remove(i); |
|
513 iAlfTextureManager.UnloadTexture(aTexture ); |
|
514 //Bug fix for PKAA-7NRBYZ - Delete all the texture only if it is asked. |
|
515 if(!aAllTexture) |
|
516 break; |
|
517 } |
|
518 } |
|
519 } |
|
520 // ----------------------------------------------------------------------------- |
|
521 // GetThumbnailAttributeAndIndexL |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 TBool CGlxTextureManagerImpl::GetThumbnailAttributeAndIndexL( TSize aSize, |
|
525 const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId, |
|
526 TInt& aThumbnailIndex, TMPXAttribute& aThumbnailAttribute ) |
|
527 { |
|
528 TRACER("CGlxTextureManagerImpl::GetThumbnailAttributeAndIndexL"); |
|
529 GLX_LOG_INFO( "CGlxTextureManagerImpl::GetThumbnailAttributeAndIndexL" ); |
|
530 aThumbnailIndex = KErrNotFound; |
|
531 |
|
532 aThumbnailAttribute = SelectAttributeL(aSize, aMedia); // Find Thumbnail attributes |
|
533 |
|
534 TInt i = iThumbnailList.Count(); |
|
535 TTime reqTime; |
|
536 aMedia.GetLastModifiedDate(reqTime); |
|
537 while(i > 0 && aThumbnailIndex == KErrNotFound) |
|
538 { |
|
539 --i; |
|
540 if ((iThumbnailList[i].iMediaId == aMedia.Id()) && |
|
541 (iThumbnailList[i].iIdSpaceId == aIdSpaceId) && |
|
542 (iThumbnailList[i].iImageDate == reqTime) && |
|
543 (iThumbnailList[i].iRequiredSize == aSize)) |
|
544 { |
|
545 aThumbnailIndex = i; |
|
546 if ( iThumbnailList[aThumbnailIndex].iAttribId == aThumbnailAttribute) |
|
547 { |
|
548 // We have found that the best match already exists |
|
549 // No need to do anything |
|
550 return EFalse; |
|
551 } |
|
552 } |
|
553 } |
|
554 |
|
555 return ETrue; |
|
556 } |
|
557 |
|
558 // ----------------------------------------------------------------------------- |
|
559 // CreateNewTextureL |
|
560 // ----------------------------------------------------------------------------- |
|
561 CAlfTexture& CGlxTextureManagerImpl::CreateNewTextureL( TSize aSize, |
|
562 const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId, |
|
563 MGlxTextureObserver* aObserver, TMPXAttribute& aAttribute, |
|
564 TGlxThumbnailIcon& aThumbData,TBool aIsThumbnailTexture, TBool aScaleGridTnm ) |
|
565 { |
|
566 TRACER("CGlxTextureManagerImpl::CreateNewTextureL"); |
|
567 // This method only works if the call to CreateTextureL which in turn calls ProvideBitmapL behaves ina synchronous manor |
|
568 |
|
569 // First find if there is an existing texture |
|
570 // Find the texture in the iThumbnailList |
|
571 |
|
572 // We have 2 scenarios here. |
|
573 // 1) We do not have a thumbnail |
|
574 // 2) The thumbnail we have is not good enough |
|
575 |
|
576 aThumbData.iTextureId = NextTextureId(); |
|
577 aThumbData.iTexture = NULL; |
|
578 aThumbData.iAttribId = aAttribute; |
|
579 aThumbData.iMediaId = aMedia.Id(); |
|
580 aThumbData.iIdSpaceId = aIdSpaceId; |
|
581 //Get the ThumbData creation date |
|
582 aMedia.GetLastModifiedDate(aThumbData.iImageDate); |
|
583 const CGlxThumbnailAttribute* thumb = aMedia.ThumbnailAttribute(aAttribute); |
|
584 __ASSERT_DEBUG(thumb, Panic(EGlxPanicLogicError)); // thumb should not be NULL |
|
585 aThumbData.iBitmap = thumb->iBitmap; |
|
586 CFbsBitmap *scaledBitmap = NULL; |
|
587 |
|
588 if(aScaleGridTnm) |
|
589 { |
|
590 #ifdef _DEBUG |
|
591 TTime startTime, stopTime; |
|
592 startTime.HomeTime(); |
|
593 #endif |
|
594 TSize origSize; |
|
595 aMedia.GetDimensions(origSize); |
|
596 scaledBitmap = new (ELeave) CFbsBitmap(); |
|
597 CleanupStack::PushL(scaledBitmap); |
|
598 ScaleGridTnmToFsL(origSize,aSize,scaledBitmap,thumb); |
|
599 aThumbData.iBitmap = scaledBitmap; |
|
600 |
|
601 #ifdef _DEBUG |
|
602 stopTime.HomeTime(); |
|
603 GLX_LOG_INFO1("=>GRID TNM SCALE TO FS took <%d> us", |
|
604 (TInt)stopTime.MicroSecondsFrom(startTime).Int64()); |
|
605 #endif |
|
606 } |
|
607 |
|
608 if( aIsThumbnailTexture ) |
|
609 { |
|
610 //Add to the thumbnail list |
|
611 GLX_LOG_INFO("CGlxTextureManagerImpl::CreateNewTextureL iThumbnailList.Append "); |
|
612 iThumbnailList.Append(aThumbData); |
|
613 } |
|
614 else |
|
615 { |
|
616 GLX_LOG_INFO1("CGlxTextureManagerImpl::CreateNewTextureL,count=%d",iZoomedList.Count()); |
|
617 iZoomedList.Append(aThumbData); |
|
618 } |
|
619 |
|
620 // If we got this far we need to create a new texture |
|
621 CAlfTexture* newTexture = &iAlfTextureManager.CreateTextureL( |
|
622 aThumbData.iTextureId, |
|
623 this, |
|
624 EAlfTextureFlagDefault); |
|
625 |
|
626 |
|
627 if( aIsThumbnailTexture ) |
|
628 { |
|
629 GLX_LOG_INFO("CGlxTextureManagerImpl::CreateNewTextureL aIsThumbnailTexture "); |
|
630 TInt index = iThumbnailList.Count()-1; |
|
631 iThumbnailList[index].iTexture = newTexture; |
|
632 iThumbnailList[index].iRequiredSize = aSize; |
|
633 } |
|
634 |
|
635 else |
|
636 { |
|
637 GLX_LOG_INFO("CGlxTextureManagerImpl::CreateNewTextureL else aIsThumbnailTexture "); |
|
638 TInt index = iZoomedList.Count()-1; |
|
639 iZoomedList[index].iTexture = newTexture; |
|
640 iZoomedList[index].iRequiredSize = aSize; |
|
641 iZoomedList[index].iBitmap=NULL; |
|
642 } |
|
643 |
|
644 if (aObserver) |
|
645 { |
|
646 GLX_LOG_INFO("CGlxTextureManagerImpl::CreateNewTextureL aObserver "); |
|
647 aThumbData.iObserver = aObserver; |
|
648 aThumbData.iObserver->TextureContentChangedL( ETrue , newTexture); |
|
649 } |
|
650 |
|
651 if(scaledBitmap) |
|
652 { |
|
653 CleanupStack::PopAndDestroy(scaledBitmap); |
|
654 } |
|
655 |
|
656 return *newTexture; |
|
657 } |
|
658 |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // CreateZoomedTextureL |
|
662 // ----------------------------------------------------------------------------- |
|
663 // |
|
664 CAlfTexture& CGlxTextureManagerImpl::CreateZoomedTextureL( |
|
665 const TGlxMedia& aMedia, const TMPXAttribute& aAttribute, |
|
666 TGlxIdSpaceId aIdSpaceId, MGlxTextureObserver* aObserver) |
|
667 { |
|
668 TRACER("CGlxTextureManagerImpl::CreateZoomedTextureL"); |
|
669 if(!iZoomDecoder) |
|
670 { |
|
671 GLX_LOG_INFO("CGlxTextureManagerImpl:: CreateZoomedTextureL,iZoomDecoder == NULL"); |
|
672 iZoomDecoder = CGlxBitmapDecoderWrapper::NewL(this); |
|
673 } |
|
674 |
|
675 TGlxThumbnailIcon aThumbData; |
|
676 |
|
677 aThumbData.iTextureId = NextTextureId(); |
|
678 aThumbData.iTexture = NULL; |
|
679 aThumbData.iAttribId = aAttribute; |
|
680 aThumbData.iMediaId = aMedia.Id(); |
|
681 aThumbData.iIdSpaceId = aIdSpaceId; |
|
682 |
|
683 //Add to the thumbnail list |
|
684 iZoomedList.Append(aThumbData); |
|
685 |
|
686 TInt index = iZoomedList.Count()-1; |
|
687 GLX_LOG_INFO1("CGlxTextureManagerImpl:: CreateZoomedTextureL,index=%d",index); |
|
688 |
|
689 iZoomedList[index].iTexture = NULL; |
|
690 aMedia.GetDimensions( iZoomedList[index].iRequiredSize ); |
|
691 |
|
692 iZoomedList[index].iBitmap=NULL; |
|
693 iZoomedList[index].iObserver = aObserver ; |
|
694 |
|
695 iZoomDecoder->DoDecodeImageL(aMedia.Uri(), iZoomedList.Count()-1); |
|
696 |
|
697 return *(iZoomedList[index].iTexture); |
|
698 } |
|
699 |
|
700 // ----------------------------------------------------------------------------- |
|
701 // CreateAnimatedGifTextureL |
|
702 // ----------------------------------------------------------------------------- |
|
703 // |
|
704 CAlfTexture& CGlxTextureManagerImpl::CreateAnimatedGifTextureL( |
|
705 const TDesC& aFilename, const TSize& aSize) |
|
706 { |
|
707 TRACER("CGlxTextureManagerImpl::CreateAnimatedGifTextureL"); |
|
708 return iAlfTextureManager.LoadTextureL(aFilename,aSize, |
|
709 EAlfTextureFlagDefault,NextTextureId() ); |
|
710 } |
|
711 |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // UpdateTexture |
|
715 // ----------------------------------------------------------------------------- |
|
716 // |
|
717 void CGlxTextureManagerImpl::UpdateTexture() |
|
718 { |
|
719 TRACER("CGlxTextureManagerImpl::UpdateTexture"); |
|
720 TInt count = iIconList.Count(); |
|
721 for(TInt i = count - 1; i >= 0; i--) |
|
722 { |
|
723 //to-check |
|
724 // TRAP_IGNORE(DoHandleResolutionChangedL(i);) |
|
725 } |
|
726 } |
|
727 |
|
728 // ----------------------------------------------------------------------------- |
|
729 // HandleResolutionChanged |
|
730 // ----------------------------------------------------------------------------- |
|
731 // |
|
732 void CGlxTextureManagerImpl::HandleResolutionChangedL() |
|
733 { |
|
734 TRACER("CGlxTextureManagerImpl::HandleResolutionChangedL"); |
|
735 UpdateTexture(); |
|
736 } |
|
737 |
|
738 // ----------------------------------------------------------------------------- |
|
739 // DoHandleResolutionChangedL |
|
740 // ----------------------------------------------------------------------------- |
|
741 // |
|
742 //To-do |
|
743 /*void CGlxTextureManagerImpl::DoHandleResolutionChangedL(TInt aIconIndex) |
|
744 { |
|
745 TGlxIcon& icon = iIconList[aIconIndex]; |
|
746 CAlfTexture* texture = icon.iTexture; |
|
747 // Clear previous content |
|
748 //texture->SetSegmentCountL(0); |
|
749 |
|
750 // Get new bitmaps |
|
751 CFbsBitmap* bitmap = NULL; |
|
752 CFbsBitmap* mask = NULL; |
|
753 ProvideBitmapL(icon.iTextureId, bitmap, mask); |
|
754 // Upload to texture |
|
755 if(bitmap) |
|
756 { |
|
757 CleanupStack::PushL(bitmap); |
|
758 texture->SetSize(bitmap->SizeInPixels()); |
|
759 if(mask) |
|
760 { |
|
761 CleanupStack::PushL(mask); |
|
762 texture->UploadL( *bitmap, mask, |
|
763 EAlfTextureUploadFlagDefault ); |
|
764 CleanupStack::PopAndDestroy(mask); |
|
765 } |
|
766 else |
|
767 { |
|
768 texture->UploadL( *bitmap, NULL, |
|
769 EAlfTextureUploadFlagDefault ); |
|
770 |
|
771 } |
|
772 CleanupStack::PopAndDestroy(bitmap); |
|
773 } |
|
774 }*/ |
|
775 |
|
776 |
|
777 // ----------------------------------------------------------------------------- |
|
778 // ProvideBitmapL |
|
779 // ----------------------------------------------------------------------------- |
|
780 // |
|
781 void CGlxTextureManagerImpl::ProvideBitmapL(TInt aTextureId, |
|
782 CFbsBitmap*& aBitmap, |
|
783 CFbsBitmap*& aMaskBitmap) |
|
784 { |
|
785 TRACER("CGlxTextureManagerImpl::ProvideBitmapL"); |
|
786 // Test whether we've already created bitmaps for the given texture id |
|
787 if ( aTextureId == iProvideBitmapHolder.iTextureId ) |
|
788 { |
|
789 GLX_LOG_INFO("CGlxTextureManagerImpl::ProvideBitmapL aTextureId"); |
|
790 aBitmap = iProvideBitmapHolder.iBitmap; |
|
791 aMaskBitmap = iProvideBitmapHolder.iMaskBitmap; |
|
792 // reset the flags to prevent multiple calls into here |
|
793 iProvideBitmapHolder.iTextureId = KErrNotFound; |
|
794 iProvideBitmapHolder.iBitmap = NULL; |
|
795 iProvideBitmapHolder.iMaskBitmap = NULL; |
|
796 return; |
|
797 } |
|
798 |
|
799 // loop to search the zoomed thumbnail list |
|
800 TInt i = iZoomedList.Count(); |
|
801 GLX_LOG_INFO1("CGlxTextureManagerImpl::ProvideBitmapL iZoomedList.Count=%d",i); |
|
802 while(i > 0) |
|
803 { |
|
804 --i; |
|
805 if (iZoomedList[i].iTextureId == aTextureId) |
|
806 { |
|
807 // We have found the texture, create a duplicate as alf destroys |
|
808 // the bitmap once the texture's been created. |
|
809 GLX_LOG_INFO1("CGlxTextureManagerImpl::ProvideBitmapL i=%d",i); |
|
810 aBitmap = CreateDuplicateBitmapL( *iZoomedList[i].iBitmap ); |
|
811 return; |
|
812 } |
|
813 } |
|
814 // add loop to search the iThumbnailList for the aTextureId |
|
815 i = iThumbnailList.Count(); |
|
816 while(i > 0) |
|
817 { |
|
818 --i; |
|
819 if ((iThumbnailList[i].iTextureId == aTextureId)) |
|
820 { |
|
821 // We have found the texture, create a duplicate as alf destroys |
|
822 // the bitmap once the texture's been created. |
|
823 aBitmap = CreateDuplicateBitmapL( *iThumbnailList[i].iBitmap ); |
|
824 return; |
|
825 } |
|
826 } |
|
827 // find in iIconList |
|
828 i = iIconList.Count(); |
|
829 TBool found = EFalse; |
|
830 TGlxIcon icon; |
|
831 while(i > 0 && !found) |
|
832 { |
|
833 i--; |
|
834 if(iIconList[i].iTextureId == aTextureId) |
|
835 { |
|
836 icon = iIconList[i]; |
|
837 found = ETrue; |
|
838 } |
|
839 } |
|
840 |
|
841 if(!found) |
|
842 { |
|
843 User::Leave(KErrNotFound); |
|
844 } |
|
845 |
|
846 TInt bitmapId = icon.iBitmapId; |
|
847 TInt maskId = bitmapId; |
|
848 if(bitmapId) |
|
849 { |
|
850 maskId++; |
|
851 } |
|
852 |
|
853 TFileName filename(KNullDesC); |
|
854 if(icon.iFilenameIndex >= 0) |
|
855 { |
|
856 filename = iMifFilenames->MdcaPoint(icon.iFilenameIndex); |
|
857 } |
|
858 |
|
859 if(icon.iSetColor) |
|
860 { |
|
861 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
862 icon.iAvkonSkinId, |
|
863 icon.iSkinColorId, |
|
864 icon.iSkinColorIndex, |
|
865 aBitmap, |
|
866 aMaskBitmap, |
|
867 filename, |
|
868 bitmapId, |
|
869 maskId, |
|
870 icon.iDefaultColor ); |
|
871 } |
|
872 else |
|
873 { |
|
874 AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
|
875 icon.iAvkonSkinId, |
|
876 aBitmap, |
|
877 aMaskBitmap, |
|
878 filename, |
|
879 bitmapId, |
|
880 maskId ); |
|
881 } |
|
882 |
|
883 // Leave if bitmap or mask is NULL. |
|
884 User::LeaveIfNull( aBitmap ); |
|
885 |
|
886 // set size |
|
887 // In preference use requested size if there is one |
|
888 TInt height =TInt(iResUtil->PossToPixels(icon.iHeightInPoss)); |
|
889 TInt width =TInt(iResUtil->PossToPixels(icon.iWidthInPoss)); |
|
890 |
|
891 TSize size(width, height); |
|
892 |
|
893 // Disable compression so that the bitmap may be able to be |
|
894 // duplicated inside HUITK when BITGDI renderer is in use. |
|
895 AknIconUtils::DisableCompression( aBitmap ); |
|
896 |
|
897 if ( size == TSize(0, 0) ) |
|
898 { |
|
899 // If no requested size use original size of the graphic |
|
900 TAknContentDimensions origDim; |
|
901 AknIconUtils::GetContentDimensions(aBitmap, origDim); |
|
902 size = TSize(origDim.iWidth, origDim.iHeight); |
|
903 |
|
904 // But if the original size is small make smallest dimension 64 |
|
905 // and keep aspect ratio |
|
906 if ( size.iHeight < 64 && size.iWidth < 64 ) |
|
907 { |
|
908 if(origDim.iWidth < origDim.iHeight) |
|
909 { |
|
910 size = TSize(64, 64.0F * origDim.iHeight / origDim.iWidth); |
|
911 } |
|
912 else |
|
913 { |
|
914 size = TSize(64.0F * origDim.iWidth / origDim.iHeight, 64); |
|
915 } |
|
916 } |
|
917 } |
|
918 AknIconUtils::SetSize(aBitmap, size, EAspectRatioNotPreserved); |
|
919 } |
|
920 |
|
921 // ----------------------------------------------------------------------------- |
|
922 // SelectAttributeL |
|
923 // ----------------------------------------------------------------------------- |
|
924 // |
|
925 TMPXAttribute CGlxTextureManagerImpl::SelectAttributeL( TSize& aSize, |
|
926 const TGlxMedia& aMedia ) |
|
927 { |
|
928 TRACER("CGlxTextureManagerImpl::SelectAttributeL"); |
|
929 const CGlxMedia& media = *aMedia.Properties(); |
|
930 if ( aMedia.Properties() == NULL || media.Count() == 0 ) |
|
931 { |
|
932 GLX_LOG_INFO("SelectAttributeL - NULL CGlxMedia / No Attribs"); |
|
933 User::Leave( KErrArgument ); |
|
934 } |
|
935 // first check if DRM protected |
|
936 TBool drmInvalid = EFalse; |
|
937 if ( aMedia.GetDrmProtected(drmInvalid) && drmInvalid ) |
|
938 { |
|
939 // require URI attribute |
|
940 TMPXGeneralCategory cat = aMedia.Category(); |
|
941 // get URI |
|
942 const TDesC& uri = aMedia.Uri(); |
|
943 if( (uri.Length() == 0) || (EMPXNoCategory == cat) ) |
|
944 { |
|
945 User::Leave( KErrArgument ); |
|
946 } |
|
947 |
|
948 // check if rights have expired |
|
949 TBool checkViewRights = (cat==EMPXImage); |
|
950 |
|
951 drmInvalid = !iDrmUtility->CheckDisplayRightsL(uri, checkViewRights); |
|
952 CGlxMedia* properties = const_cast<CGlxMedia*>(aMedia.Properties()); |
|
953 if( !drmInvalid ) |
|
954 { |
|
955 properties->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, EGlxDrmRightsValid); |
|
956 } |
|
957 else |
|
958 { |
|
959 properties->SetTObjectValueL(KGlxMediaGeneralDRMRightsValid, EGlxDrmRightsInvalid); |
|
960 } |
|
961 } |
|
962 |
|
963 // if invalid need dimensions |
|
964 if ( drmInvalid ) |
|
965 { |
|
966 TSize dimensions(0,0); |
|
967 if(!aMedia.GetDimensions(dimensions)) |
|
968 { |
|
969 User::Leave( KErrArgument ); |
|
970 } |
|
971 |
|
972 aSize = iDrmUtility->DRMThumbnailSize(dimensions); |
|
973 } |
|
974 |
|
975 // Get the index for the attribute |
|
976 TInt index = GlxThumbnailUtility::ClosestThumbnail( aSize, |
|
977 media, !drmInvalid ); |
|
978 // check it's valid |
|
979 if (KErrNotFound == index) |
|
980 { |
|
981 GLX_LOG_INFO("GlxThumbnailUtility::ClosestThumbnail fail "); |
|
982 User::Leave( KErrArgument ); |
|
983 } |
|
984 |
|
985 return media.Attribute(index); |
|
986 } |
|
987 |
|
988 |
|
989 // ----------------------------------------------------------------------------- |
|
990 // CreateDuplicateBitmapL |
|
991 // ----------------------------------------------------------------------------- |
|
992 // |
|
993 CFbsBitmap* CGlxTextureManagerImpl::CreateDuplicateBitmapL(CFbsBitmap& aOriginalBitmap ) |
|
994 { |
|
995 TRACER("CGlxTextureManagerImpl::CreateDuplicateBitmapL"); |
|
996 CFbsBitmap* duplicateBitmap = new( ELeave) CFbsBitmap(); |
|
997 TInt err=duplicateBitmap->Duplicate( aOriginalBitmap.Handle()); |
|
998 if ( err != KErrNone ) |
|
999 { |
|
1000 delete duplicateBitmap; |
|
1001 duplicateBitmap = NULL; |
|
1002 GLX_LOG_INFO1("CGlxTextureManagerImpl::CreateDuplicateBitmapL fail =%d",err); |
|
1003 } |
|
1004 |
|
1005 return duplicateBitmap; |
|
1006 } |
|
1007 |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // NextTextureId |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // |
|
1012 TInt CGlxTextureManagerImpl::NextTextureId() |
|
1013 { |
|
1014 TRACER("CGlxTextureManagerImpl::NextTextureId"); |
|
1015 return ++iNextTextureId; |
|
1016 } |
|
1017 |
|
1018 |
|
1019 void CGlxTextureManagerImpl::HandleBitmapDecodedL(TInt aThumbnailIndex,CFbsBitmap* aBitmap) |
|
1020 { |
|
1021 TRACER("CGlxTextureManagerImpl::HandleBitmapDecodedL"); |
|
1022 CAlfTexture* newTexture = NULL; |
|
1023 TBool textureCreated = ETrue; |
|
1024 TInt textureID = -1; |
|
1025 TInt textureToBeUnloaded = -1; |
|
1026 |
|
1027 //check if the image is decoded |
|
1028 if(aBitmap != NULL) |
|
1029 { |
|
1030 iZoomedList[aThumbnailIndex].iBitmap = aBitmap; |
|
1031 |
|
1032 //if we already have a texture then dont unload the texture before creating |
|
1033 //the next one. It might happen that because of low memory we might not be able |
|
1034 //to create a new texture. |
|
1035 if(iZoomedList[aThumbnailIndex].iTexture) |
|
1036 { |
|
1037 textureID = NextTextureId(); |
|
1038 textureToBeUnloaded = iZoomedList[aThumbnailIndex].iTextureId ; |
|
1039 iZoomedList[aThumbnailIndex].iTextureId = textureID ; |
|
1040 } |
|
1041 else |
|
1042 { |
|
1043 textureID = iZoomedList[aThumbnailIndex].iTextureId; |
|
1044 } |
|
1045 |
|
1046 TRAPD(err, newTexture = &iAlfTextureManager.CreateTextureL( |
|
1047 textureID, this, EAlfTextureFlagDefault)); |
|
1048 if ( KErrNone != err && KErrNoMemory == err ) |
|
1049 { |
|
1050 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded ReleaseRam : START RAM RELEASE"); |
|
1051 iCache->ReleaseRAML(ETrue); |
|
1052 TRAPD(err, newTexture = &iAlfTextureManager.CreateTextureL(textureID, this, EAlfTextureFlagDefault)); |
|
1053 if ( KErrNone != err && KErrNoMemory == err ) |
|
1054 { |
|
1055 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded CreateTextureL : LOW MEMORY CONDITION"); |
|
1056 textureCreated = EFalse; |
|
1057 } |
|
1058 } |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 textureCreated = EFalse; |
|
1063 } |
|
1064 |
|
1065 if(iZoomedList[aThumbnailIndex].iBitmap) |
|
1066 { |
|
1067 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded delete iBitmap"); |
|
1068 delete iZoomedList[aThumbnailIndex].iBitmap; |
|
1069 iZoomedList[aThumbnailIndex].iBitmap = NULL; |
|
1070 } |
|
1071 |
|
1072 if (textureCreated && (NULL != newTexture)) |
|
1073 { |
|
1074 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded textureCreated && newTexture"); |
|
1075 //If the new texture is created then unload the old texture and store the new texture and textureID. |
|
1076 if(iZoomedList[aThumbnailIndex].iTexture) |
|
1077 { |
|
1078 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded Unloading Old Texture"); |
|
1079 iAlfTextureManager.UnloadTexture(textureToBeUnloaded ); |
|
1080 } |
|
1081 iZoomedList[aThumbnailIndex].iTextureId = textureID; |
|
1082 |
|
1083 iZoomedList[aThumbnailIndex].iTexture = newTexture; |
|
1084 } |
|
1085 |
|
1086 if (iZoomedList[aThumbnailIndex].iObserver) |
|
1087 { |
|
1088 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecoded TextureContentChangedL"); |
|
1089 iZoomedList[aThumbnailIndex].iObserver->TextureContentChangedL( textureCreated ,iZoomedList[aThumbnailIndex].iTexture); |
|
1090 } |
|
1091 GLX_LOG_INFO("CGlxTextureManagerImpl::HandleBitmapDecodedL Exit "); |
|
1092 } |
|
1093 |
|
1094 // ----------------------------------------------------------------------------- |
|
1095 // HandleAttributesAvailableL |
|
1096 // ----------------------------------------------------------------------------- |
|
1097 // |
|
1098 void CGlxTextureManagerImpl::HandleAttributesAvailableL(const TGlxIdSpaceId& /*aIdSpaceId*/, |
|
1099 const TGlxMediaId& /*aMediaId*/, |
|
1100 const RArray<TMPXAttribute>& /*aAttributes*/, |
|
1101 const CGlxMedia* /*aMedia*/) |
|
1102 { |
|
1103 |
|
1104 } |
|
1105 |
|
1106 // ----------------------------------------------------------------------------- |
|
1107 // CleanupTextureCacheL |
|
1108 // ----------------------------------------------------------------------------- |
|
1109 // |
|
1110 void CGlxTextureManagerImpl::CleanupMedia(const TGlxMediaId& aMediaId) |
|
1111 { |
|
1112 TRACER("CGlxTextureManagerImpl::CleanupMedia"); |
|
1113 RemoveTexture(aMediaId, EFalse); |
|
1114 } |
|
1115 |
|
1116 |
|
1117 |
|
1118 // ----------------------------------------------------------------------------- |
|
1119 // ScaleGridTnmToFsL |
|
1120 // ----------------------------------------------------------------------------- |
|
1121 // |
|
1122 void CGlxTextureManagerImpl::ScaleGridTnmToFsL(TSize aSrcSize, TSize aDestSize, |
|
1123 CFbsBitmap *aScaledBitmap, const CGlxThumbnailAttribute* thumb) |
|
1124 { |
|
1125 TRACER("CGlxTextureManagerImpl::ScaleGridTnmToFsL"); |
|
1126 // Scale the Image to required size if the thumbnail is smaller.Instead of Displaying Small thumbnail |
|
1127 // Calculate destination rect to maintain aspect ratio |
|
1128 TReal aspectRatio = (TReal)aDestSize.iWidth/(TReal)aDestSize.iHeight ; |
|
1129 TReal thumbAspectRatio = (TReal)aSrcSize.iWidth/(TReal)aSrcSize.iHeight ; |
|
1130 TSize destinationSize ; |
|
1131 if(thumbAspectRatio >= aspectRatio) |
|
1132 { |
|
1133 destinationSize.iWidth = aDestSize.iWidth ; |
|
1134 destinationSize.iHeight = aDestSize.iWidth*aSrcSize.iHeight/aSrcSize.iWidth ; |
|
1135 } |
|
1136 else |
|
1137 { |
|
1138 destinationSize.iHeight = aDestSize.iHeight ; |
|
1139 destinationSize.iWidth = aDestSize.iHeight*aSrcSize.iWidth/aSrcSize.iHeight ; |
|
1140 } |
|
1141 aScaledBitmap->Create(destinationSize,thumb->iBitmap->DisplayMode()); |
|
1142 CFbsBitmapDevice *bitmapDevice = CFbsBitmapDevice::NewL(aScaledBitmap); |
|
1143 CleanupStack::PushL(bitmapDevice); |
|
1144 CFbsBitGc * bitmapGc = CFbsBitGc::NewL(); |
|
1145 CleanupStack::PushL(bitmapGc); |
|
1146 bitmapGc->Activate(bitmapDevice); |
|
1147 bitmapGc->DrawBitmap(TRect(destinationSize),thumb->iBitmap); |
|
1148 CleanupStack::PopAndDestroy(bitmapGc); |
|
1149 CleanupStack::PopAndDestroy(bitmapDevice); |
|
1150 GLX_LOG_INFO2("===== Actual Image Size %d x %d",aSrcSize.iWidth,aSrcSize.iHeight); |
|
1151 GLX_LOG_INFO2("===== Scaled Image Size %d x %d",destinationSize.iWidth,destinationSize.iHeight); |
|
1152 } |