// ----------------------------------------------------------------------------- // AknsUtils::CreateIconLC // ----------------------------------------------------------------------------- // EXPORT_C void AknsUtils::CreateIconLC( MAknsSkinInstance* aInstance, const TAknsItemID& aID, CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, const TDesC& aFilename, const TInt aFileBitmapId, const TInt aFileMaskId ) { CFbsBitmap* bitmap = NULL; CFbsBitmap* mask = NULL; TBool fallback = EFalse; if( aInstance ) { CAknsMaskedBitmapItemData* bmpData = static_cast<CAknsMaskedBitmapItemData*>( aInstance->CreateUncachedItemDataL( aID, EAknsITMaskedBitmap ) ); CleanupStack::PushL( bmpData ); if( bmpData && bmpData->Bitmap() && bmpData->Mask() ) { // Detach bitmaps bitmap = bmpData->Bitmap(); bmpData->SetBitmap( NULL ); mask = bmpData->Mask(); bmpData->SetMask( NULL ); } CleanupStack::PopAndDestroy( bmpData ); } if( bitmap ) // Mask is also loaded { CleanupStack::PushL( mask ); CleanupStack::PushL( bitmap ); } else { if( !aFilename.Length() ) { User::Leave( KErrNotFound ); } // Fallback AknIconUtils::CreateIconLC( bitmap, mask, aFilename, aFileBitmapId, aFileMaskId ); fallback = ETrue; } if( (bitmap && mask) || fallback) { // Ownership transferred aBitmap = bitmap; aMask = mask; } else { User::Leave( KErrUnknown ); } }
// ----------------------------------------------------------------------------- // CTestSDKSkins::TestMBIDSetMaskL // ----------------------------------------------------------------------------- TInt CTestSDKSkins::TestMBIDSetMaskL( CStifItemParser& /*aItem*/ ) { CAknsMaskedBitmapItemData* itemData = CAknsMaskedBitmapItemData::NewL(); CleanupStack::PushL( itemData ); STIF_ASSERT_NOT_NULL( itemData ); CFbsBitmap* bitMapMask = new (ELeave) CFbsBitmap; CleanupStack::PushL( bitMapMask ); itemData->SetMask( bitMapMask ); STIF_ASSERT_TRUE( bitMapMask == itemData->Mask() ); CleanupStack::Pop( bitMapMask ); CleanupStack::PopAndDestroy( itemData ); return KErrNone; }
// ----------------------------------------------------------------------------- // AknsDrawUtils::DrawBackground() // (commented in the header). // ----------------------------------------------------------------------------- EXPORT_C TBool AknsDrawUtils::DrawBackground( MAknsSkinInstance* aInstance, MAknsControlContext* aContext, const CCoeControl* aControl, CBitmapContext& aGc, const TPoint& aDstPos, const TRect& aControlRect, const TInt aDrawParam ) { TInt drawParam = aDrawParam; TInt originalParam = aDrawParam; TBool retVal = EFalse; TBool blitFailed = EFalse; TBool blit = EFalse; TBool blitAttempted = EFalse; if ( !&aGc ) { return retVal; } MAknsControlContext* parentContext = GetParentContext( aContext ); if( parentContext ) { retVal = DrawBackground( aInstance, parentContext, aControl, aGc, aDstPos, aControlRect, aDrawParam ); drawParam |= KAknsDrawParamNoClearUnderImage; } else if( drawParam & KAknsDrawParamBottomLevelRGBOnly ) { drawParam |= KAknsDrawParamRGBOnly; } originalParam = drawParam; if( aContext ) { aContext->UpdateContext(); } TAknsBackground* bgLayout = RetrieveBackgroundLayout( aContext ); TAknsItemID imgIID( KAknsIIDNone ); CAknsImageItemData* imgData = RetrieveBackgroundImage( aInstance, bgLayout, imgIID ); // chained background if (imgData && imgData->ParentIID() != KAknsIIDNone) { TAknsItemID parentiid = imgData->ParentIID(); TRect parentDrawRect = imgData->DrawRect(); imgData = RetrieveKnownBackgroundImage( aInstance, parentiid ); if (imgData) { imgData->SetDrawRect(parentDrawRect); drawParam |= KAknsDrawParamChained ; } } TPoint paDelta = GetParentAbsoluteDelta( bgLayout, aControl ); TRect drawRect = aControlRect; drawRect.Move( aDstPos-aControlRect.iTl ); paDelta += aControlRect.iTl-aDstPos; if (!(aDrawParam & KAknsDrawParamPrepareOnly)) { aGc.SetPenStyle(CGraphicsContext::ENullPen); aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); } if ( !(aDrawParam & KAknsDrawParamIgnoreLayerMask)) { if( imgData ) { blitAttempted = ETrue; if( (drawParam&KAknsDrawParamNoClearUnderImage)==0 ) { blit = BlitAndClear( aInstance, aGc, drawRect, imgData, imgIID, bgLayout, paDelta, drawParam ); } else { blit = Blit( aInstance, aGc, drawRect, imgData, imgIID, bgLayout, paDelta, drawParam ); } if ( !blit ) { blitFailed = ETrue; } } else { if( !(drawParam&KAknsDrawParamNoClearUnderImage) && !(drawParam&KAknsDrawParamPrepareOnly) ) { // Clear only if permitted aGc.DrawRect( drawRect ); } } } if( bgLayout ) { if (!(aDrawParam & KAknsDrawParamIgnoreLayerMask) && aContext->IsCompatibleWithType(EAknsControlContextTypeMasked)) { CAknsMaskedLayerBackgroundControlContext* layeredCxt = static_cast<CAknsMaskedLayerBackgroundControlContext*>(aContext); if (layeredCxt->iOffScreenBmp) { CAknsMaskedBitmapItemData* maskedImgData = NULL; TRAPD( err, maskedImgData = CAknsMaskedBitmapItemData::NewL() ); if ( err != KErrNone ) { return EFalse; } maskedImgData->SetBitmap(layeredCxt->iOffScreenBmp); maskedImgData->SetMask(layeredCxt->iLayerMask); TAknsBackground* childLayout = bgLayout->iNext; blitAttempted = ETrue; blit = Blit( aInstance, aGc, drawRect, maskedImgData, KAknsIIDNone, childLayout, paDelta, drawParam ); if ( !blit ) { blitFailed = ETrue; } maskedImgData->SetBitmap(NULL); maskedImgData->SetMask(NULL); delete maskedImgData; if (!(aDrawParam & KAknsDrawParamPrepareOnly)) { aGc.SetPenStyle(CGraphicsContext::ESolidPen); aGc.SetBrushStyle(CGraphicsContext::ENullBrush); } retVal = !blitFailed; return retVal; } } if (!aContext->IsCompatibleWithType(EAknsControlContextTypeFrame)) { // special handling for frames drawParam|=KAknsDrawParamNoClearUnderImage; originalParam|=KAknsDrawParamNoClearUnderImage; } TAknsBackground* nextLayout = bgLayout->iNext; while( nextLayout && ((drawParam & KAknsDrawParamLimitToFirstLevel) == 0) ) { imgData = RetrieveKnownBackgroundImage( aInstance, nextLayout->iImageID ); if (imgData && imgData->ParentIID() != KAknsIIDNone) { TAknsItemID parentiid = imgData->ParentIID(); TRect parentDrawRect = imgData->DrawRect(); imgData = RetrieveKnownBackgroundImage( aInstance, parentiid ); if (imgData) { imgData->SetDrawRect(parentDrawRect); drawParam |= KAknsDrawParamChained ; } } else { drawParam=originalParam; } if( imgData ) { blitAttempted = ETrue; blit = BlitAndClear( aInstance, aGc, drawRect, imgData, nextLayout->iImageID, nextLayout, paDelta, drawParam ); if ( !blit ) { blitFailed = ETrue; } } nextLayout = nextLayout->iNext; } } if (!(aDrawParam & KAknsDrawParamPrepareOnly)) { aGc.SetPenStyle(CGraphicsContext::ESolidPen); aGc.SetBrushStyle(CGraphicsContext::ENullBrush); } // If Blit failed, or was not even attempted => return EFalse if ( blitFailed ) { retVal = EFalse; } else if ( !retVal ) { retVal = blitAttempted; } return retVal; }