|
1 /* |
|
2 * Copyright (c) 2003 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: SVG Engine header file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __INC_CSVGTIMER__ |
|
20 #define __INC_CSVGTIMER__ |
|
21 |
|
22 #if !defined(__E32BASE_H__) |
|
23 #include <e32base.h> |
|
24 #endif |
|
25 #include "GfxFloatFixPt.h" |
|
26 |
|
27 // Maximum frame rate: 15 fps |
|
28 const TUint32 KMinFrameDelay = 33; // milliseconds |
|
29 const TUint32 KMinSleepDuration = 1; // milliseconds |
|
30 |
|
31 // Minimum sleep duration in msecs |
|
32 const TUint32 KMinSleepDurationInMsecs = 1000; |
|
33 |
|
34 class CSvgEngineImpl; |
|
35 class CSvgTimeContainer; |
|
36 |
|
37 /** |
|
38 * A Timer class that wraps Symbian CTimer class |
|
39 * All the essential functionality is same |
|
40 * Adds additional capabilities such as frames, frames per second information, |
|
41 * ability to specify/change duration etc. |
|
42 * |
|
43 * @lib SVGEngine.lib |
|
44 * @since 1.0 |
|
45 */ |
|
46 class CSvgTimer : public CTimer |
|
47 { |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Two phase constructor |
|
52 * |
|
53 * @since 1.0 |
|
54 * @param aTimeContainer - Pointer to the Time Container |
|
55 * @return An instance of the CSvgTimer |
|
56 */ |
|
57 static CSvgTimer* NewLC( CSvgTimeContainer* |
|
58 aTimeContainer ); |
|
59 |
|
60 /** |
|
61 * Two phase constructor |
|
62 * |
|
63 * @since 1.0 |
|
64 * @param aTimeContainer - Pointer to the Time Container |
|
65 * @return An instance of the CSvgTimer |
|
66 */ |
|
67 static CSvgTimer* NewL( CSvgTimeContainer* |
|
68 aTimeContainer ); |
|
69 |
|
70 /** |
|
71 * Destructor |
|
72 * |
|
73 * @since 1.0 |
|
74 * @param None |
|
75 * @return None |
|
76 */ |
|
77 ~CSvgTimer(); |
|
78 |
|
79 public: |
|
80 // Defined as pure virtual by CActive; |
|
81 |
|
82 /** |
|
83 * Standard Active Object DoCancel |
|
84 * |
|
85 * @since 1.0 |
|
86 * @param None |
|
87 * @return None |
|
88 */ |
|
89 void DoCancel(); |
|
90 |
|
91 /** |
|
92 * Standard Active Object RunL |
|
93 * |
|
94 * @since 1.0 |
|
95 * @param |
|
96 * @return |
|
97 */ |
|
98 void RunL(); |
|
99 |
|
100 |
|
101 /** |
|
102 * Reset the time |
|
103 * |
|
104 * @since 1.0 |
|
105 * @param None |
|
106 * @return None |
|
107 */ |
|
108 void ResetTime(); |
|
109 |
|
110 /** |
|
111 * CHange the duration of the timer |
|
112 * |
|
113 * @since 1.0 |
|
114 * @param aTimerDuration - An integer that is the new duration |
|
115 * @return None |
|
116 */ |
|
117 void ChangeFrameDuration( TUint32 aTimerDuration ); |
|
118 |
|
119 |
|
120 /** |
|
121 * Return the frames per second information |
|
122 * |
|
123 * @since 1.0 |
|
124 * @param None |
|
125 * @return An integer that is the number of frames per second |
|
126 */ |
|
127 TUint Fps(); |
|
128 |
|
129 /** |
|
130 * Resume function |
|
131 * |
|
132 * @since 1.0 |
|
133 * @param aTime Time in msecs to resume after(Must be Positive) |
|
134 * @return An integer that is the number of frames per second |
|
135 */ |
|
136 void SVGResume( TInt32 aTime ); |
|
137 |
|
138 /** |
|
139 * Pause function |
|
140 * |
|
141 * @since 1.0 |
|
142 * @param None |
|
143 * @return An integer that is the number of frames per second |
|
144 */ |
|
145 void SVGStop(); |
|
146 |
|
147 /** |
|
148 * Set Start Time for animation |
|
149 * |
|
150 * @since 1.0 |
|
151 * @param None |
|
152 * @return None |
|
153 */ |
|
154 void SetStartTime(); |
|
155 |
|
156 /** |
|
157 * Set the timer to forward/rewind animation |
|
158 * |
|
159 * @since 1.0 |
|
160 * @param aTime - in microseconds |
|
161 * @return None |
|
162 */ |
|
163 void SetSeekTime( TUint32 aTime ); |
|
164 |
|
165 /** |
|
166 * Set whether each frame generated should be time-base or |
|
167 * frame-based. |
|
168 * |
|
169 * @since 1.0 |
|
170 * @param aKeepStrictFrameDuration - if ETrue then |
|
171 * every cycle of RunL will generate a frame with the elapsed |
|
172 * time set by ChangeFrameDuration(). |
|
173 * @return None |
|
174 */ |
|
175 void SetStrictFrameDuration( TBool aKeepStrictFrameDuration ); |
|
176 |
|
177 protected: |
|
178 |
|
179 /** |
|
180 * Private constructor |
|
181 * |
|
182 * @since 1.0 |
|
183 * @param aSvgEngine - A pointer to the SVG Engine |
|
184 * @return None |
|
185 */ |
|
186 CSvgTimer( CSvgTimeContainer* |
|
187 aTimeContainer ); |
|
188 /** |
|
189 * A private constructor that constructs heap objects |
|
190 * |
|
191 * @since 1.0 |
|
192 * @param None |
|
193 * @return None |
|
194 */ |
|
195 void ConstructL(); |
|
196 |
|
197 private: |
|
198 static TUint32 GetElapsedMilliseconds( TTime& aStart, TTime& aEnd ); |
|
199 |
|
200 /** |
|
201 * Request svg engine to generate frame at the given time in |
|
202 * milliseconds |
|
203 * |
|
204 * @since 1.0 |
|
205 * @param aTime - milliseconds |
|
206 * @return None |
|
207 */ |
|
208 TUint32 GenerateFrameL( TUint32 aTime ); |
|
209 |
|
210 |
|
211 CSvgTimeContainer* iTimeContainer; |
|
212 |
|
213 TUint32 iTime; // in millisecond |
|
214 TUint32 iFrameDuration; // in millisecond |
|
215 TTime iPreviousFrameTime; |
|
216 |
|
217 TUint32 iFrames; // for debug. counting FPS |
|
218 |
|
219 // Frame-based or time-based (default) |
|
220 TBool iIsStrictFrameDuration; |
|
221 |
|
222 TBool iFirstFrameDrawn; |
|
223 }; |
|
224 |
|
225 #endif //__INC_CSVGTIMER__ |