skins/AknSkins/src/AknsRendererWrapper.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     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:  Wrapper class for access to scalable item renderer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "AknsCppPreface.h"
       
    21 
       
    22 #include <AknsRendererWrapper.h>
       
    23 
       
    24 #include "AknsScalabilityUtils.h"
       
    25 #include "AknsRlRenderer.h"
       
    26 #include "AknsDebug.h"
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // AknsRendererWrapper::RenderScalableItemL
       
    32 // (commented in the header).
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 EXPORT_C void AknsRendererWrapper::RenderScalableItemL(
       
    36     MAknsSkinInstance* aSkin, const TAknsItemID& aIID, CFbsBitmap*& aOutRGB,
       
    37     CFbsBitmap*& aOutAlpha, const TRect& aRect,
       
    38     const CFbsBitmap* aInRGB, const CFbsBitmap* aInAlpha )
       
    39     {
       
    40     if( !aSkin ) User::Leave( KErrArgument );
       
    41 
       
    42     CAknsAppSkinInstance* appSkin = static_cast<CAknsAppSkinInstance*>(aSkin);
       
    43 
       
    44     TAknsItemID realIID =
       
    45         AknsScalabilityUtils::ConcreteEffectQueue( appSkin, aIID );
       
    46     if( realIID == KAknsIIDNone )
       
    47         {
       
    48         // No such item
       
    49         User::Leave( KErrNotFound );
       
    50         }
       
    51 
       
    52     CAknsEffectQueueItemData* queue = static_cast<CAknsEffectQueueItemData*>(
       
    53         appSkin->GetCachedItemData( realIID, EAknsITEffectQueue ) );
       
    54     if( !queue )
       
    55         {
       
    56         // No such item
       
    57         User::Leave( KErrNotFound );
       
    58         }
       
    59 
       
    60     MAknsRlRenderer* renderer = appSkin->DefaultRenderer();
       
    61 
       
    62     MAknsRlCommandIterator* commands =
       
    63         queue->CreateCommandIteratorL();
       
    64     CleanupStack::PushL( TCleanupItem(
       
    65         MAknsRlCommandIterator::CleanupOperation, commands ) ); // (1)
       
    66     TInt inputLayer = queue->InputLayer();
       
    67     TInt outputLayer = queue->OutputLayer();
       
    68 
       
    69     // Bitmap and mask being created, no leaves allowed
       
    70     TInt rendererErr = KErrNone;
       
    71     CFbsBitmap* bitmap = NULL;
       
    72     CFbsBitmap* alpha = NULL;
       
    73     if( aInRGB || aInAlpha )
       
    74         {
       
    75         rendererErr = renderer->RenderItemWithBackground(
       
    76             bitmap, alpha, outputLayer, commands, aRect.Size(),
       
    77             aInRGB, aInAlpha, aRect, inputLayer );
       
    78         }
       
    79     else
       
    80         {
       
    81         rendererErr = renderer->RenderItem(
       
    82             bitmap, alpha, outputLayer, commands, aRect.Size() );
       
    83         }
       
    84     if( rendererErr )
       
    85         {
       
    86         // Leave is safe (bitmaps not created)
       
    87         User::Leave( rendererErr );
       
    88         }
       
    89     CleanupStack::PopAndDestroy(); // commands (0)
       
    90 
       
    91     // Drop alpha, if RGB only
       
    92     if( queue->OutputLayerMode() == KAknsRlLayerRGBOnly )
       
    93         {
       
    94         delete alpha;
       
    95         alpha = NULL;
       
    96         }
       
    97 
       
    98     // Ownership transfer
       
    99     aOutRGB = bitmap;
       
   100     aOutAlpha = alpha;
       
   101     }
       
   102 
       
   103 //  End of File
       
   104