|
1 /* |
|
2 * Copyright (c) 2004-2008 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: Effect that applies the given bitmap or SVG icon to the layer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "AknsRlEffectPluginApplyGfx.h" |
|
21 |
|
22 #include <AknIconUtils.h> |
|
23 #include <AknsSrvClient.h> |
|
24 |
|
25 #include "AknsFsHandleProvider.h" |
|
26 |
|
27 // CONSTANTS |
|
28 /*lint -save -e618 */ // Disables lint nag about _LIT |
|
29 const TInt KApplyGfxEffectUID = 0x101F8748; |
|
30 _LIT( KApplyGfxParamFilename, "f" ); |
|
31 _LIT( KApplyGfxParamScaleMode, "ms" ); |
|
32 static const TInt KApplyGfxValueScaleModePreserveAspect = 0; |
|
33 static const TInt KApplyGfxValueScaleModeStretch = 1; |
|
34 _LIT( KApplyGfxParamXTiles, "tx" ); |
|
35 _LIT( KApplyGfxParamYTiles, "ty" ); |
|
36 _LIT( KApplyGfxParamTileW, "tw" ); |
|
37 _LIT( KApplyGfxParamTileH, "th" ); |
|
38 _LIT( KApplyGfxParamAspectLT, "alt" ); |
|
39 _LIT( KApplyGfxParamAspectGT, "agt" ); |
|
40 _LIT( KApplyGfxParamGenImg, "g" ); |
|
41 /*lint -restore */ |
|
42 |
|
43 _LIT(KAknsSrvPrivateLocation, "private\\10207114\\"); |
|
44 |
|
45 |
|
46 // ============================= LOCAL FUNCTIONS =============================== |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // DivAndRoundUp |
|
50 // |
|
51 // Divides the given number by the given divider, and rounds the resulting |
|
52 // integer upward, if there is a non-zero remainder. |
|
53 // |
|
54 // Returns: Divedend as an integer. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 TInt DivAndRoundUp( const TInt aNumber, const TInt aDivider ) |
|
58 { |
|
59 TInt result = aNumber/aDivider; |
|
60 if( aNumber%aDivider ) |
|
61 { |
|
62 result+=1; |
|
63 } |
|
64 return result; |
|
65 } |
|
66 |
|
67 // Destroys preserved icon. |
|
68 void DestroyPreservedIcon( TAny* aBitmap ) |
|
69 { |
|
70 CFbsBitmap* bitmap = static_cast<CFbsBitmap*>(aBitmap); |
|
71 if ( bitmap ) |
|
72 { |
|
73 AknIconUtils::DestroyIconData( bitmap ); |
|
74 } |
|
75 } |
|
76 |
|
77 // ============================ MEMBER FUNCTIONS =============================== |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CAknsRlEffectPluginApplyGfx::CAknsRlEffectPluginApplyGfx |
|
81 // C++ default constructor can NOT contain any code, that |
|
82 // might leave. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CAknsRlEffectPluginApplyGfx::CAknsRlEffectPluginApplyGfx() |
|
86 { |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // Destructor |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CAknsRlEffectPluginApplyGfx::~CAknsRlEffectPluginApplyGfx() |
|
94 { |
|
95 iContext = NULL; // Removes lint nag |
|
96 iFilename = NULL; // Removes lint nag |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CAknsRlEffectPluginApplyGfx::EffectUid |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 TUid CAknsRlEffectPluginApplyGfx::EffectUid() const |
|
104 { |
|
105 return TUid::Uid( KApplyGfxEffectUID ); |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CAknsRlEffectPluginApplyGfx::Effect |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 MAknsRlEffect* CAknsRlEffectPluginApplyGfx::Effect( const TInt aInterface ) |
|
113 { |
|
114 if( aInterface == KAknsRlEffectPluginInterfaceEffect ) |
|
115 { |
|
116 return this; |
|
117 } |
|
118 return NULL; |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CAknsRlEffectPluginApplyGfx::InitializeL |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CAknsRlEffectPluginApplyGfx::InitializeL() |
|
126 { |
|
127 iContext = NULL; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CAknsRlEffectPluginApplyGfx::Release |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CAknsRlEffectPluginApplyGfx::Release() |
|
135 { |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CAknsRlEffectPluginApplyGfx::ActivateL |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CAknsRlEffectPluginApplyGfx::ActivateL( MAknsRlEffectContext* aContext ) |
|
143 { |
|
144 if( !aContext ) // We absolutely need the context |
|
145 { |
|
146 User::Leave( KErrArgument ); |
|
147 } |
|
148 |
|
149 iContext = aContext; |
|
150 |
|
151 iFilename = NULL; |
|
152 iBmpIndex = -1; |
|
153 iMaskIndex = -1; |
|
154 |
|
155 iScaleMode = KApplyGfxValueScaleModeStretch; |
|
156 iTiled = EFalse; |
|
157 iTilesX = 1; |
|
158 iTilesY = 1; |
|
159 iTileW = 0; |
|
160 iTileH = 0; |
|
161 |
|
162 iMaxAspect = -1; |
|
163 iMinAspect = -1; |
|
164 iGenericImage = 0; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CAknsRlEffectPluginApplyGfx::Deactivate |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CAknsRlEffectPluginApplyGfx::Deactivate() |
|
172 { |
|
173 delete iFilename; |
|
174 iFilename = NULL; |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CAknsRlEffectPluginApplyGfx::SetParametersL |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CAknsRlEffectPluginApplyGfx::SetParametersL( |
|
182 MAknsRlParameterIterator& aParameters ) |
|
183 { |
|
184 while( aParameters.HasNext() ) |
|
185 { |
|
186 const TAknsRlParameterData* param = aParameters.NextL(); |
|
187 |
|
188 if( param->iName->Compare(KApplyGfxParamFilename) == 0 ) |
|
189 { |
|
190 if( param->iType != EAknsRlParameterTypeGraphics ) |
|
191 { |
|
192 User::Leave( KErrArgument ); |
|
193 } |
|
194 delete iFilename; |
|
195 iFilename = NULL; |
|
196 iFilename = param->iGfx->iFilename->AllocL(); |
|
197 iBmpIndex = param->iGfx->iIndex; |
|
198 iMaskIndex = param->iGfx->iMaskIndex; |
|
199 } |
|
200 else if( param->iName->Compare(KApplyGfxParamScaleMode) == 0 ) |
|
201 { |
|
202 if( param->iType != EAknsRlParameterTypeNumber ) |
|
203 { |
|
204 User::Leave( KErrArgument ); |
|
205 } |
|
206 iScaleMode = param->iNumber; |
|
207 } |
|
208 else if( param->iName->Compare(KApplyGfxParamXTiles) == 0 ) |
|
209 { |
|
210 if( param->iType != EAknsRlParameterTypeNumber ) |
|
211 { |
|
212 User::Leave( KErrArgument ); |
|
213 } |
|
214 iTilesX = param->iNumber; |
|
215 iTiled = ETrue; |
|
216 } |
|
217 else if( param->iName->Compare(KApplyGfxParamYTiles) == 0 ) |
|
218 { |
|
219 if( param->iType != EAknsRlParameterTypeNumber ) |
|
220 { |
|
221 User::Leave( KErrArgument ); |
|
222 } |
|
223 iTilesY = param->iNumber; |
|
224 iTiled = ETrue; |
|
225 } |
|
226 else if( param->iName->Compare(KApplyGfxParamTileW) == 0 ) |
|
227 { |
|
228 if( param->iType != EAknsRlParameterTypeNumber ) |
|
229 { |
|
230 User::Leave( KErrArgument ); |
|
231 } |
|
232 iTileW = param->iNumber; |
|
233 iTiled = ETrue; |
|
234 } |
|
235 else if( param->iName->Compare(KApplyGfxParamTileH) == 0 ) |
|
236 { |
|
237 if( param->iType != EAknsRlParameterTypeNumber ) |
|
238 { |
|
239 User::Leave( KErrArgument ); |
|
240 } |
|
241 iTileH = param->iNumber; |
|
242 iTiled = ETrue; |
|
243 } |
|
244 else if( param->iName->Compare(KApplyGfxParamAspectGT) == 0 ) |
|
245 { |
|
246 if( param->iType != EAknsRlParameterTypeNumber ) |
|
247 { |
|
248 User::Leave( KErrArgument ); |
|
249 } |
|
250 iMinAspect = param->iNumber; |
|
251 } |
|
252 else if( param->iName->Compare(KApplyGfxParamAspectLT) == 0 ) |
|
253 { |
|
254 if( param->iType != EAknsRlParameterTypeNumber ) |
|
255 { |
|
256 User::Leave( KErrArgument ); |
|
257 } |
|
258 iMaxAspect = param->iNumber; |
|
259 } |
|
260 else if( param->iName->Compare(KApplyGfxParamGenImg) == 0 ) |
|
261 { |
|
262 if( param->iType != EAknsRlParameterTypeNumber ) |
|
263 { |
|
264 User::Leave( KErrArgument ); |
|
265 } |
|
266 iGenericImage = param->iNumber; |
|
267 } |
|
268 } |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CAknsRlEffectPluginApplyGfx::GetCapabilities |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 void CAknsRlEffectPluginApplyGfx::GetCapabilities( TAknsRlEffectCaps& aCaps ) |
|
276 { |
|
277 // Input layers are not used |
|
278 aCaps.iInputLayerASupport = KAknsRlLayerNone; |
|
279 aCaps.iInputLayerBSupport = KAknsRlLayerNone; |
|
280 aCaps.iOutputLayerSupport = KAknsRlLayerRGBOnly | |
|
281 KAknsRlLayerAlphaOnly | KAknsRlLayerRGBA; |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CAknsRlEffectPluginApplyGfx::Render |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 TInt CAknsRlEffectPluginApplyGfx::Render( const TAknsRlRenderOpParam& aParam ) |
|
289 { |
|
290 TRAPD( err, DoRenderL( aParam ) ); |
|
291 return err; |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CAknsRlEffectPluginApplyGfx::DoRenderL |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CAknsRlEffectPluginApplyGfx::DoRenderL( const TAknsRlRenderOpParam& aParam ) |
|
299 { |
|
300 TSize layoutSize = iContext->LayerSize(); |
|
301 TInt aspect = KMaxTInt; |
|
302 if( layoutSize.iHeight != 0 ) |
|
303 { |
|
304 aspect = (layoutSize.iWidth*256) / layoutSize.iHeight; |
|
305 } |
|
306 |
|
307 if( iMaxAspect >= 0 ) |
|
308 { |
|
309 if( aspect >= iMaxAspect ) return; |
|
310 } |
|
311 if( iMinAspect >= 0 ) |
|
312 { |
|
313 if( aspect <= iMinAspect ) return; |
|
314 } |
|
315 |
|
316 TAknsRlLayerData layerData; |
|
317 iContext->GetLayerDataL( layerData, aParam.iOutputLayerIndex, |
|
318 aParam.iOutputLayerStatus, ETrue ); |
|
319 |
|
320 if( !iFilename ) User::Leave( KErrArgument ); |
|
321 if( iBmpIndex<0 ) User::Leave( KErrArgument ); |
|
322 |
|
323 TBool hasMask = ETrue; |
|
324 if( iMaskIndex<0 ) hasMask = EFalse; |
|
325 |
|
326 CFbsBitmap* bitmap = NULL; |
|
327 CFbsBitmap* mask = NULL; |
|
328 |
|
329 RAknsSrvSession* skinsrvsession = NULL; |
|
330 |
|
331 TBool altbmplocation = ETrue; |
|
332 #ifdef AKNS_RL_TEST_FRAMEWORK |
|
333 // Note: Pragma message causes CodeTest compiler to go berserk. |
|
334 #pragma message("Compiling ApplyGfx WITHOUT filename check <----------------") |
|
335 // Don't compile filename check to test framework. This is required to make |
|
336 // ApplyGfx behave with unit tests. |
|
337 #else |
|
338 |
|
339 if (iGenericImage) |
|
340 { |
|
341 hasMask = EFalse; |
|
342 } |
|
343 else |
|
344 { |
|
345 TInt res = (*iFilename).FindF(KAknsSrvPrivateLocation); |
|
346 if (res >= 0) // location found |
|
347 { |
|
348 altbmplocation = EFalse; |
|
349 } |
|
350 } |
|
351 #endif |
|
352 |
|
353 skinsrvsession = iContext->GetSkinSrvSession(); |
|
354 if (!skinsrvsession) |
|
355 { |
|
356 User::Leave(KErrArgument); |
|
357 } |
|
358 |
|
359 if( hasMask && !iGenericImage) |
|
360 { |
|
361 if (!altbmplocation) |
|
362 { |
|
363 // AknIconUtils will call CAknsFsHandleProvider::Finished when it is ready => deletes the object |
|
364 CAknsFsHandleProvider* provider = CAknsFsHandleProvider::NewL(skinsrvsession, *iFilename); |
|
365 AknIconUtils::CreateIconL( |
|
366 bitmap, mask, *provider, iBmpIndex, iMaskIndex ); |
|
367 } |
|
368 else |
|
369 { |
|
370 AknIconUtils::CreateIconL( |
|
371 bitmap, mask, *iFilename, iBmpIndex, iMaskIndex ); |
|
372 } |
|
373 |
|
374 CleanupStack::PushL( bitmap ); |
|
375 CleanupStack::PushL( mask ); |
|
376 if( !bitmap || !mask ) |
|
377 { |
|
378 User::Leave( KErrNotFound ); |
|
379 } |
|
380 } |
|
381 else if (!iGenericImage) |
|
382 { |
|
383 if (!altbmplocation) |
|
384 { |
|
385 // AknIconUtils will call CAknsFsHandleProvider::Finished when it is ready => deletes the object |
|
386 CAknsFsHandleProvider* provider = CAknsFsHandleProvider::NewL(skinsrvsession, *iFilename); |
|
387 bitmap = AknIconUtils::CreateIconL( *provider, iBmpIndex ); |
|
388 } |
|
389 else |
|
390 { |
|
391 bitmap = AknIconUtils::CreateIconL( *iFilename, iBmpIndex ); |
|
392 } |
|
393 |
|
394 CleanupStack::PushL( bitmap ); // bitmap |
|
395 if( !bitmap ) |
|
396 { |
|
397 User::Leave( KErrNotFound ); |
|
398 } |
|
399 } |
|
400 else // isGenericImage |
|
401 { |
|
402 TInt decodeErr = KErrNone; |
|
403 TRAP(decodeErr, |
|
404 skinsrvsession->DecodeWallpaperImageL(*iFilename, layoutSize, bitmap, mask)); |
|
405 if (decodeErr == KErrNoMemory) |
|
406 { |
|
407 // ignore OOM errors, so that the phone will |
|
408 // not try to do this whole time |
|
409 return; |
|
410 } |
|
411 else |
|
412 { |
|
413 User::LeaveIfError(decodeErr); |
|
414 } |
|
415 |
|
416 if (!bitmap) |
|
417 { |
|
418 User::Leave( KErrNotFound ); |
|
419 } |
|
420 CleanupStack::PushL(bitmap); |
|
421 if (mask) |
|
422 { |
|
423 hasMask = ETrue; |
|
424 CleanupStack::PushL(mask); |
|
425 } |
|
426 } |
|
427 |
|
428 TSize srcSize; |
|
429 TBool svg = AknIconUtils::IsMifIcon( bitmap ); |
|
430 TBool svgIconDataPreserved = EFalse; |
|
431 if( svg && !iGenericImage) |
|
432 { |
|
433 svgIconDataPreserved = ETrue; |
|
434 AknIconUtils::PreserveIconData( bitmap ); |
|
435 CleanupStack::PushL( TCleanupItem( DestroyPreservedIcon, bitmap ) ); |
|
436 if( AknIconUtils::GetContentDimensions( bitmap, srcSize ) ) |
|
437 { |
|
438 User::Leave( KErrUnknown ); |
|
439 } |
|
440 } |
|
441 else |
|
442 { |
|
443 srcSize = bitmap->SizeInPixels(); |
|
444 } |
|
445 TInt srcAspect = KMaxTInt; |
|
446 if( srcSize.iHeight ) |
|
447 { |
|
448 srcAspect = (srcSize.iWidth<<16) / srcSize.iHeight; |
|
449 } |
|
450 |
|
451 TInt layoutAspect = KMaxTInt; |
|
452 if( layoutSize.iHeight ) |
|
453 { |
|
454 layoutAspect = (layoutSize.iWidth<<16) / layoutSize.iHeight; |
|
455 } |
|
456 |
|
457 TRect imgRect; |
|
458 if( iTiled ) |
|
459 { |
|
460 // Zero checks |
|
461 if( (iTilesX<1) || (iTilesY<1) ) { |
|
462 User::Leave( KErrArgument ); |
|
463 } |
|
464 |
|
465 TSize tileSize( |
|
466 DivAndRoundUp( layoutSize.iWidth, iTilesX ), |
|
467 DivAndRoundUp( layoutSize.iHeight, iTilesY ) ); |
|
468 |
|
469 if( iTileW>0 ) |
|
470 { |
|
471 tileSize.iWidth = iTileW; |
|
472 iTilesX = DivAndRoundUp( layoutSize.iWidth, tileSize.iWidth ); |
|
473 } |
|
474 |
|
475 if( iTileH>0 ) |
|
476 { |
|
477 tileSize.iHeight = iTileH; |
|
478 iTilesY = DivAndRoundUp( layoutSize.iHeight, tileSize.iHeight ); |
|
479 } |
|
480 AknIconUtils::ExcludeFromCache( bitmap ); |
|
481 User::LeaveIfError( |
|
482 AknIconUtils::SetSize( |
|
483 bitmap, tileSize, EAspectRatioNotPreserved ) ); |
|
484 |
|
485 imgRect = TRect( TPoint(0,0), tileSize ); |
|
486 } |
|
487 else |
|
488 { |
|
489 // Disable tiling in drawing |
|
490 iTilesX = 1; |
|
491 iTilesY = 1; |
|
492 |
|
493 if( iScaleMode == KApplyGfxValueScaleModePreserveAspect ) |
|
494 { |
|
495 if( srcAspect > layoutAspect ) |
|
496 { |
|
497 if (!iGenericImage) |
|
498 { |
|
499 //28-Apr-2008 Modified by Ding Long |
|
500 //according to Merila Sami suggestion. |
|
501 //Comment out to speed up Screen Rotation. |
|
502 //(Refer to defect AVAO-7D4BXY.) |
|
503 //AknIconUtils::ExcludeFromCache( bitmap ); |
|
504 User::LeaveIfError( |
|
505 AknIconUtils::SetSize( |
|
506 bitmap, TSize(KMaxTInt, layoutSize.iHeight), |
|
507 EAspectRatioPreservedAndUnusedSpaceRemoved ) ); |
|
508 } |
|
509 } |
|
510 else |
|
511 { |
|
512 if (!iGenericImage) |
|
513 { |
|
514 //28-Apr-2008 Modified by Ding Long |
|
515 //according to Merila Sami suggestion. |
|
516 //Comment out to speed up Screen Rotation. |
|
517 //(Refer to defect AVAO-7D4BXY.) |
|
518 //AknIconUtils::ExcludeFromCache( bitmap ); |
|
519 User::LeaveIfError( |
|
520 AknIconUtils::SetSize( |
|
521 bitmap, TSize(layoutSize.iWidth, KMaxTInt), |
|
522 EAspectRatioPreservedAndUnusedSpaceRemoved ) ); |
|
523 } |
|
524 } |
|
525 TSize bmpSize = bitmap->SizeInPixels(); |
|
526 imgRect = TRect( TPoint( |
|
527 (bmpSize.iWidth-layoutSize.iWidth)/2, |
|
528 (bmpSize.iHeight-layoutSize.iHeight)/2), layoutSize ); |
|
529 } |
|
530 else if( iScaleMode == KApplyGfxValueScaleModeStretch ) |
|
531 { |
|
532 if (!iGenericImage) |
|
533 { |
|
534 //28-Apr-2008 Modified by Ding Long |
|
535 //according to Merila Sami suggestion. |
|
536 //Comment out to speed up Screen Rotation. |
|
537 //(Refer to defect AVAO-7D4BXY.) |
|
538 //AknIconUtils::ExcludeFromCache( bitmap ); |
|
539 User::LeaveIfError( |
|
540 AknIconUtils::SetSize( |
|
541 bitmap, layoutSize, |
|
542 EAspectRatioNotPreserved ) ); |
|
543 } |
|
544 imgRect = TRect( TPoint(0,0), layoutSize ); |
|
545 } |
|
546 else |
|
547 { |
|
548 User::Leave( KErrNotSupported ); |
|
549 } |
|
550 } |
|
551 |
|
552 // @TODO This does not do mask inversion for hard->soft. |
|
553 |
|
554 // Icon operations should be done by now |
|
555 if (!iGenericImage) |
|
556 { |
|
557 if ( svgIconDataPreserved ) |
|
558 { |
|
559 svgIconDataPreserved = EFalse; |
|
560 CleanupStack::PopAndDestroy(); // DestroyPreservedIcon |
|
561 } |
|
562 } |
|
563 TPoint drawPoint( 0, 0 ); |
|
564 TBool generatedMask = EFalse; |
|
565 for( TInt yTile=0; yTile<iTilesY; yTile++ ) |
|
566 { |
|
567 drawPoint.iX = 0; |
|
568 if (iGenericImage) |
|
569 { |
|
570 if (bitmap->SizeInPixels().iWidth < layoutSize.iWidth) |
|
571 { |
|
572 drawPoint.iX = (layoutSize.iWidth / 2) - (bitmap->SizeInPixels().iWidth /2); |
|
573 if (!hasMask) |
|
574 { |
|
575 generatedMask = ETrue; |
|
576 } |
|
577 } |
|
578 if (bitmap->SizeInPixels().iHeight < layoutSize.iHeight) |
|
579 { |
|
580 drawPoint.iY = (layoutSize.iHeight / 2) - (bitmap->SizeInPixels().iHeight /2); |
|
581 if (!hasMask) |
|
582 { |
|
583 generatedMask = ETrue; |
|
584 } |
|
585 } |
|
586 } |
|
587 for( TInt xTile=0; xTile<iTilesX; xTile++ ) |
|
588 { |
|
589 if( layerData.iRGBGc ) |
|
590 { |
|
591 layerData.iRGBGc->SetBrushStyle( |
|
592 CGraphicsContext::ENullBrush ); |
|
593 } |
|
594 if( layerData.iAlphaGc ) |
|
595 { |
|
596 layerData.iAlphaGc->SetBrushStyle( |
|
597 CGraphicsContext::ENullBrush ); |
|
598 } |
|
599 |
|
600 if( (aParam.iOutputLayerStatus==KAknsRlLayerRGBOnly) || |
|
601 (aParam.iOutputLayerStatus==KAknsRlLayerRGBA) ) |
|
602 { |
|
603 layerData.iRGBGc->BitBlt( drawPoint, bitmap, imgRect ); |
|
604 // When RGBOnly is queried alpha information is not filled -> |
|
605 // we need to check alphaGc exists. |
|
606 if (generatedMask && layerData.iAlphaGc) |
|
607 { |
|
608 layerData.iAlphaGc->SetBrushColor( KRgbBlack ); |
|
609 layerData.iAlphaGc->Clear(); |
|
610 layerData.iAlphaGc->SetBrushStyle( |
|
611 CGraphicsContext::ESolidBrush ); |
|
612 |
|
613 layerData.iAlphaGc->SetPenColor(KRgbWhite); |
|
614 layerData.iAlphaGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
615 layerData.iAlphaGc->SetBrushColor( KRgbWhite ); |
|
616 TRect rect(drawPoint, bitmap->SizeInPixels()); |
|
617 layerData.iAlphaGc->DrawRect(rect); |
|
618 layerData.iAlphaGc->SetBrushStyle( |
|
619 CGraphicsContext::ENullBrush ); |
|
620 layerData.iAlphaGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
621 } |
|
622 } |
|
623 if( aParam.iOutputLayerStatus==KAknsRlLayerRGBA && hasMask) |
|
624 { |
|
625 layerData.iAlphaGc->BitBlt( drawPoint, mask, imgRect ); |
|
626 } |
|
627 if( aParam.iOutputLayerStatus==KAknsRlLayerAlphaOnly ) |
|
628 { |
|
629 // If there is no mask, draw bitmap to alpha channel |
|
630 CFbsBitmap* srcBitmap = bitmap; |
|
631 if( hasMask ) |
|
632 { |
|
633 // ... otherwise, draw mask to alpha channel |
|
634 srcBitmap = mask; |
|
635 } |
|
636 layerData.iAlphaGc->BitBlt( drawPoint, srcBitmap, imgRect ); |
|
637 } |
|
638 |
|
639 drawPoint.iX += imgRect.Size().iWidth; |
|
640 } |
|
641 |
|
642 drawPoint.iY += imgRect.Size().iHeight; |
|
643 } |
|
644 |
|
645 if( aParam.iOutputLayerStatus==KAknsRlLayerRGBA && !hasMask && !generatedMask ) |
|
646 { |
|
647 // RGBA and no mask, clear with white |
|
648 layerData.iAlphaGc->SetBrushColor( KRgbWhite ); |
|
649 layerData.iAlphaGc->Clear(); |
|
650 } |
|
651 if ( svgIconDataPreserved ) |
|
652 { |
|
653 CleanupStack::PopAndDestroy(); // DestroyPreservedIcon |
|
654 } |
|
655 |
|
656 if( hasMask ) |
|
657 { |
|
658 CleanupStack::PopAndDestroy( mask ); |
|
659 } |
|
660 CleanupStack::PopAndDestroy( bitmap ); |
|
661 } |
|
662 |
|
663 // End of File |