|
1 /* |
|
2 * Copyright (c) 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: Juha Kauppinen, Mika Hokkanen |
|
13 * |
|
14 * Description: Photo Browser |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef IMAGIC_TEXTURE_LOADER_H |
|
19 #define IMAGIC_TEXTURE_LOADER_H |
|
20 |
|
21 // INCLUDES |
|
22 #include "ImagicViewBrowser.h" |
|
23 #include "ImagicContainerBrowser.h" |
|
24 #include <BitmapTransforms.h> |
|
25 |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CImagicViewBrowser; |
|
29 class CImagicAppUi; |
|
30 |
|
31 /*enum TTextureLoaderStatus |
|
32 { |
|
33 EIdle = 0, |
|
34 EScaling = 1, |
|
35 EDecoding = 2, |
|
36 ECreateSmileTex = 3, |
|
37 };*/ |
|
38 |
|
39 class CTextureLoader : public CActive |
|
40 { |
|
41 public: |
|
42 // Constructor and destructor |
|
43 void ConstructL(); |
|
44 CTextureLoader(CImagicAppUi* aImagicAppUi, CImagicContainerBrowser* aContainer, |
|
45 CImagicViewBrowser* aView, RCriticalSection* aDrawLock); |
|
46 ~CTextureLoader(); |
|
47 |
|
48 // Tells if loader is running at the moment |
|
49 inline const TBool IsRunning(void) const |
|
50 { |
|
51 return (iData!=NULL); |
|
52 } |
|
53 |
|
54 // Loads picture and stores the OpenGL index into specified variable |
|
55 void LoadL(CImageData* aData, TThumbSize aResolution); |
|
56 |
|
57 // Unloads picture from specified index |
|
58 void ReleaseSuperHResTexture(CImageData* aGridData); |
|
59 void ReleaseHQ512Textures(); |
|
60 void UnloadLQ512Tex(CImageData* aData) const; |
|
61 void UnloadLQ128Tex(CImageData* aData) const; |
|
62 void UnloadLQ32Tex(CImageData* aData) const; |
|
63 |
|
64 // Called when image is loaded |
|
65 void ImageLoadedL(TInt aError, CFbsBitmap* aBitmap, TInt aGLMaxRes); |
|
66 |
|
67 // Creates OpenGL texture of given bitmap |
|
68 static TInt CreateTexture(CFbsBitmap* aBitmap, TBool aHighQuality); |
|
69 void CreateIconTextures(/*RArray<CFbsBitmap*> aBitmapArray*/); |
|
70 void LoadIcons(); |
|
71 |
|
72 //void LoadAnimation(); |
|
73 TBool IsActiveAndRunning(); |
|
74 void GetPngL(TFileName& afilepath, CFbsBitmap* aBitmap); |
|
75 |
|
76 private: |
|
77 // Active object interface |
|
78 void RunL(); |
|
79 void DoCancel(); |
|
80 void RunError(); |
|
81 void CreateThumbnailTexture(CFbsBitmap* aBitmap); |
|
82 |
|
83 private: |
|
84 // Scales given value to power of two |
|
85 TInt ScaleDown(TInt aSize); |
|
86 TBool IsScalingNeeded(TSize aImageSize); |
|
87 |
|
88 private: |
|
89 CImagicViewBrowser* iView; // Pointer to view |
|
90 RCriticalSection* iDrawLock; // Drawing mutex |
|
91 CImagicContainerBrowser* iContainer; // Container class |
|
92 CFbsBitmap* iBitmap; // Bitmap for scaled picture |
|
93 CFbsBitmap* iSmileBitmap; // Bitmap for scaled picture |
|
94 CFbsBitmap* iZoomBitmap; // Bitmap for scaled picture |
|
95 RArray<CFbsBitmap*> iBitmapArray; // Bitmap for scaled picture |
|
96 CBitmapScaler* iBitmapScaler; // Bitmap scaler object |
|
97 CImageDecoder* iImageDecoder; |
|
98 |
|
99 CImageData* iData; // Pointer to one grid data |
|
100 TBool iHighQuality; // Is image supposed to be high quality |
|
101 |
|
102 TUint iNewIndex; // Texture index |
|
103 CImageData* iPreviousData; // Texture index |
|
104 |
|
105 |
|
106 TBool iCreateAnimation; |
|
107 GLuint iSmileTexIndex; |
|
108 RArray<GLuint> iIconTextureIndexes; |
|
109 TSize iImageSize; |
|
110 TBool iScalingNeeded; |
|
111 CImagicAppUi* iImagicAppUi; |
|
112 TInt iGLMaxRes; |
|
113 TThumbSize iResolution; |
|
114 TBool iClearCurrentLoading; |
|
115 TBool iRGB2BGRDone; |
|
116 }; |
|
117 |
|
118 #endif // IMAGIC_TEXTURE_LOADER_H |