|
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 |
|
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 * CGlxTextureManagerImpl |
|
55 * |
|
56 * Implementation of Texture Manager component. |
|
57 * |
|
58 * @author David Holland |
|
59 * @internal reviewed 03/07/2007 by Dan Rhodes |
|
60 * |
|
61 */ |
|
62 class CGlxTextureManagerImpl : public CBase, public MAlfBitmapProvider, |
|
63 public MGlxResolutionChangeObserver, |
|
64 public MGlxBitmapDecoderObserver, |
|
65 public MGlxCacheObserver |
|
66 { |
|
67 public: |
|
68 /** |
|
69 * Two-phased constructor |
|
70 * @param aAlfTextureManager The Alf Texture Manager |
|
71 * @return Constructed object |
|
72 */ |
|
73 static CGlxTextureManagerImpl* NewL( |
|
74 CAlfTextureManager& aAlfTextureManager); |
|
75 |
|
76 /** |
|
77 * Two-phased constructor |
|
78 * @param aAlfTextureManager The Alf Texture Manager |
|
79 * @return Constructed object |
|
80 */ |
|
81 static CGlxTextureManagerImpl* NewLC( |
|
82 CAlfTextureManager& aAlfTextureManager); |
|
83 |
|
84 /** |
|
85 * Destructor |
|
86 */ |
|
87 ~CGlxTextureManagerImpl(); |
|
88 |
|
89 /** |
|
90 * Determins if the texture need updating |
|
91 * @param aMediaId The Id of the media item |
|
92 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
93 * @param aRequiredSize The preferred size of the texture |
|
94 * @return ETrue if the texture needs updating. EFalse if not. |
|
95 */ |
|
96 TBool TextureNeedsUpdating(TGlxMedia aMedia, TGlxIdSpaceId aIdSpaceId, |
|
97 const TSize& aRequiredSize); |
|
98 /** |
|
99 * Create a texture from an icon within the application |
|
100 * @param aSkinID The skin Id associated with the icon |
|
101 * @param aIconResourceId The Id associated with the icon .mif file |
|
102 * @param aFilename The full path name of the .mif file |
|
103 * @param aSetColor ETrue if colour of icon is to be modified |
|
104 * @param aDefaultColor colour use if skin clour not specified or not found |
|
105 * @param aSkinColorId Id of the skin colour table |
|
106 * @param aSkinColorIndex Index of the colour in the table |
|
107 * @param aRequestedSize requested size. If default used size is based on size of original graphic |
|
108 * @return Created texture |
|
109 */ |
|
110 CAlfTexture& CreateIconTextureL(const TAknsItemID& aSkinID, |
|
111 TInt aIconResourceId, |
|
112 const TDesC& aFilename, |
|
113 TBool aSetColor, |
|
114 TRgb aDefaultColor, |
|
115 const TAknsItemID& aSkinColorId, |
|
116 TInt aSkinColorIndex, |
|
117 TSize aRequestedSize); |
|
118 |
|
119 /** |
|
120 * Requests the best match texture. If it already exists this method does nothing. |
|
121 * However if it doed not exist it will create it and replace the old texture |
|
122 * if necessary. |
|
123 * @param aSize The size of the requested texture |
|
124 * @param aMedia The TGlxMedia item |
|
125 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
126 * @param aObserver Observer for the texture. |
|
127 * @param aScaleGridTnm ETrue if the grid tnm to be scaled else EFalse. |
|
128 * @return Created texture, or NULL if the texture alreay exists |
|
129 */ |
|
130 CAlfTexture& CreateNewTextureForMediaL(TSize aSize, const TGlxMedia& aMedia, |
|
131 const TGlxIdSpaceId& aIdSpaceId, MGlxTextureObserver* aObserver, TBool aScaleGridTnm ); |
|
132 |
|
133 |
|
134 /** |
|
135 * Create a texture from a zoomed thumbnail attribute of a media item |
|
136 * @param aMedia The media item |
|
137 * @param aAttribute Which attribute |
|
138 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
139 * @param aTextureId The created texture's id, required when the texture is removed. |
|
140 * @return Created texture |
|
141 */ |
|
142 CAlfTexture& CreateZoomedTextureL(const TGlxMedia& aMedia, |
|
143 const TMPXAttribute& aAttribute, |
|
144 TGlxIdSpaceId aIdSpaceId, MGlxTextureObserver* aObserver); |
|
145 |
|
146 /** |
|
147 * Create an animated texture from a GIF file |
|
148 * @param aFilename The filename of the GIF file |
|
149 * @param aSize The size of the GIF file |
|
150 * @return Created texture: ownership transfered |
|
151 */ |
|
152 CAlfTexture& CreateAnimatedGifTextureL(const TDesC& aFilename, |
|
153 const TSize& aSize); |
|
154 |
|
155 /** |
|
156 * Removes the texture if it was created by CreateThumbnailTextureL or |
|
157 * CreateZoomedTextureL |
|
158 * @param aTexture The texture to be removed |
|
159 */ |
|
160 void RemoveTexture( const CAlfTexture& aTexture ); |
|
161 /** |
|
162 * Removes the texture if it was created by CreateThumbnailTextureL or |
|
163 * CreateZoomedTextureL |
|
164 * @param aTexture The texture to be removed |
|
165 */ |
|
166 void RemoveZoomList(); |
|
167 |
|
168 /** |
|
169 * Removes the texture if it was created by CreateThumbnailTextureL or |
|
170 * CreateZoomedTextureL |
|
171 * @param TGlxMediaId The iMediaId to be removed |
|
172 * @param aAllTexture Flag to remove all textures |
|
173 * Bug fix for PKAA-7NRBYZ - added bAllTexture param. |
|
174 */ |
|
175 void RemoveTexture( const TGlxMediaId& aMediaId, TBool aAllTexture); |
|
176 |
|
177 |
|
178 /** |
|
179 * Creates a flat color texture and returns the reference to it |
|
180 */ |
|
181 CAlfTexture& CreateFlatColourTextureL( TRgb aColour ); |
|
182 |
|
183 public: // From MGlxCacheObserver |
|
184 void HandleAttributesAvailableL(const TGlxIdSpaceId& aIdSpaceId, |
|
185 const TGlxMediaId& aMediaId, |
|
186 const RArray<TMPXAttribute>& aAttributes, |
|
187 const CGlxMedia* aMedia); |
|
188 |
|
189 void CleanupMedia(const TGlxMediaId& aMediaId); |
|
190 |
|
191 public: // from MAlfBitmapProvider |
|
192 void ProvideBitmapL(TInt aId, |
|
193 CFbsBitmap*& aBitmap, |
|
194 CFbsBitmap*& aMaskBitmap); |
|
195 |
|
196 |
|
197 public: // From MGlxResolutionChangeObserver |
|
198 void HandleResolutionChangedL(); |
|
199 |
|
200 /** |
|
201 * Updates the texture for every Icon in the IconList. |
|
202 */ |
|
203 void UpdateTexture(); |
|
204 public: // From MGlxTextureRotatorObserver |
|
205 void HandleBitmapDecodedL(TInt aThumbnailIndex,CFbsBitmap* aBitmap); |
|
206 |
|
207 |
|
208 private: |
|
209 /** |
|
210 * Constructor |
|
211 * @param aAlfTextureManager The Alf Texture Manager |
|
212 */ |
|
213 CGlxTextureManagerImpl(CAlfTextureManager& aAlfTextureManager); |
|
214 |
|
215 /** |
|
216 * Second-phase constuction |
|
217 */ |
|
218 void ConstructL(); |
|
219 |
|
220 |
|
221 /** |
|
222 * GetThumbnailAttributeAndIndexL |
|
223 * @param aSize The size of the requested texture |
|
224 * @param aMedia The TGlxMedia item. |
|
225 * @param aThumbnailIndex on return will contain the Index of the thumbnail in the iThumbnailList |
|
226 * or KErrNotFound |
|
227 * @param aThumbnailAttribute on return will contain the Thumbnail attribute (if found) |
|
228 * @return ETrue if Thumbnail is available, EFalse if it needs to be created |
|
229 */ |
|
230 TBool GetThumbnailAttributeAndIndexL( TSize aSize, const TGlxMedia& aMedia, |
|
231 const TGlxIdSpaceId& aIdSpaceId, TInt& aThumbnailIndex, |
|
232 TMPXAttribute& aThumbnailAttribute ); |
|
233 |
|
234 /** |
|
235 * TGlxIcon |
|
236 * Values associated with a bitmap/svg icon |
|
237 */ |
|
238 class TGlxIcon |
|
239 { |
|
240 public: |
|
241 TInt iTextureId; |
|
242 CAlfTexture* iTexture; |
|
243 TAknsItemID iAvkonSkinId; |
|
244 TInt iBitmapId; |
|
245 TInt iFilenameIndex; |
|
246 TBool iSetColor; // indicates if color to be modified |
|
247 TRgb iDefaultColor; |
|
248 TAknsItemID iSkinColorId; |
|
249 TInt iSkinColorIndex; |
|
250 TReal32 iHeightInPoss; |
|
251 TReal32 iWidthInPoss; |
|
252 |
|
253 /** |
|
254 * Helper functor to be able to find texture from array |
|
255 */ |
|
256 static TBool MatchTexture( |
|
257 const CAlfTexture* aTexture, |
|
258 const TGlxIcon& aRhs ) |
|
259 { |
|
260 // return true if the address of the texture match |
|
261 return aTexture == aRhs.iTexture; |
|
262 } |
|
263 }; |
|
264 |
|
265 /** |
|
266 * TGlxThumbIcon |
|
267 * Values associated with a thumbnail. |
|
268 */ |
|
269 class TGlxThumbnailIcon |
|
270 { |
|
271 public: |
|
272 TInt iTextureId; |
|
273 CAlfTexture* iTexture; |
|
274 TMPXAttribute iAttribId; |
|
275 TSize iRequiredSize; |
|
276 TGlxMediaId iMediaId; |
|
277 TGlxIdSpaceId iIdSpaceId; |
|
278 MGlxTextureObserver* iObserver; |
|
279 CFbsBitmap* iBitmap; |
|
280 TTime iImageDate; |
|
281 /** |
|
282 * Helper functor to be able to find texture from array |
|
283 */ |
|
284 static TBool MatchTexture( |
|
285 const CAlfTexture* aTexture, |
|
286 const TGlxThumbnailIcon& aRhs ) |
|
287 { |
|
288 // return true if the address of the texture match |
|
289 return aTexture == aRhs.iTexture; |
|
290 } |
|
291 }; |
|
292 /** |
|
293 * Requests the best match texture. If it already exists this method does nothing. |
|
294 * However if it doed not exist it will create it and replace the old texture |
|
295 * if necessary. |
|
296 * @param aSize The size of the requested texture |
|
297 * @param aMedia The TGlxMedia item |
|
298 * @param aIdSpaceId The Id of the Id space in which the media Id is defined |
|
299 * @param aObserver Observer for the texture. |
|
300 * @param aAttribute specifies the type of texture to create |
|
301 * @param aThumbData the tumbnail data |
|
302 * @param aScaleGridTnm ETrue if the grid tnm to be scaled else EFalse. |
|
303 * @return Created texture, or NULL if the texture alreay exists |
|
304 */ |
|
305 CAlfTexture& CreateNewTextureL( TSize aSize, const TGlxMedia& aMedia, |
|
306 const TGlxIdSpaceId& aIdSpaceId, MGlxTextureObserver* aObserver, |
|
307 TMPXAttribute& aAttribute, TGlxThumbnailIcon& aThumbData,TBool aIsThumbnailTexture, TBool aScaleGridTnm); |
|
308 |
|
309 |
|
310 /** |
|
311 * TGlxProvideBitmapHolder |
|
312 * Used to hold the bitmaps and their associated texture id between |
|
313 * the call to create the alf texture and the callback to ProvideBitmap. |
|
314 */ |
|
315 class TGlxProvideBitmapHolder |
|
316 { |
|
317 public: |
|
318 TInt iTextureId; |
|
319 CFbsBitmap* iBitmap; // not owned |
|
320 CFbsBitmap* iMaskBitmap; // not owned |
|
321 }; |
|
322 |
|
323 /** |
|
324 * Select the most appropriate attribute to use to load bitmap |
|
325 * @param aThumbnail contains the data concerning the texture |
|
326 * @param aMedia the media |
|
327 * @return Index of selected attribute in list or KErrNotFound |
|
328 */ |
|
329 TMPXAttribute SelectAttributeL(TSize& aThumbnail, |
|
330 const TGlxMedia& aMedia); |
|
331 |
|
332 |
|
333 /** |
|
334 * Duplicates a bitmap |
|
335 * @param aOriginalBitmap original bitmap |
|
336 * @return duplicate bitmap |
|
337 */ |
|
338 CFbsBitmap* CreateDuplicateBitmapL( CFbsBitmap& aOriginalBitmap ); |
|
339 |
|
340 /** |
|
341 * Increments the texture id and returns it |
|
342 * @return next texture id |
|
343 */ |
|
344 TInt NextTextureId(); |
|
345 |
|
346 // void DoHandleResolutionChangedL(TInt aIconIndex); |
|
347 |
|
348 /** |
|
349 * Scales the grid Thumbnail bitmap to the fullscreen keeping the aspect |
|
350 * ratio. |
|
351 * @param aSrcSize The size of the original image |
|
352 * @param aDestSize The Fullscreen size |
|
353 * @param aScaledBitmap Pointer to the scaled bitmap |
|
354 * @param thumb thumbnail attributes. |
|
355 */ |
|
356 void ScaleGridTnmToFsL(TSize aSrcSize, TSize aDestSize, |
|
357 CFbsBitmap *aScaledBitmap, const CGlxThumbnailAttribute* thumb); |
|
358 |
|
359 private: |
|
360 // Alf Texture manager (not owned) |
|
361 CAlfTextureManager& iAlfTextureManager; |
|
362 |
|
363 // Next id to be allocated to icon textures provide within the application. |
|
364 TInt iNextTextureId; |
|
365 |
|
366 // List containing data for icon textures provided within the application. |
|
367 RArray<TGlxIcon> iIconList; |
|
368 |
|
369 // List containing data for textures generated from thumbnail bitmaps. |
|
370 RArray<TGlxThumbnailIcon> iThumbnailList; |
|
371 |
|
372 // List containing data for textures generated from zoomed thumbnail. |
|
373 RArray<TGlxThumbnailIcon> iZoomedList; |
|
374 |
|
375 // List of .mif filenames of files containing icons. |
|
376 CDesCArrayFlat* iMifFilenames; |
|
377 |
|
378 // DRM utility class |
|
379 CGlxDRMUtility* iDrmUtility; |
|
380 |
|
381 // MGlxCache instance |
|
382 MGlxCache* iCache; |
|
383 |
|
384 // CGlxResolutionUtility instance |
|
385 CGlxResolutionUtility* iResUtil; |
|
386 |
|
387 //The Bitmap Decoder Engine |
|
388 CGlxBitmapDecoderWrapper* iZoomDecoder; |
|
389 // Temporary storage class used between call to create a texture and the |
|
390 //callback from alf to ProvideBitmap |
|
391 TGlxProvideBitmapHolder iProvideBitmapHolder; |
|
392 |
|
393 }; |
|
394 |
|
395 #endif // C_GLXTEXTUREMANAGERIMPL_H |