uigraphics/AknIcon/src/akniconconfig.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Implementation of class AknIconConfig.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "akniconconfig.h"
       
    22 #include "AknIconSrvDef.h"
       
    23 #include "AknIconSrvTlsData.h"
       
    24 #include "AknIconSrvClient.h"
       
    25 
       
    26 #include <fbs.h>
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // AknIconConfig::PreferredDisplayMode
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 EXPORT_C void AknIconConfig::PreferredDisplayMode(TPreferredDisplayMode& aMode, const TImageType aType, const TUid /*aUid*/)
       
    33     {
       
    34     CAknIconSrvTlsData* data = static_cast<CAknIconSrvTlsData*>( Dll::Tls() );
       
    35     switch (aType)
       
    36         {
       
    37         case EImageTypeIcon:
       
    38             {
       
    39             aMode.iBitmapMode = data->iInitData.iIconMode;
       
    40             aMode.iMaskMode = data->iInitData.iIconMaskMode;
       
    41             break;
       
    42             }
       
    43         case EImageTypePhoto:
       
    44             {
       
    45             aMode.iBitmapMode = data->iInitData.iPhotoMode;
       
    46             aMode.iMaskMode = ENone;
       
    47             break;
       
    48             }
       
    49         case EImageTypeVideo:
       
    50             {
       
    51             aMode.iBitmapMode = data->iInitData.iVideoMode;
       
    52             aMode.iMaskMode = ENone;
       
    53             break;
       
    54             }
       
    55         case EImageTypeOffscreen:
       
    56             {
       
    57             aMode.iBitmapMode = data->iInitData.iOffscreenMode;
       
    58             aMode.iMaskMode = data->iInitData.iOffscreenMaskMode;
       
    59             break;
       
    60             }
       
    61         default:
       
    62             {
       
    63             aMode.iBitmapMode = EColor64K;
       
    64             aMode.iMaskMode = EGray256;
       
    65             break;
       
    66             }
       
    67         }
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // AknIconConfig::CompressIfPreferred
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 EXPORT_C void AknIconConfig::CompressIfPreferred(CFbsBitmap* aBitmap, const TUid aUid)
       
    75     {
       
    76     CompressIfPreferred(aBitmap, NULL, aUid);
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // AknIconConfig::CompressIfPreferred
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 EXPORT_C void AknIconConfig::CompressIfPreferred(CFbsBitmap* aBitmap, CFbsBitmap* aMask, const TUid aUid)
       
    84     {
       
    85     CAknIconSrvTlsData* data = static_cast<CAknIconSrvTlsData*>( Dll::Tls() );
       
    86     CompressIfPreferred(aBitmap, aMask, data->iInitData.iCompression, aUid);
       
    87     }
       
    88     
       
    89 // -----------------------------------------------------------------------------
       
    90 // AknIconConfig::CompressIfPreferred
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void AknIconConfig::CompressIfPreferred(CFbsBitmap* aBitmap, CFbsBitmap* aMask, const TInt aValue, const TUid /*aUid*/)
       
    94     {
       
    95     TBool compression = EFalse;
       
    96     TBitmapfileCompressionScheme compressionValue;
       
    97     switch (aValue)
       
    98         {
       
    99         case 0:
       
   100             break;
       
   101         case 1:
       
   102             {
       
   103             compression = ETrue;
       
   104             compressionValue = ERLECompression;
       
   105             break;
       
   106             }
       
   107         case 2:
       
   108             {
       
   109             compression = ETrue;
       
   110             compressionValue = EPaletteCompression;
       
   111             break;
       
   112             }
       
   113         default:
       
   114             break;
       
   115         }
       
   116         
       
   117     if (compression)        
       
   118         {
       
   119         if (aBitmap)
       
   120             {
       
   121             aBitmap->CompressInBackground(compressionValue);
       
   122             }
       
   123         if (aMask)
       
   124             {
       
   125             aMask->CompressInBackground(compressionValue);
       
   126             }
       
   127         }
       
   128     }
       
   129     
       
   130     
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // AknIconConfig::EnableAknIconSrvCache
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C TInt AknIconConfig::EnableAknIconSrvCache(TBool aEnable)
       
   137 	{
       
   138     RAknIconSrvClient* client = RAknIconSrvClient::GetSession();
       
   139     return client->EnableCache(aEnable);
       
   140 	}