|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** @file |
|
17 @internalTechnology */ |
|
18 #include "MngPlayer.h" |
|
19 #include "MngPanic.h" |
|
20 #include "MngRenderer.h" |
|
21 |
|
22 #include "MngObjects.h" |
|
23 |
|
24 /*virtual*/ |
|
25 void CMngObject::Reset() |
|
26 { |
|
27 } |
|
28 |
|
29 /*virual*/ |
|
30 TBool CMngObject::IsSubFrame() const |
|
31 { |
|
32 return EFalse; |
|
33 } |
|
34 |
|
35 /*virual*/ |
|
36 TBool CMngObject::IsLayer() const |
|
37 { |
|
38 return EFalse; |
|
39 } |
|
40 |
|
41 /*virual*/ |
|
42 void CMngObject::OnAddToPlayerL(const CMngPlayer& /*aPlayer*/) |
|
43 { |
|
44 } |
|
45 |
|
46 /*virual*/ |
|
47 TBool CMngLayer::IsLayer() const |
|
48 { |
|
49 return ETrue; |
|
50 } |
|
51 |
|
52 /*static*/ |
|
53 CMngTermination* CMngTermination::NewL(TTermChunk*& aTermChunk, TBool aMngSubframesNoLoops) //Subframes with No Loops |
|
54 { |
|
55 TTermChunk* pChunk=aTermChunk; |
|
56 CleanupDeletePushL(pChunk); |
|
57 aTermChunk = NULL; |
|
58 CMngTermination* self=new (ELeave) CMngTermination(*pChunk, aMngSubframesNoLoops); //Subframes with No Loops |
|
59 CleanupStack::PopAndDestroy(pChunk); |
|
60 return self; |
|
61 } |
|
62 |
|
63 void CMngTermination::ExecuteL(CMngPlayer& aPlayer, TMngExecuteResult& aResult) |
|
64 { |
|
65 TMngTerminationAction Action=iPostIterationAction; |
|
66 |
|
67 //Subframes with No Loops |
|
68 if(iMngSubframesNoLoops) |
|
69 { |
|
70 iIterationCounter = 1; |
|
71 Action =EMngShowLastFrameIndef; |
|
72 } |
|
73 |
|
74 ASSERT(iIterationCounter > -1); |
|
75 iIterationCounter -= (iIterationCounter>0 && iIterationCounter!=KMngInfinity); |
|
76 aResult.iDelayInTicks = iDelay; |
|
77 if (iIterationCounter) |
|
78 { |
|
79 Action=iTerminationAction; |
|
80 } |
|
81 switch (Action) |
|
82 { |
|
83 case EMngShowLastFrameIndef: |
|
84 aResult.iCommand=ECmdTerminate; |
|
85 break; |
|
86 case EMngCeaseDisplAnything: |
|
87 aResult.iCommand=ECmdTerminateClearOutput; |
|
88 break; |
|
89 case EMngShowFirstFrmAfterTerm: |
|
90 aResult.iCommand=ECmdTerminateAfter1stFrame; |
|
91 aPlayer.SetTerminationFrameNum(1); |
|
92 break; |
|
93 case EMngRepeatImmidiately: |
|
94 aResult.iCommand=ECmdStartFromBeginning; |
|
95 break; |
|
96 default: |
|
97 User::Leave(KErrCorrupt); |
|
98 } |
|
99 } |
|
100 |
|
101 void CMngTermination::Reset() |
|
102 { |
|
103 iIterationCounter = iIterationMax; |
|
104 } |
|
105 |
|
106 /*static*/ |
|
107 CMngObject* CMngKeyFrame::NewL(TMngChunk*& aFramChunk) |
|
108 { |
|
109 CleanupDeletePushL(aFramChunk); |
|
110 TFramChunk* FrameChunk=static_cast<TFramChunk*>(aFramChunk); |
|
111 aFramChunk=NULL; |
|
112 CMngKeyFrame* self=new (ELeave) CMngKeyFrame(FrameChunk); |
|
113 CleanupStack::Pop(); |
|
114 return self; |
|
115 } |
|
116 |
|
117 inline |
|
118 CMngKeyFrame::CMngKeyFrame(TFramChunk* aFramChunk):iFramChunk(aFramChunk) |
|
119 { |
|
120 } |
|
121 |
|
122 CMngKeyFrame::~CMngKeyFrame() |
|
123 { |
|
124 delete iFramChunk; |
|
125 } |
|
126 |
|
127 void CMngKeyFrame::ExecuteL(CMngPlayer& aPlayer, TMngExecuteResult& /*aResult*/) |
|
128 { |
|
129 aPlayer.SetFramingMode(iFramChunk->iFramingMode); |
|
130 if (EMngFramDoNotChange != iFramChunk->iChangeInterFrmDelay) |
|
131 { |
|
132 aPlayer.SetInterFrameDelay(iFramChunk->iChangeInterFrmDelay, iFramChunk->iInterframeDelay); |
|
133 } |
|
134 |
|
135 if (EMngFramDoNotChange != iFramChunk->iChangeClippingBoundaries) |
|
136 { |
|
137 aPlayer.SetLayerClipping(iFramChunk->iChangeClippingBoundaries, |
|
138 TRect(iFramChunk->iLeftLayerClippingB, iFramChunk->iTopLayerClippingB, |
|
139 iFramChunk->iRightLayerClippingB, iFramChunk->iBottomLayerClippingB), |
|
140 iFramChunk->iAddLayerClipping); |
|
141 } |
|
142 } |
|
143 |
|
144 TBool CMngKeyFrame::IsSubFrame() const |
|
145 { |
|
146 return ETrue; |
|
147 } |
|
148 |
|
149 /*static*/ |
|
150 CMngObject* CMngBackground::NewL(TMngChunk*& aBackChunk) |
|
151 { |
|
152 TBackChunk* BackChunk=static_cast<TBackChunk*>(aBackChunk); |
|
153 aBackChunk = NULL; |
|
154 CleanupDeletePushL(BackChunk); |
|
155 CMngBackground* self=new (ELeave) CMngBackground(*BackChunk); |
|
156 CleanupStack::PopAndDestroy(BackChunk); |
|
157 return self; |
|
158 } |
|
159 |
|
160 void CMngBackground::ExecuteL(CMngPlayer& aPlayer, TMngExecuteResult& /*aResult*/) |
|
161 { |
|
162 aPlayer.Renderer()->SetBackground(iBackgroundColour, (iBgMandatory&EMngTermBgColorMandatoryImgAdvisory) ); |
|
163 } |
|
164 |
|
165 /*static*/ |
|
166 CMngObject* CMngRawChunkHolder::NewL(TMngChunk*& aChunk) |
|
167 { |
|
168 TMngRawChunk* RawChunk=static_cast<TMngRawChunk*>(aChunk); |
|
169 aChunk = NULL; |
|
170 CleanupDeletePushL(RawChunk); |
|
171 CMngRawChunkHolder* self=new (ELeave) CMngRawChunkHolder(RawChunk); |
|
172 CleanupStack::Pop(RawChunk); |
|
173 return self; |
|
174 } |
|
175 |
|
176 void CMngRawChunkHolder::ExecuteL(CMngPlayer& aPlayer, TMngExecuteResult& /*aResult*/) |
|
177 { |
|
178 aPlayer.AddUniqueChunkProviderL(iChunk->iHeader.iChunkId, *this); |
|
179 } |
|
180 |
|
181 TInt CMngRawChunkHolder::GetChunkData(const TText8* aChunkId, const TUint8*& aDataPtr, TInt& aSizeInBites) |
|
182 { |
|
183 TInt res=KErrNone; |
|
184 if (iChunk->iHeader.iChunkId == TPtrC8(aChunkId, sizeof(TChunkId)) ) |
|
185 { |
|
186 aDataPtr = iChunk->Data(); |
|
187 aSizeInBites = iChunk->iHeader.iLength; |
|
188 } |
|
189 else |
|
190 { |
|
191 res = KErrNotFound; |
|
192 aSizeInBites = 0; |
|
193 aDataPtr = NULL; |
|
194 } |
|
195 return res; |
|
196 } |
|
197 |
|
198 CMngRawChunkHolder::~CMngRawChunkHolder() |
|
199 { |
|
200 delete iChunk; |
|
201 } |
|
202 |
|
203 /*static*/ |
|
204 CMngObject* CMngImageDefinition::NewL(TMngChunk*& aDefiChunk) |
|
205 { |
|
206 TDefiChunk* DefiChunk=static_cast<TDefiChunk*>(aDefiChunk); |
|
207 aDefiChunk = NULL; |
|
208 CleanupDeletePushL(DefiChunk); |
|
209 CMngImageDefinition* self = new (ELeave) CMngImageDefinition(*DefiChunk); |
|
210 CleanupStack::PopAndDestroy(DefiChunk); |
|
211 return self; |
|
212 } |
|
213 |
|
214 void CMngImageDefinition::ExecuteL(CMngPlayer& aPlayer, TMngExecuteResult& /*aResult*/) |
|
215 { |
|
216 CMngRenderer* Renderer = aPlayer.Renderer(); |
|
217 Renderer->SetOutputEnabled(!iDoNotShow); |
|
218 Renderer->SetImageOrigin(iOrigin); |
|
219 Renderer->SetImageClipRect(iClippingRect); |
|
220 } |
|
221 |
|
222 void CMngImageDefinition::OnAddToPlayerL(const CMngPlayer& aPlayer) |
|
223 { |
|
224 if (iClippingRect.iBr.iX==-1 && iClippingRect.iTl.iX==0) |
|
225 { |
|
226 iClippingRect.iBr.iX= 0; |
|
227 iClippingRect.iBr = aPlayer.FrameSize().AsPoint(); |
|
228 } |
|
229 } |
|
230 |
|
231 /*static*/ |
|
232 CMngObject* CMngLoopEntry::NewL(TMngChunk*& aLoopChunk) |
|
233 { |
|
234 TLoopChunk* LoopChunk=static_cast<TLoopChunk*>(aLoopChunk); |
|
235 aLoopChunk = NULL; |
|
236 CleanupDeletePushL(LoopChunk); |
|
237 CMngLoopEntry* self = new (ELeave) CMngLoopEntry(*LoopChunk); |
|
238 CleanupStack::PopAndDestroy(LoopChunk); |
|
239 return self; |
|
240 } |
|
241 |
|
242 void CMngLoopEntry::ExecuteL(CMngPlayer& aPlayer, TMngExecuteResult& /*aResult*/) |
|
243 { |
|
244 ASSERT(iIterationsLeft>-1); |
|
245 TLoopStackItem item; |
|
246 item.iLoopObjectLabel = ObjectLabel(); |
|
247 item.iNestLevel = iNestLevel; |
|
248 if (iIterationsLeft > 0) |
|
249 { |
|
250 --iIterationsLeft; |
|
251 } |
|
252 if (iIterationsLeft > 0) |
|
253 { |
|
254 item.iMoreIterationsNeeded = ETrue; |
|
255 } |
|
256 else |
|
257 { |
|
258 iIterationsLeft = iIterationCount; |
|
259 item.iMoreIterationsNeeded = EFalse; |
|
260 } |
|
261 aPlayer.LoopStack().PushL(item); |
|
262 } |
|
263 |
|
264 void CMngLoopEntry::Reset() |
|
265 { |
|
266 iIterationsLeft = iIterationCount; |
|
267 } |
|
268 |
|
269 /*static*/ |
|
270 CMngObject* CMngLoopEnd::NewL(TMngChunk*& aEndlChunk) |
|
271 { |
|
272 TEndlChunk* EndlChunk=static_cast<TEndlChunk*>(aEndlChunk); |
|
273 aEndlChunk = NULL; |
|
274 CleanupDeletePushL(EndlChunk); |
|
275 CMngLoopEnd* self = new (ELeave) CMngLoopEnd(*EndlChunk); |
|
276 CleanupStack::PopAndDestroy(EndlChunk); |
|
277 return self; |
|
278 } |
|
279 |
|
280 void CMngLoopEnd::ExecuteL(CMngPlayer& aPlayer, TMngExecuteResult& aResult) |
|
281 { |
|
282 TLoopStackItem item; |
|
283 if (KErrNone != aPlayer.LoopStack().Pop(item)) |
|
284 { |
|
285 User::Leave(KErrCorrupt); |
|
286 } |
|
287 if (item.iNestLevel != iNestLevel) |
|
288 { |
|
289 User::Leave(KErrCorrupt); |
|
290 } |
|
291 if (item.iMoreIterationsNeeded) |
|
292 { |
|
293 aResult.iCommand = ECmdJumpToObject; |
|
294 aResult.iObjectLabel= item.iLoopObjectLabel; |
|
295 } |
|
296 } |