skins/AknSkins/alinc/AknsAlAnimatorBmp.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:  Animates effect queues.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef AKNSALANIMATORBMP_H
       
    20 #define AKNSALANIMATORBMP_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <gdi.h>
       
    24 #include <hwrmlight.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class MAknsAlTimingModel;
       
    28 class CAknsAlEffectContext;
       
    29 class CAknsAlEffectParamContainer;
       
    30 class CAknsAlAnimationValueContainer;
       
    31 class CAknsAlAnimationCommand;
       
    32 class CAknsAlSizeBoundParam;
       
    33 class CAknsAnimationItemData;
       
    34 class TAknsItemID;
       
    35 class MAknsEffectAnimObserver;
       
    36 class RAknsSrvSession;
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // Minimum convoluteable bitmap size is 3x3
       
    41 const TInt KAknsAlAnimMinimumWidth  = 3;
       
    42 const TInt KAknsAlAnimMinimumHeight = 3;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 /**
       
    46 * AnimatorBmp animates RL effect filter queues by allowing time bound
       
    47 * parametrization with timing models and animation values. AnimatorBmp
       
    48 * implements the next state machine:
       
    49 *
       
    50 * Starting |          | Resulting
       
    51 *  state   | Command  |  state
       
    52 * -------------------------------
       
    53 * Stopped    Start      Running
       
    54 *            Stop       Stopped
       
    55 *            Pause      Stopped
       
    56 *            Continue   Stopped
       
    57 *
       
    58 * Running    Start      Running
       
    59 *            Stop       Stopped
       
    60 *            Pause      Paused
       
    61 *            Continue   Running
       
    62 *
       
    63 * Paused     Start      Running
       
    64 *            Stop       Stopped
       
    65 *            Pause      Paused
       
    66 *            Continue   Running
       
    67 *
       
    68 * Finished   Start      Running
       
    69 *            Stop       Stopped
       
    70 *            Pause      Finished
       
    71 *            Continue   Finished
       
    72 *
       
    73 * @since 3.0
       
    74 */
       
    75 NONSHARABLE_CLASS( CAknsAlAnimatorBmp ): public CBase, public MHWRMLightObserver
       
    76     {
       
    77     protected: // Protected construction
       
    78         CAknsAlAnimatorBmp( MAknsEffectAnimObserver* aObserver );
       
    79         void ConstructL();
       
    80 
       
    81     public: // Public construction/destruction
       
    82 
       
    83         /**
       
    84         * Deleting the animator will stop running animation.
       
    85         */
       
    86         virtual ~CAknsAlAnimatorBmp();
       
    87 
       
    88         static CAknsAlAnimatorBmp* NewL( MAknsEffectAnimObserver* aObserver );
       
    89 
       
    90         /**
       
    91         * Constructs the animation from skin. The animation is not
       
    92         * automatically updated during a skin change. A newly constructed
       
    93         * animation is in stopped state.
       
    94         *
       
    95         * @param aItemID Animation bound to this id will be queried from the
       
    96         *                Skin.
       
    97         *
       
    98         * @return ETrue if the animation was found and succesfully constructed.
       
    99         *   EFalse if the animation was not found.
       
   100         */
       
   101         TBool ConstructFromSkinL( const TAknsItemID& aItemID );
       
   102 
       
   103         /**
       
   104         * Constructs animation directly from item data. This allows bypassing
       
   105         * skin data and feeding test cases directly to animation. This method
       
   106         * exists only for testing purposes.
       
   107         */
       
   108         TBool ConstructFromItemL( const CAknsAnimationItemData& aData,
       
   109                                   RAknsSrvSession* aSession);
       
   110 
       
   111     public:
       
   112 
       
   113         /**
       
   114         * Removes all layers and creates the input layer if it is required.
       
   115         * @param aLayerSize New layer size
       
   116         * @param aRgbMode   New RGB layer mode
       
   117         */
       
   118         void BeginConfigLayersL( const TSize& aLayerSize,
       
   119                                  TDisplayMode aRgbMode );
       
   120         /**
       
   121         * Updates the animation once so that output layer is available for
       
   122         * drawing immediately after this method.
       
   123         */
       
   124         void EndConfigLayersL( TBool aAboutToStart );
       
   125 
       
   126         TInt StartAnimation();
       
   127         TInt StopAnimation();
       
   128         TInt PauseAnimation();
       
   129         TInt ContinueAnimation();
       
   130 
       
   131         TInt State() const;
       
   132 
       
   133         CFbsBitmap* OutputRgb() const;
       
   134         CFbsBitmap* OutputAlpha() const;
       
   135         CFbsBitGc* InputRgbGc() const;
       
   136         CFbsBitGc* InputAlphaGc() const;
       
   137 
       
   138         TInt UpdateOutput();
       
   139 
       
   140         void SetIdling( TInt aIntervalMs );
       
   141         TBool IsIdling() const;
       
   142 
       
   143         TSize LayerSize() const;
       
   144         TBool NeedsInputLayer() const;
       
   145 
       
   146     private: // New methods
       
   147         void CancelIdling();
       
   148         TBool RenderError() const;
       
   149 
       
   150         /// Does not change iState
       
   151         void StartAnimationL( TBool aReset, TBool aStartTimer );
       
   152         /// Does not change iState
       
   153         void StopAndRelease( TBool aReleaseInputLayers, TBool aReleasePlugins );
       
   154         void Tick();
       
   155         TInt Render( TBool aNotify );
       
   156         void PreprocessL();
       
   157         TInt ApplyCommands( RPointerArray<CAknsAlAnimationCommand>& aArray,
       
   158                             TBool aApplyNamedReferences ) const;
       
   159 
       
   160         MAknsAlTimingModel* FindTimingModelById( TInt aId ) const;
       
   161         CAknsAlAnimationValueContainer* FindContainerById( TInt aId ) const;
       
   162 
       
   163         void CreateTimingModelsL( const CAknsAnimationItemData& aSkinData );
       
   164         void CreateAnimationValueContainersL( const CAknsAnimationItemData& aSkinData );
       
   165         void CreatePreprocessCommandsL( const CAknsAnimationItemData& aSkinData );
       
   166         void CreateAnimationCommandsL( const CAknsAnimationItemData& aSkinData );
       
   167         void CreateSizeBoundParamsL( const CAknsAnimationItemData& aSkinData );
       
   168 
       
   169         static TInt TimerTimeoutCallback( TAny *aPtr );
       
   170 
       
   171         // From MHWRMLightObserver.
       
   172         // Used to pause animation when lights go out, and to resume
       
   173         // when lights are active again.
       
   174         void LightStatusChanged( TInt aTarget, CHWRMLight::TLightStatus aStatus );
       
   175 
       
   176     private: // Data
       
   177 
       
   178         TInt iState;
       
   179         // Set if rendering plugins fails
       
   180         TInt iRenderError;
       
   181         TBool iSizeKnown;
       
   182 
       
   183         TBool iIdling;
       
   184         TInt iIdlingInterval;
       
   185 
       
   186         TInt iLastFrameTicks;
       
   187         TInt iMsPerTick; // Milliseconds per tick, queried from HAL
       
   188         TInt iMinimumInterval;
       
   189 
       
   190         // Animation's layer configuration
       
   191         TInt iInputLayerMode;
       
   192         TInt iInputLayerIndex;
       
   193         TInt iOutputLayerMode;
       
   194         TInt iOutputLayerIndex;
       
   195 
       
   196         CPeriodic* iTimer;
       
   197         CAknsAlEffectContext* iContext;
       
   198 
       
   199         RPointerArray<MAknsAlTimingModel> iTimingModels;
       
   200         RPointerArray<CAknsAlAnimationValueContainer> iValueContainers;
       
   201         RPointerArray<CAknsAlAnimationCommand> iPreprocessCommands;
       
   202         RPointerArray<CAknsAlAnimationCommand> iAnimationCommands;
       
   203         RPointerArray<CAknsAlSizeBoundParam> iSizeBoundParams;
       
   204 
       
   205         MAknsEffectAnimObserver* iObserver;
       
   206 
       
   207         TInt iPreprocessInputLayers;
       
   208 
       
   209         // Light client.
       
   210         // Own.
       
   211         CHWRMLight* iLightsClient;
       
   212 
       
   213     };
       
   214 
       
   215 #endif // AKNSALANIMATORBMP_H
       
   216 
       
   217 // End of File