skins/AknSkins/rlplugininc/AknsRlEffectPluginAlphaBlend.h
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:  Alpha Blend provides functionality to combine masked images with Porter-Duff
       
    15 *                operations.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef AKNSRLEFFECTPLUGINALPHABLEND_H
       
    20 #define AKNSRLEFFECTPLUGINALPHABLEND_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include "AknsRlEffectPlugin.h"
       
    24 #include <AknsRlEffect.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // Effect plugin UID
       
    29 const TInt KAknsRlEffectPluginAlphaBlendUID = 0x10204ADD;
       
    30 
       
    31 // Constants for parameter names
       
    32 _LIT( KAknsRlEffectAlphaBlendARed,   "ar" );
       
    33 _LIT( KAknsRlEffectAlphaBlendAGreen, "ag" );
       
    34 _LIT( KAknsRlEffectAlphaBlendABlue,  "ab" );
       
    35 
       
    36 _LIT( KAknsRlEffectAlphaBlendBRed,   "br" );
       
    37 _LIT( KAknsRlEffectAlphaBlendBGreen, "bg" );
       
    38 _LIT( KAknsRlEffectAlphaBlendBBlue,  "bb" );
       
    39 
       
    40 _LIT( KAknsRlEffectAlphaBlendAMask,  "am" );
       
    41 _LIT( KAknsRlEffectAlphaBlendBMask,  "bm" );
       
    42 
       
    43 _LIT( KAknsRlEffectAlphaBlendMode,   "m" );
       
    44 
       
    45 // FORWARD DECLARATIONS
       
    46 class CAknsRlScanlines;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 /**
       
    51 * Alpha Blend provides functionality to combine masked images with Porter-Duff
       
    52 * operations. The used blend modes follow reference: T. Porter and T. Duff,
       
    53 * "Compositing Digital Images", SIGGRAPH 84, 253-259.
       
    54 *
       
    55 * Blending modes have A, B and Clear been dropped because they are pointless.
       
    56 * Also the plus mode has not been implemented.
       
    57 *
       
    58 * @since 2.8
       
    59 */
       
    60 NONSHARABLE_CLASS(CAknsRlEffectPluginAlphaBlend):
       
    61     public CAknsRlEffectPlugin,
       
    62     public MAknsRlEffect
       
    63     {
       
    64     public:
       
    65         /**
       
    66         * Flags for marking set parameters, internally used.
       
    67         */
       
    68         enum TConstantFlag
       
    69             {
       
    70             EConstantAColor = 0x01,
       
    71             EConstantBColor = 0x02,
       
    72             EConstantAMask  = 0x04,
       
    73             EConstantBMask  = 0x08
       
    74             };
       
    75 
       
    76     public: // Constructors and destructor
       
    77 
       
    78         /**
       
    79         * Default constructor.
       
    80         *
       
    81         * @since 2.8
       
    82         */
       
    83         CAknsRlEffectPluginAlphaBlend();
       
    84 
       
    85         /**
       
    86         * Destructor.
       
    87         *
       
    88         * @since 2.8
       
    89         */
       
    90         virtual ~CAknsRlEffectPluginAlphaBlend();
       
    91 
       
    92     public: // Functions from base classes
       
    93 
       
    94         TUid EffectUid() const;
       
    95         MAknsRlEffect* Effect( const TInt aInterface );
       
    96 
       
    97     public: // Implementation of MAknsRlEffect
       
    98 
       
    99         void InitializeL();
       
   100         void Release();
       
   101 
       
   102         void ActivateL( MAknsRlEffectContext* aContext );
       
   103         void Deactivate();
       
   104 
       
   105         /**
       
   106         * Accepted named parameters:
       
   107         *
       
   108         * Constant color A:
       
   109         * - "ar", integer, channel value for red, truncated to range [0, 255]
       
   110         * - "ag", integer, channel value for green, truncated to range [0, 255]
       
   111         * - "ab", integer, channel value for blue, truncated to range [0, 255]
       
   112         * Constant color B:
       
   113         * - "br", integer, channel value for red, truncated to range [0, 255]
       
   114         * - "bg", integer, channel value for green, truncated to range [0, 255]
       
   115         * - "bb", integer, channel value for blue, truncated to range [0, 255]
       
   116         * Constant mask A:
       
   117         * - "am", integer, 8-bit shade, truncated to range [0, 255]
       
   118         * Constant mask B:
       
   119         * - "bm", integer, 8-bit shade, truncated to range [0, 255]
       
   120         * Blend mode:
       
   121         * - "m", integer (enumeration), one of the Porter-Duff blend modes
       
   122         *
       
   123         * Constant color A and B:
       
   124         * If any of the A color channel values is set the processing will use a
       
   125         * constant color for A. The same goes with B. If the processed bitmaps
       
   126         * are grayscale the constant colors are converted to grayscale shade.
       
   127         *
       
   128         * The next input/output combinations are supported:
       
   129         *
       
   130         *      A | B | T    A | B | T     A | B | T
       
   131         *      ---------    ----------    ----------
       
   132         *      8 | 8 | 8    16| 16| 16    32| 32| 32
       
   133         *      8 | C | 8    16| C | 16    32| C | 32
       
   134         *      C | 8 | 8    C | 16| 16    C | 32| 32
       
   135         *      C | C | 8    C | C | 16    C | C | 32
       
   136         *
       
   137         *  A = input layer A, B = input layer B, T = target layer
       
   138         *  8 = 8-bit grayscale bitmap (EGray256)
       
   139         * 16 = 16-bit RGB bitmap (EColor64K)
       
   140         * 32 = 24-bit unpacked RGB bitmap (EColor16MU)
       
   141         *  C = 24-bit constant color (converted to 8-bit gray if
       
   142         *      needed)
       
   143         *
       
   144         * Constant mask A and B:
       
   145         * If constant mask A is set the processing will use constant mask for
       
   146         * A. The same goes for mask B. The next mask combinations are
       
   147         * supported:
       
   148         *
       
   149         *      MA|MB
       
   150         *      -----
       
   151         *      8 | 8       MA = input mask A, MB = input mask B
       
   152         *      8 | C       8 = 8-bit grayscale bitmap (EGray256)
       
   153         *      C | 8       C = 8-bit constant shade
       
   154         *      C | C
       
   155         *
       
   156         * Blend mode:
       
   157         * Defines the used alpha blend operation. Possible values are defined
       
   158         * in enumeration TAknsRlAlphaBlendMode. Using any other value will
       
   159         * cause leave.
       
   160         *
       
   161         * Default values:
       
   162         * - "ar" = 255
       
   163         * - "ag" = 255
       
   164         * - "ab" = 255
       
   165         * - "br" = 255
       
   166         * - "bg" = 255
       
   167         * - "bb" = 255
       
   168         * - "am" = 255
       
   169         * - "bm" = 255
       
   170         * - "m"  = EAknsRlAlphaBlendAOverB
       
   171         *
       
   172         * Note that constant color and constant mask values are not used by
       
   173         * default. You must pass at least one value per constant (yes, a
       
   174         * default value for constant mask is actually quite pointless).
       
   175         */
       
   176         void SetParametersL( MAknsRlParameterIterator& aParameters );
       
   177 
       
   178         /**
       
   179         * Supported modes:
       
   180         * - EColor64K -> EColor64K
       
   181         * - EColor16MU -> EColor16MU
       
   182         * - EGray256 -> EGray256
       
   183         */
       
   184         void GetCapabilities( TAknsRlEffectCaps& aCaps );
       
   185 
       
   186         /**
       
   187         * Defining constants allows dropping layers. If color constant and mask
       
   188         * constant are both defined the corresponding layer is never queried.
       
   189         * In other cases the layer is queried but defining a constant allows
       
   190         * omitting the corresponding bitmap.
       
   191         *
       
   192         * The target layer may or may not have mask bitmap. If target mask
       
   193         * bitmap exists it is filled with white.
       
   194         */
       
   195         TInt Render( const TAknsRlRenderOpParam& aParam );
       
   196 
       
   197         void DoRenderL( const TAknsRlRenderOpParam& aParam );
       
   198 
       
   199     private:
       
   200 
       
   201         MAknsRlEffectContext* iContext;
       
   202 
       
   203         TUint8 iBlendMode;
       
   204 
       
   205         /**
       
   206         * Any constants set during the parameter iteration are flagged here
       
   207         * using TConstantFlags.
       
   208         */
       
   209         TUint8 iFlags;
       
   210 
       
   211         TUint8 iARed;
       
   212         TUint8 iAGreen;
       
   213         TUint8 iABlue;
       
   214 
       
   215         TUint8 iBRed;
       
   216         TUint8 iBGreen;
       
   217         TUint8 iBBlue;
       
   218 
       
   219         TUint8 iAMask;
       
   220         TUint8 iBMask;
       
   221 
       
   222         // Cache for constant scanlines, reduces memory allocations for
       
   223         // constant scanlines during animations.
       
   224         CAknsRlScanlines* iScans;
       
   225     };
       
   226 
       
   227 #endif // AKNSRLEFFECTPLUGINALPHABLEND_H
       
   228 // End of File