|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32math.h> |
|
22 #include <fbs.h> |
|
23 #include <mifconvdefs.h> // For definition of EIconFormatNVG |
|
24 |
|
25 #include "AknNvgFormatHandler.h" |
|
26 #include "AknIconObserver.h" |
|
27 #include "AknIconSrvPanic.h" |
|
28 #include "AknIconTraces.h" |
|
29 #include <flogger.h> |
|
30 #include "AknIconManager.h" |
|
31 #include "AknIconHeader.h" |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CAknNvgFormatHandler::CAknNvgFormatHandler |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CAknNvgFormatHandler::CAknNvgFormatHandler():iMode(EAspectRatioPreserved),iAngle(0) |
|
45 { |
|
46 iData = 0x00; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CAknNvgFormatHandler::ConstructL |
|
51 // Symbian 2nd phase constructor can leave. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CAknNvgFormatHandler::ConstructL() |
|
55 { |
|
56 #ifdef __AKNICON_TRACES |
|
57 RDebug::Print( _L("AknIcon: %x Calling ConstructL - iSvgEngine: %x"), this, iSvgEngine); |
|
58 #endif |
|
59 } |
|
60 |
|
61 CAknNvgFormatHandler* CAknNvgFormatHandler::NewL() |
|
62 { |
|
63 CAknNvgFormatHandler* self = new( ELeave ) CAknNvgFormatHandler(); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 CleanupStack::Pop(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // Destructor |
|
71 CAknNvgFormatHandler::~CAknNvgFormatHandler() |
|
72 { |
|
73 iIconData.Close(); |
|
74 delete iData; |
|
75 delete iDummyBitmap; |
|
76 delete iNvgEngine; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CAknNvgFormatHandler::SetScaleMode |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CAknNvgFormatHandler::SetScaleMode( TScaleMode aMode ) |
|
84 { |
|
85 iMode = aMode; |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CAknNvgFormatHandler::SetRotation |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CAknNvgFormatHandler::SetRotation( TInt aAngle ) |
|
93 { |
|
94 iAngle = aAngle; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CAknNvgFormatHandler::GetContentDimensionsL |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CAknNvgFormatHandler::GetContentDimensionsL( |
|
102 TAknContentDimensions& aContentDimensions) |
|
103 { |
|
104 if ( iNvgEngine && iData) |
|
105 { |
|
106 TSize lSize = iNvgEngine->ContentDimensions(iData->Des().MidTPtr(KIconHeaderLength) ); |
|
107 aContentDimensions.SetDimensions( lSize ); |
|
108 } |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CAknNvgFormatHandler::InitializeEngineL |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CAknNvgFormatHandler::InitializeEngineL() |
|
116 { |
|
117 if ( !iNvgEngine) |
|
118 { |
|
119 iNvgEngine = CNvgEngine::NewL( ); |
|
120 } |
|
121 |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CAknNvgFormatHandler::PrepareIconL |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CAknNvgFormatHandler::PrepareIconL( const TDesC8& aIconData, TInt& aHandle ) |
|
129 { |
|
130 InitializeEngineL(); |
|
131 |
|
132 TInt handle = 1; |
|
133 |
|
134 |
|
135 if (iData) |
|
136 { |
|
137 delete iData; |
|
138 iData = NULL; |
|
139 } |
|
140 |
|
141 iData = HBufC8::NewL(aIconData.Size()+KIconHeaderLength); |
|
142 |
|
143 TPtr8 lPtr(iData->Des() ); |
|
144 TUint8 header[KIconHeaderLength]= |
|
145 { |
|
146 0 |
|
147 }; |
|
148 |
|
149 lPtr.Append(header, KIconHeaderLength); |
|
150 |
|
151 lPtr.Append(aIconData); |
|
152 |
|
153 aHandle = handle; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CAknNvgFormatHandler::UsePreparedIconL |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CAknNvgFormatHandler::UsePreparedIconL(TInt /*aHandle */) |
|
161 { |
|
162 |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CAknNvgFormatHandler::RenderPreparedIconL |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CAknNvgFormatHandler::RenderPreparedIconL(CFbsBitmap* aBitmap, |
|
170 CFbsBitmap* aMask, TSize Bitmapsize, TDisplayMode Bitmapdepth, |
|
171 TDisplayMode Maskdepth, TRgb aColor, TBool aMarginFlag) |
|
172 { |
|
173 FormCommonHeader(aBitmap, EFalse, aColor, aMarginFlag); |
|
174 aBitmap->CreateExtendedBitmap(Bitmapsize, Bitmapdepth, |
|
175 KUidNvgProprietaryFormat, iData->Ptr(), iData->Length()); |
|
176 |
|
177 if (aMask) |
|
178 { |
|
179 FormCommonHeader(0, ETrue, 0, 0); |
|
180 aMask->CreateExtendedBitmap(Bitmapsize, Maskdepth, |
|
181 KUidNvgProprietaryFormat, iData->Ptr(), iData->Length()); |
|
182 } |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CAknNvgFormatHandler::UnprepareIcon |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CAknNvgFormatHandler::UnprepareIcon( TInt /*aHandle*/ ) |
|
190 { |
|
191 delete iData; |
|
192 iData = NULL; |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CAknNvgFormatHandler::SetAnimated |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CAknNvgFormatHandler::SetAnimated( TBool aAnimated ) |
|
200 { |
|
201 iAnimated = aAnimated; |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // CAknNvgFormatHandler::IconFormatType |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 TInt CAknNvgFormatHandler::IconFormatType() |
|
209 { |
|
210 return EIconFormatNVG; |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CAknNvgFormatHandler::SetObserver |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void CAknNvgFormatHandler::SetObserver( MAknIconChangeObserver* aObserver ) |
|
218 { |
|
219 |
|
220 iObserver = aObserver; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CAknNvgFormatHandler::CheckHandleActivatedL |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 |
|
228 void CAknNvgFormatHandler::CheckHandleActivatedL( CFbsBitmap* /*aBitmap*/, CFbsBitmap * /*aMask*/ ) |
|
229 { |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CAknNvgFormatHandler::SupportedDisplayMode |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 void CAknNvgFormatHandler::SupportedDisplayMode( |
|
237 TDisplayMode& aMode, TDisplayMode aPreferredMode ) |
|
238 { |
|
239 // Modes currently supported by SVG engine are: |
|
240 // EGray2, EColor4K, EColor64K, EColor16M |
|
241 if ( aMode != EGray2 ) |
|
242 { |
|
243 aMode = aPreferredMode; |
|
244 } |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CAknNvgFormatHandler::SetEngineScaleMode |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 |
|
252 void CAknNvgFormatHandler::SetEngineScaleMode() |
|
253 { |
|
254 |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CAknNvgFormatHandler::CleanupNullMaskPointer |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 // |
|
262 void CAknNvgFormatHandler::CleanupNullMaskPointer(TAny* aParam) |
|
263 { |
|
264 static_cast<CAknNvgFormatHandler*>( aParam )->iMask = NULL; |
|
265 } |
|
266 |
|
267 void CAknNvgFormatHandler::FormCommonHeader(const CFbsBitmap *aBitmap, |
|
268 TBool isMask, TRgb aColor, TBool aMarginFlag) |
|
269 { |
|
270 |
|
271 TPtr8 tmpBufPtr(iData->Des()); |
|
272 |
|
273 TAknIconHeader iconheader(tmpBufPtr); |
|
274 |
|
275 if(isMask) |
|
276 { |
|
277 iconheader.SetIsMask(ETrue); |
|
278 return; |
|
279 } |
|
280 |
|
281 iconheader.Initialize(); |
|
282 |
|
283 iconheader.SetRotation(iAngle); |
|
284 |
|
285 iconheader.SetIconColor(aColor.Value()); |
|
286 |
|
287 iconheader.SetScaleMode(iMode); |
|
288 |
|
289 if(aMarginFlag) |
|
290 iconheader.SetMarginCorrection(ETrue); |
|
291 |
|
292 iconheader.SetIsMask(EFalse); |
|
293 |
|
294 iconheader.SetBitmapId(aBitmap->Handle()); |
|
295 } |
|
296 |
|
297 |
|
298 // End of File |