|
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 component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_GLXTEXTUREMANAGERIMPL_H |
|
22 #define C_GLXTEXTUREMANAGERIMPL_H |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <badesca.h> // For CDesCArrayFlat |
|
26 #include <e32cmn.h> |
|
27 |
|
28 #include <AknsItemID.h> |
|
29 #include <alf/alftexture.h> |
|
30 #include <alf/alfbitmapprovider.h> |
|
31 #include <alf/alftimedvalue.h> |
|
32 #include <mpxattribute.h> |
|
33 #include <mglxresolutionchangeobserver.h> |
|
34 #include "glxbitmapdecoderwrapper.h" |
|
35 #include <glxmediaid.h> |
|
36 #include <glximageviewermanager.h> |
|
37 #include <imageconversion.h> |
|
38 #include <bitmaptransforms.h> |
|
39 #include <mglxcacheobserver.h> |
|
40 class CAlfTexture; |
|
41 class CGlxDRMUtility; |
|
42 class CGlxMedia; |
|
43 //class CAlfGifAnimationTexture; |
|
44 class CAlfImageLoaderUtil; |
|
45 class CAlfTextureManager; |
|
46 class MGlxCache; |
|
47 class TGlxMedia; |
|
48 class CGlxResolutionUtility; |
|
49 class MGlxTextureObserver; |
|
50 class CGlxBitmapDecoderWrapper; |
|
51 class MGlxBitmapDecoderObserver; |
|
52 class CGlxThumbnailAttribute; |
|
53 |
|
54 const TInt KGlxMaxFrameCount = 25; |
|
55 |
|
56 /** |
|
57 * CGlxTextureManagerImpl |
|
58 * |
|
59 * Implementation of Texture Manager component. |
|
60 * |
|
61 * @author David Holland |
|
62 * @internal reviewed 03/07/2007 by Dan Rhodes |
|
63 * |
|
64 */ |
|
65 class CGlxTextureManagerImpl : public CBase, public MAlfBitmapProvider, |
|
66 public MGlxResolutionChangeObserver, |
|
67 public MGlxBitmapDecoderObserver, |
|
68 public MGlxCacheObserver |
|
69 { |
|
70 public: |
|
71 /** |
|
72 * Two-phased constructor |
|
73 * @param aAlfTextureManager The Alf Texture Manager |
|
74 * @return Constructed object |
|
75 */ |
|
76 static CGlxTextureManagerImpl* NewL( |
|
77 CAlfTextureManager& aAlfTextureManager); |
|
78 |
|
79 /** |
|
80 * Two-phased constructor |
|
81 * @param aAlfTextureManager The Alf Texture Manager |
|
82 * @return Constructed object |
|
83 */ |
|
84 static CGlxTextureManagerImpl* NewLC( |
|
85 CAlfTextureManager& aAlfTextureManager); |
|
86 |
|
87 /** |
|
88 * Destructor |
|
89 */ |
|
90 ~CGlxTextureManagerImpl(); |
|
91 |
|
92 /** |
|
93 * Determins if the texture need updating |
|
94 * @param aMediaId The Id of the media item |
|
95 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
96 * @param aRequiredSize The preferred size of the texture |
|
97 * @return ETrue if the texture needs updating. EFalse if not. |
|
98 */ |
|
99 TBool TextureNeedsUpdating(TGlxMedia aMedia, TGlxIdSpaceId aIdSpaceId, |
|
100 const TSize& aRequiredSize); |
|
101 /** |
|
102 * Create a texture from an icon within the application |
|
103 * @param aSkinID The skin Id associated with the icon |
|
104 * @param aIconResourceId The Id associated with the icon .mif file |
|
105 * @param aFilename The full path name of the .mif file |
|
106 * @param aSetColor ETrue if colour of icon is to be modified |
|
107 * @param aDefaultColor colour use if skin clour not specified or not found |
|
108 * @param aSkinColorId Id of the skin colour table |
|
109 * @param aSkinColorIndex Index of the colour in the table |
|
110 * @param aRequestedSize requested size. If default used size is based on size of original graphic |
|
111 * @return Created texture |
|
112 */ |
|
113 CAlfTexture& CreateIconTextureL(const TAknsItemID& aSkinID, |
|
114 TInt aIconResourceId, |
|
115 const TDesC& aFilename, |
|
116 TBool aSetColor, |
|
117 TRgb aDefaultColor, |
|
118 const TAknsItemID& aSkinColorId, |
|
119 TInt aSkinColorIndex, |
|
120 TSize aRequestedSize); |
|
121 |
|
122 /** |
|
123 * Requests the best match texture. If it already exists this method does nothing. |
|
124 * However if it doed not exist it will create it and replace the old texture |
|
125 * if necessary. |
|
126 * @param aSize The size of the requested texture |
|
127 * @param aMedia The TGlxMedia item |
|
128 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
129 * @param aObserver Observer for the texture. |
|
130 * @param aScaleGridTnm ETrue if the grid tnm to be scaled else EFalse. |
|
131 * @return Created texture, or NULL if the texture alreay exists |
|
132 */ |
|
133 CAlfTexture& CreateNewTextureForMediaL(TSize aSize, const TGlxMedia& aMedia, |
|
134 const TGlxIdSpaceId& aIdSpaceId, MGlxTextureObserver* aObserver, TBool aScaleGridTnm ); |
|
135 |
|
136 |
|
137 /** |
|
138 * Create a texture from a zoomed thumbnail attribute of a media item |
|
139 * @param aMedia The media item |
|
140 * @param aAttribute Which attribute |
|
141 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
142 * @param aObserver Observer for the texture. |
|
143 * @return Created texture |
|
144 */ |
|
145 CAlfTexture& CreateZoomedTextureL(const TGlxMedia& aMedia, |
|
146 const TMPXAttribute& aAttribute, |
|
147 TGlxIdSpaceId aIdSpaceId, MGlxTextureObserver* aObserver); |
|
148 |
|
149 /** |
|
150 * If we have a texture ID, we recreate the Zoomed texture based on that |
|
151 * |
|
152 * @param aTextureID the texture ID to create the texture on. |
|
153 */ |
|
154 CAlfTexture* CreateZoomedTextureL( ); |
|
155 |
|
156 /** |
|
157 * Create an animated texture from a GIF file |
|
158 * @param aFilename The filename of the GIF file |
|
159 * @param aSize The size of the GIF file |
|
160 * @param aMedia The media item |
|
161 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
162 * @return Created texture: ownership transfered |
|
163 */ |
|
164 CAlfTexture& CreateAnimatedGifTextureL(const TDesC& aFilename, const TSize& aSize, |
|
165 const TGlxMedia& aMedia, TGlxIdSpaceId aIdSpaceId); |
|
166 |
|
167 /** |
|
168 * Creates textures for the given GIF media |
|
169 * @param aMedia The media item |
|
170 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
171 * @param aFrameNumber frame number of gif media |
|
172 * @param aBitmap Bitmap for the particular frame |
|
173 * @return Created texture: ownership transfered |
|
174 */ |
|
175 CAlfTexture& CreateDRMAnimatedGifTextureL(const TGlxMedia& aMedia, |
|
176 TGlxIdSpaceId aIdSpaceId, TInt aFrameNumber, CFbsBitmap* aBitmap, CFbsBitmap* aBitmapMask); |
|
177 /** |
|
178 * Removes the texture if it was created by CreateThumbnailTextureL or |
|
179 * CreateZoomedTextureL |
|
180 * @param aTexture The texture to be removed |
|
181 */ |
|
182 void RemoveTexture( const CAlfTexture& aTexture ); |
|
183 |
|
184 /** |
|
185 * Removes all Texteures |
|
186 * |
|
187 */ |
|
188 void FlushTextures() ; |
|
189 |
|
190 /** |
|
191 * Removes the texture if it was created by CreateThumbnailTextureL or |
|
192 * CreateZoomedTextureL |
|
193 * @param aTexture The texture to be removed |
|
194 */ |
|
195 void RemoveZoomList(); |
|
196 |
|
197 /** |
|
198 * Removes the texture if it was created by CreateThumbnailTextureL or |
|
199 * CreateZoomedTextureL |
|
200 * @param TGlxMediaId The iMediaId to be removed |
|
201 * @param aAllTexture Flag to remove all textures |
|
202 * Bug fix for PKAA-7NRBYZ - added bAllTexture param. |
|
203 */ |
|
204 void RemoveTexture( const TGlxMediaId& aMediaId, TBool aAllTexture); |
|
205 |
|
206 |
|
207 /** |
|
208 * Creates a flat color texture and returns the reference to it |
|
209 */ |
|
210 CAlfTexture& CreateFlatColourTextureL( TRgb aColour ); |
|
211 |
|
212 /** |
|
213 * Animate the given media. |
|
214 * @param aMediaId The Id of the media to be animated |
|
215 * @param aState Animation state [ETrue to Start, EFalse to Stop] |
|
216 */ |
|
217 void AnimateMediaItem(const TGlxMediaId& aMediaId, TBool aState); |
|
218 |
|
219 public: // From MGlxCacheObserver |
|
220 void HandleAttributesAvailableL(const TGlxIdSpaceId& aIdSpaceId, |
|
221 const TGlxMediaId& aMediaId, |
|
222 const RArray<TMPXAttribute>& aAttributes, |
|
223 const CGlxMedia* aMedia); |
|
224 |
|
225 void CleanupMedia(const TGlxMediaId& aMediaId); |
|
226 |
|
227 public: // from MAlfBitmapProvider |
|
228 void ProvideBitmapL(TInt aId, |
|
229 CFbsBitmap*& aBitmap, |
|
230 CFbsBitmap*& aMaskBitmap); |
|
231 |
|
232 |
|
233 public: // From MGlxResolutionChangeObserver |
|
234 void HandleResolutionChangedL(); |
|
235 |
|
236 /** |
|
237 * Updates the texture for every Icon in the IconList. |
|
238 */ |
|
239 void UpdateTexture(); |
|
240 public: // From MGlxTextureRotatorObserver |
|
241 void HandleBitmapDecodedL(TInt aThumbnailIndex,CFbsBitmap* aBitmap); |
|
242 |
|
243 |
|
244 private: |
|
245 /** |
|
246 * Constructor |
|
247 * @param aAlfTextureManager The Alf Texture Manager |
|
248 */ |
|
249 CGlxTextureManagerImpl(CAlfTextureManager& aAlfTextureManager); |
|
250 |
|
251 /** |
|
252 * Second-phase constuction |
|
253 */ |
|
254 void ConstructL(); |
|
255 |
|
256 |
|
257 /** |
|
258 * GetThumbnailAttributeAndIndexL |
|
259 * @param aSize The size of the requested texture |
|
260 * @param aMedia The TGlxMedia item. |
|
261 * @param aThumbnailIndex on return will contain the Index of the thumbnail in the iThumbnailList |
|
262 * or KErrNotFound |
|
263 * @param aThumbnailAttribute on return will contain the Thumbnail attribute (if found) |
|
264 * @return ETrue if Thumbnail is available, EFalse if it needs to be created |
|
265 */ |
|
266 TBool GetThumbnailAttributeAndIndexL( TSize aSize, const TGlxMedia& aMedia, |
|
267 const TGlxIdSpaceId& aIdSpaceId, TInt& aThumbnailIndex, |
|
268 TMPXAttribute& aThumbnailAttribute ); |
|
269 |
|
270 /** |
|
271 * Create Image Viewer manager Instance |
|
272 */ |
|
273 void CreateImageViewerInstanceL(); |
|
274 |
|
275 /** |
|
276 * Delete Image Viewer manager Instance |
|
277 */ |
|
278 void DeleteImageViewerInstance(); |
|
279 |
|
280 /** |
|
281 * TGlxIcon |
|
282 * Values associated with a bitmap/svg icon |
|
283 */ |
|
284 class TGlxIcon |
|
285 { |
|
286 public: |
|
287 TInt iTextureId; |
|
288 CAlfTexture* iTexture; |
|
289 TAknsItemID iAvkonSkinId; |
|
290 TInt iBitmapId; |
|
291 TInt iFilenameIndex; |
|
292 TBool iSetColor; // indicates if color to be modified |
|
293 TRgb iDefaultColor; |
|
294 TAknsItemID iSkinColorId; |
|
295 TInt iSkinColorIndex; |
|
296 TReal32 iHeightInPoss; |
|
297 TReal32 iWidthInPoss; |
|
298 |
|
299 /** |
|
300 * Helper functor to be able to find texture from array |
|
301 */ |
|
302 static TBool MatchTexture( |
|
303 const CAlfTexture* aTexture, |
|
304 const TGlxIcon& aRhs ) |
|
305 { |
|
306 // return true if the address of the texture match |
|
307 return aTexture == aRhs.iTexture; |
|
308 } |
|
309 }; |
|
310 |
|
311 /** |
|
312 * TGlxThumbIcon |
|
313 * Values associated with a thumbnail. |
|
314 */ |
|
315 class TGlxThumbnailIcon |
|
316 { |
|
317 public: |
|
318 TInt iTextureId; |
|
319 CAlfTexture* iTexture; |
|
320 TMPXAttribute iAttribId; |
|
321 TSize iRequiredSize; |
|
322 TGlxMediaId iMediaId; |
|
323 TGlxIdSpaceId iIdSpaceId; |
|
324 MGlxTextureObserver* iObserver; |
|
325 CFbsBitmap* iBitmap; |
|
326 TTime iImageDate; |
|
327 /** |
|
328 * Helper function to be able to find texture from array |
|
329 */ |
|
330 static TBool MatchTexture( |
|
331 const CAlfTexture* aTexture, |
|
332 const TGlxThumbnailIcon& aThumbData ) |
|
333 { |
|
334 // return true if the address of the texture match |
|
335 return aTexture == aThumbData.iTexture; |
|
336 } |
|
337 |
|
338 /** |
|
339 * Helper function to be able to find mediaid from array |
|
340 */ |
|
341 static TBool MatchMediaId(const TGlxMediaId* aMediaId, |
|
342 const TGlxThumbnailIcon& aThumbData) |
|
343 { |
|
344 // return true if the Media Id match |
|
345 return *aMediaId == aThumbData.iMediaId; |
|
346 } |
|
347 }; |
|
348 |
|
349 /** |
|
350 * TGlxDRMGifThumbnailIcon |
|
351 * Values associated with a DRM Gif thumbnail. |
|
352 */ |
|
353 class TGlxDRMGifThumbnailIcon |
|
354 { |
|
355 public: |
|
356 TInt iTextureId[KGlxMaxFrameCount]; |
|
357 CAlfTexture* iTexture[KGlxMaxFrameCount]; |
|
358 TMPXAttribute iAttribId; |
|
359 TSize iRequiredSize; |
|
360 TGlxMediaId iMediaId; |
|
361 TGlxIdSpaceId iIdSpaceId; |
|
362 MGlxTextureObserver* iObserver; |
|
363 CFbsBitmap* iBitmap[KGlxMaxFrameCount]; |
|
364 CFbsBitmap* iBitmapMask[KGlxMaxFrameCount]; |
|
365 TTime iImageDate; |
|
366 /** |
|
367 * Helper function to be able to find texture from array |
|
368 */ |
|
369 static TBool MatchTexture(const CAlfTexture* aTexture, |
|
370 const TGlxDRMGifThumbnailIcon& aThumbData) |
|
371 { |
|
372 // return true if the address of the texture match |
|
373 return aTexture == aThumbData.iTexture[0]; |
|
374 } |
|
375 |
|
376 /** |
|
377 * Helper function to be able to find mediaid from array |
|
378 */ |
|
379 static TBool MatchMediaId(const TGlxMediaId* aMediaId, |
|
380 const TGlxDRMGifThumbnailIcon& aThumbData) |
|
381 { |
|
382 // return true if the Media Id match |
|
383 return *aMediaId == aThumbData.iMediaId; |
|
384 } |
|
385 }; |
|
386 /** |
|
387 * Requests the best match texture. If it already exists this method does nothing. |
|
388 * However if it doed not exist it will create it and replace the old texture |
|
389 * if necessary. |
|
390 * @param aSize The size of the requested texture |
|
391 * @param aMedia The TGlxMedia item |
|
392 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
393 * @param aObserver Observer for the texture. |
|
394 * @param aAttribute specifies the type of texture to create |
|
395 * @param aThumbData the tumbnail data |
|
396 * @param aScaleGridTnm ETrue if the grid tnm to be scaled else EFalse. |
|
397 * @return Created texture, or NULL if the texture alreay exists |
|
398 */ |
|
399 CAlfTexture& CreateNewTextureL( TSize aSize, const TGlxMedia& aMedia, |
|
400 const TGlxIdSpaceId& aIdSpaceId, MGlxTextureObserver* aObserver, |
|
401 TMPXAttribute& aAttribute, TGlxThumbnailIcon& aThumbData,TBool aIsThumbnailTexture, TBool aScaleGridTnm); |
|
402 |
|
403 |
|
404 /** |
|
405 * TGlxProvideBitmapHolder |
|
406 * Used to hold the bitmaps and their associated texture id between |
|
407 * the call to create the alf texture and the callback to ProvideBitmap. |
|
408 */ |
|
409 class TGlxProvideBitmapHolder |
|
410 { |
|
411 public: |
|
412 TInt iTextureId; |
|
413 CFbsBitmap* iBitmap; // not owned |
|
414 CFbsBitmap* iMaskBitmap; // not owned |
|
415 }; |
|
416 |
|
417 /** |
|
418 * Select the most appropriate attribute to use to load bitmap |
|
419 * @param aThumbnail contains the data concerning the texture |
|
420 * @param aMedia the media |
|
421 * @return Index of selected attribute in list or KErrNotFound |
|
422 */ |
|
423 TMPXAttribute SelectAttributeL(TSize& aThumbnail, |
|
424 const TGlxMedia& aMedia); |
|
425 |
|
426 |
|
427 /** |
|
428 * Duplicates a bitmap |
|
429 * @param aOriginalBitmap original bitmap |
|
430 * @return duplicate bitmap |
|
431 */ |
|
432 CFbsBitmap* CreateDuplicateBitmapL( CFbsBitmap& aOriginalBitmap ); |
|
433 |
|
434 /** |
|
435 * Increments the texture id and returns it |
|
436 * @return next texture id |
|
437 */ |
|
438 TInt NextTextureId(); |
|
439 |
|
440 /** |
|
441 * Scales the grid Thumbnail bitmap to the fullscreen keeping the aspect |
|
442 * ratio. |
|
443 * @param aSrcSize The size of the original image |
|
444 * @param aDestSize The Fullscreen size |
|
445 * @param aScaledBitmap Pointer to the scaled bitmap |
|
446 * @param thumb thumbnail attributes. |
|
447 */ |
|
448 void ScaleGridTnmToFsL(TSize aSrcSize, TSize aDestSize, |
|
449 CFbsBitmap *aScaledBitmap, const CGlxThumbnailAttribute* thumb); |
|
450 |
|
451 |
|
452 /** |
|
453 * GetAnimatedGifThumbnailIndex |
|
454 * @param aSize The size of the requested texture |
|
455 * @param aMedia The TGlxMedia item. |
|
456 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
457 * @param aThumbnailIndex on return will contain the Index of the thumbnail in the iAnimatedTnmList |
|
458 * or KErrNotFound |
|
459 * @return ETrue if Thumbnail is available, EFalse if it needs to be created |
|
460 */ |
|
461 TBool GetAnimatedGifThumbnailIndex( TSize aSize, |
|
462 const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId, |
|
463 TInt& aThumbnailIndex); |
|
464 /** |
|
465 * GetDRMAnimatedGifThumbnailIndex |
|
466 * @param aMedia The TGlxMedia item. |
|
467 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
468 * @param aThumbnailIndex on return will contain the Index of the thumbnail in the iAnimatedTnmList |
|
469 * or KErrNotFound |
|
470 * @return ETrue if Thumbnail is available, EFalse if it needs to be created |
|
471 */ |
|
472 TBool GetDRMAnimatedGifThumbnailIndex(const TGlxMedia& aMedia, const TGlxIdSpaceId& aIdSpaceId, |
|
473 TInt& aThumbnailIndex); |
|
474 private: |
|
475 // Alf Texture manager (not owned) |
|
476 CAlfTextureManager& iAlfTextureManager; |
|
477 |
|
478 // Next id to be allocated to icon textures provide within the application. |
|
479 TInt iNextTextureId; |
|
480 |
|
481 // List containing data for icon textures provided within the application. |
|
482 RArray<TGlxIcon> iIconList; |
|
483 |
|
484 // List containing data for textures generated from thumbnail bitmaps. |
|
485 RArray<TGlxThumbnailIcon> iThumbnailList; |
|
486 |
|
487 // List containing data for textures generated from zoomed thumbnail. |
|
488 RArray<TGlxThumbnailIcon> iZoomedList; |
|
489 |
|
490 // List containing data for textures generated from Animated thumbnail. |
|
491 RArray<TGlxThumbnailIcon> iAnimatedTnmList; |
|
492 |
|
493 // List containing data for textures generated from DRM Gif Animated thumbnail. |
|
494 RArray<TGlxDRMGifThumbnailIcon> iDRMGifAnimatedTnmList; |
|
495 |
|
496 // List of .mif filenames of files containing icons. |
|
497 CDesCArrayFlat* iMifFilenames; |
|
498 |
|
499 // DRM utility class |
|
500 CGlxDRMUtility* iDrmUtility; |
|
501 |
|
502 // MGlxCache instance |
|
503 MGlxCache* iCache; |
|
504 |
|
505 // CGlxResolutionUtility instance |
|
506 CGlxResolutionUtility* iResUtil; |
|
507 |
|
508 //The Bitmap Decoder Engine |
|
509 CGlxBitmapDecoderWrapper* iZoomDecoder; |
|
510 // Temporary storage class used between call to create a texture and the |
|
511 //callback from alf to ProvideBitmap |
|
512 TGlxProvideBitmapHolder iProvideBitmapHolder; |
|
513 // For image viewer, not own |
|
514 CGlxImageViewerManager* iImageViewerInstance; |
|
515 }; |
|
516 |
|
517 #endif // C_GLXTEXTUREMANAGERIMPL_H |