uiacceltk/hitchcock/coretoolkit/inc/HuiFxEngine.h
changeset 0 15bf7259bb7c
child 3 d8a3531bc6b8
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef HUIFXENGINE_H_
       
    21 #define HUIFXENGINE_H_
       
    22 
       
    23 #include "HuiFxConstants.h"
       
    24 #include "HuiFxParameter.h"
       
    25 #include "huieffectable.h"
       
    26 #include <uiacceltk/huilowmemoryobserver.h>
       
    27 #include <e32std.h>
       
    28 
       
    29 
       
    30 #define HUIFX_RBCACHE_ENABLED
       
    31 #define HUIFX_EFFECTCACHE_ENABLED
       
    32 
       
    33 //FORWARD DECLARATIONS
       
    34 class CHuiFxRenderbuffer;
       
    35 class CHuiFxFilter;
       
    36 class CHuiFxEffect;
       
    37 class CHuiVisual;
       
    38 class CHuiFxEffectCache;
       
    39 class MAlfGfxEffectObserver;
       
    40 class CHuiGc;
       
    41 
       
    42 class CHuiFxEngine : public CBase, public MHuiLowMemoryObserver, public MHuiMemoryLevelObserver
       
    43     {
       
    44     // important constant! Affects memory fragmentation in backend too small 
       
    45     // number forces lots of acquires/releases resulting in fragmented memory 
       
    46     // and finally panic.
       
    47 
       
    48     // CACHE_SIZE set to 20 to avoid buffer creation at worst case scenario (fading).
       
    49     // Emulator cannot currently handle that much (out of memory) 
       
    50 #ifdef __WINS__ 
       
    51     static const TInt CACHE_SIZE = 1;
       
    52 #else
       
    53     static const TInt CACHE_SIZE = 20;
       
    54 #endif    
       
    55     friend class CHuiFxEffect;
       
    56 protected:
       
    57     IMPORT_C void ConstructL(THuiFxEngineType aEngineType);
       
    58 public:
       
    59     IMPORT_C virtual ~CHuiFxEngine();
       
    60     // Engine management
       
    61     IMPORT_C virtual void Release();
       
    62     IMPORT_C virtual void RestoreL();
       
    63 
       
    64     // Render buffer management
       
    65     IMPORT_C virtual CHuiFxRenderbuffer* AcquireRenderbuffer(const TSize& aDesiredSize);
       
    66     CHuiFxRenderbuffer* AcquireRenderbuffer(const TSize& aDesiredSize, TBool aAlllowLarger);
       
    67 
       
    68     IMPORT_C virtual void ReleaseRenderbuffer(CHuiFxRenderbuffer* aBuffer);
       
    69     virtual CHuiFxRenderbuffer* DefaultRenderbuffer() = 0;
       
    70 
       
    71     // Filter construction
       
    72     virtual CHuiFxFilter* CreateFilterL(THuiFxFilterType aType) = 0;
       
    73 
       
    74     // Composition
       
    75     // TODO: Coordinates
       
    76     virtual void Composite(CHuiFxRenderbuffer& aTarget, CHuiFxRenderbuffer& aSource,
       
    77                                     const TRect& aTargetRect, const TRect& aSourceRect,
       
    78                                     THuiFxBlendingMode aMode, TInt aAlpha) = 0;
       
    79 
       
    80     // Composition variant to compose directly to the screen. Uses always over blending with constant alpha.
       
    81     IMPORT_C virtual void Composite(CHuiGc& aGc, CHuiFxRenderbuffer& aSource, const TPoint& aTargetPoint, TBool aOpaque, TInt aAlpha);
       
    82     
       
    83     // Effect construction
       
    84     // TODO: Other needed effect parameters?
       
    85     // Demarcation rectangele added.
       
    86     
       
    87     // Effect end observer and handle added
       
    88     IMPORT_C void RegisterEffectL(const TDesC &aFileName);
       
    89     IMPORT_C void UnRegisterEffectL(const TDesC &aFileName);
       
    90     IMPORT_C void LoadEffectL(
       
    91         const TDesC& aFileName,
       
    92         CHuiFxEffect*& aEffect,
       
    93         MHuiEffectable* aVisual = 0,
       
    94         TRect* extRect = 0,
       
    95         MAlfGfxEffectObserver* aEffectEndObserver = 0,
       
    96         TInt aHandle = 0, 
       
    97         TInt aFlags = 0 );
       
    98     
       
    99     IMPORT_C void LoadGroupEffectL(
       
   100             const TDesC& aFileName,
       
   101             CHuiFxEffect*& aEffect,
       
   102             MHuiEffectable* aVisual = 0,
       
   103             TInt aGroupHandle = 0,
       
   104             TRect* extRect = 0,
       
   105             MAlfGfxEffectObserver* aEffectEndObserver = 0,
       
   106             TInt aHandle = 0,
       
   107             TInt aFlags = 0 );
       
   108     
       
   109     IMPORT_C TBool FxmlUsesInput1(const TDesC &aFileName);
       
   110 
       
   111     
       
   112     IMPORT_C void AdvanceTime(TReal32 aElapsedTime);
       
   113     
       
   114     IMPORT_C TReal32 GetReferenceValue(THuiFxReferencePoint aPoint);
       
   115     
       
   116     IMPORT_C THuiFxEngineType EngineType();
       
   117     
       
   118     //from MHuiLowMemoryObserver
       
   119     // deprecated
       
   120     IMPORT_C void EnableLowMemoryState(TBool aEnable);
       
   121     
       
   122     /*
       
   123 	 * BeginGroupEffect
       
   124 	 *
       
   125 	 * Begins new group. start collecting effects, that should be set to motion at the same 
       
   126 	 * time.
       
   127 	 */
       
   128 	IMPORT_C void BeginGroupEffect(TInt aGroup);
       
   129 
       
   130     
       
   131     IMPORT_C TInt ActiveGroupEffect();
       
   132     
       
   133     /*
       
   134 	 * StartGroupEffect
       
   135 	 *
       
   136 	 * Starts syncronously group of effects that have the same aGroup id. 
       
   137 	 */
       
   138     IMPORT_C void StartGroupEffect(TInt aGroup);
       
   139     
       
   140     TInt LowMemoryState();
       
   141     
       
   142     TBool HasActiveEffects() const;
       
   143     
       
   144     void ClearCache();
       
   145     
       
   146     void NotifyEffectEndObservers();
       
   147     
       
   148     IMPORT_C void SetMemoryLevel(THuiMemoryLevel aLevel);
       
   149     
       
   150 protected:
       
   151     IMPORT_C void AddEffectL(CHuiFxEffect* aEffect);
       
   152     IMPORT_C void RemoveEffect(CHuiFxEffect* aEffect);
       
   153     
       
   154     TRequestStatus   iParserStatus;
       
   155     TInt             iBuffersInUse;
       
   156     
       
   157 private:
       
   158     // Render buffer management --- native implementations
       
   159     virtual CHuiFxRenderbuffer* AcquireNativeRenderbuffer(const TSize& aDesiredSize) = 0;
       
   160     virtual void ReleaseNativeRenderbuffer(CHuiFxRenderbuffer* aBuffer) = 0;
       
   161 
       
   162     // Render buffer cache
       
   163 #ifdef HUIFX_RBCACHE_ENABLED
       
   164     CHuiFxRenderbuffer* LookupFreeRenderbuffer(const TSize& aDesiredSize, TBool aAlllowLarger);
       
   165     void InsertFreeRenderbuffer(CHuiFxRenderbuffer *aBuffer);
       
   166     inline TBool IsCacheEmpty() const;
       
   167     inline TBool IsCacheFull() const;
       
   168 
       
   169     // simple general renderbuffer cache
       
   170     TInt                iBuffersInCache;
       
   171     CHuiFxRenderbuffer* iBufferCache[CACHE_SIZE];
       
   172 #endif
       
   173     
       
   174 #ifdef HUIFX_PERF_COUNTERS
       
   175     // TODO! counters for performance evaluation?!
       
   176     TInt iMaxAcquiredBuffers;
       
   177     TInt iMaxFreeBuffers;
       
   178     TSize iMaxBufferSize;
       
   179     TInt iHit;
       
   180     TInt iMiss;
       
   181 #endif
       
   182 
       
   183     RPointerArray<CHuiFxEffect>  iActiveEffects;
       
   184     THuiFxEngineType             iType;
       
   185     TRect                        iExtRect;
       
   186     CHuiFxEffectCache *iCache;
       
   187     TInt iLowGraphicsMemoryMode;
       
   188     RArray<TInt> iActiveEffectGroups;
       
   189     };
       
   190 
       
   191 #endif /*HUIFXENGINE_H_*/