|
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 #ifndef HUIFXEFFECTCACHE_H_ |
|
19 #define HUIFXEFFECTCACHE_H_ |
|
20 |
|
21 #include <e32cmn.h> |
|
22 #include <e32base.h> |
|
23 #include <e32hashtab.h> |
|
24 #include "HuiFxEffectParser.h" |
|
25 #include "huieffectable.h" |
|
26 |
|
27 class MHuiFxParsingEndedObserver; |
|
28 class MAlfGfxEffectObserver; |
|
29 |
|
30 |
|
31 class MHuiFxEffectCacheNode |
|
32 { |
|
33 public: |
|
34 virtual ~MHuiFxEffectCacheNode() { } |
|
35 virtual TPtrC Id()=0; // how to regognize this instance |
|
36 virtual MHuiFxEffectCacheNode *CloneL()=0; // from this instance to cache |
|
37 virtual void LightOperationL(MHuiFxEffectCacheNode *aCached)=0; // from cache to this instance |
|
38 virtual void HeavyOperationL(MHuiFxParsingEndedObserver *aObserver, TInt aIndex)=0; // from nothing to this instance |
|
39 virtual TInt Ref(TInt aCount)=0; // increase count by aCount and return count. |
|
40 virtual void ParsingEndedBefore()=0; |
|
41 virtual void ParsingEndedAfter(MHuiFxEffectCacheNode *aCached)=0; |
|
42 virtual TBool FxmlUsesInput1()=0; |
|
43 }; |
|
44 |
|
45 class CHuiFxEffectCache : public CBase, public MHuiFxParsingEndedObserver |
|
46 { |
|
47 public: |
|
48 IMPORT_C static CHuiFxEffectCache* NewL(); |
|
49 void CreateL(MHuiFxEffectCacheNode *aNode); // moves ownership |
|
50 IMPORT_C void FindOrCreateL(MHuiFxEffectCacheNode *aNode); // moves ownership |
|
51 MHuiFxEffectCacheNode *FindDup(const TDesC &aId); |
|
52 IMPORT_C void UnUse(MHuiFxEffectCacheNode *aNode); |
|
53 IMPORT_C ~CHuiFxEffectCache(); |
|
54 void ParsingEnded(TInt aHandle); |
|
55 MHuiFxEffectCacheNode *FindCached(const TDesC &aId); |
|
56 TBool FxmlUsesInput1(const TDesC &aFileName); |
|
57 private: |
|
58 struct IDNode |
|
59 { |
|
60 TInt iId; |
|
61 MHuiFxEffectCacheNode *iNode; |
|
62 }; |
|
63 |
|
64 MHuiFxEffectCacheNode *Find(MHuiFxEffectCacheNode *aNode); |
|
65 static bool Compare(MHuiFxEffectCacheNode *aNode1, MHuiFxEffectCacheNode *aNode2); |
|
66 void Remove(RPointerArray<MHuiFxEffectCacheNode> &aEffects, MHuiFxEffectCacheNode *aNode); |
|
67 void Remove(RHashMap<TInt, MHuiFxEffectCacheNode*> &aMap, MHuiFxEffectCacheNode *aNode); |
|
68 void Remove(RArray<IDNode> &aMap, MHuiFxEffectCacheNode *aNode); |
|
69 TInt FindById(TInt aId); |
|
70 TInt UniqueId(); |
|
71 private: |
|
72 RPointerArray<MHuiFxEffectCacheNode> iCachedEffects; |
|
73 //RPointerArray<MHuiFxEffectCacheNode> iDuplicateEffects; // array can have null pointers in it |
|
74 //RHashMap<TInt, MHuiFxEffectCacheNode*> iDuplicateEffects; |
|
75 RArray<IDNode> iDuplicateEffects; |
|
76 TInt iUniqueId; |
|
77 }; |
|
78 |
|
79 class CHuiFxEffect; |
|
80 class TRect; |
|
81 class CHuiVisual; |
|
82 class CHuiFxEngine; |
|
83 |
|
84 // This class has all dependencies to outside objects. |
|
85 class CHuiFxEffectCacheEffectNode : public CBase, public MHuiFxEffectCacheNode |
|
86 { |
|
87 public: |
|
88 IMPORT_C CHuiFxEffectCacheEffectNode(const TDesC &aFileName, CHuiFxEffect *&aEffect, MHuiEffectable *aVisual, TRect *extRect, CHuiFxEngine *aEngine) |
|
89 : iFileName(aFileName.AllocL()), iEffect(aEffect), iVisual(aVisual), iExtRect(extRect), iEffectCached(0), iEngine(aEngine), iRefCount(0), iParser(0) { } |
|
90 IMPORT_C ~CHuiFxEffectCacheEffectNode(); |
|
91 void SetEffectEndObserver( MAlfGfxEffectObserver* aEffectEndObserver, TInt aHandle ); |
|
92 void SetEffectFlags( TInt aFlags ); |
|
93 void SetEffectGroup( TInt aGroup); |
|
94 private: |
|
95 CHuiFxEffectCacheEffectNode(const TDesC &aFileName, CHuiFxEffect *aEffect) : iFileName(aFileName.AllocL()), iEffect(iEffectCached), iVisual(0), iExtRect(0), iEffectCached(aEffect), iRefCount(0), iParser(0), iEffectEndObserver(0), iHandle(0) { } |
|
96 public: // from MHuiFxEffectCacheNode |
|
97 TPtrC Id(); |
|
98 MHuiFxEffectCacheNode *CloneL(); |
|
99 void LightOperationL(MHuiFxEffectCacheNode *aCached); |
|
100 void HeavyOperationL(MHuiFxParsingEndedObserver *aObserver, TInt aIndex); |
|
101 TInt Ref(TInt aCount); |
|
102 void ParsingEndedBefore(); |
|
103 void ParsingEndedAfter(MHuiFxEffectCacheNode *aCached); |
|
104 TBool FxmlUsesInput1(); |
|
105 |
|
106 private: |
|
107 const TDesC *iFileName; |
|
108 CHuiFxEffect *iEffect; |
|
109 MHuiEffectable *iVisual; |
|
110 TRect *iExtRect; |
|
111 CHuiFxEffect *iEffectCached; |
|
112 CHuiFxEngine *iEngine; |
|
113 TInt iRefCount; |
|
114 CHuiFxEffectParser *iParser; |
|
115 MAlfGfxEffectObserver* iEffectEndObserver; |
|
116 TInt iHandle; |
|
117 TInt iFlags; |
|
118 TInt iGroup; |
|
119 }; |
|
120 |
|
121 |
|
122 #endif |