|
1 /* |
|
2 * Copyright (c) 2005 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: SVGRenderFrameControl provides an implementation of a control |
|
15 * which renders SVG using RenderFrames API provided by the |
|
16 * engine. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef SVGRENDERFRAMECONTROL_H |
|
22 #define SVGRENDERFRAMECONTROL_H |
|
23 |
|
24 #include <gdi.h> |
|
25 #include <SVGRequestObserver.h> |
|
26 #include <e32base.h> |
|
27 #include <coecntrl.h> |
|
28 #include "SvgRenderFrameTimer.h" |
|
29 |
|
30 const TInt KMaxTimeDuration=2500; |
|
31 class CSvgEngineInterfaceImpl; |
|
32 class MSvgtAppObserver; |
|
33 |
|
34 |
|
35 /** |
|
36 * CSvgRenderFrameControl is a CCoeControl used to display SVGT content. |
|
37 * It makes use of RenderFrames API provided by the svg engine to get |
|
38 * the set of frame buffers and render it one by using render frame timer |
|
39 * |
|
40 * @lib SVGTScreenSaverPlugin.lib |
|
41 * @since 3.1 |
|
42 */ |
|
43 class CSvgRenderFrameControl: public CCoeControl, |
|
44 public MSvgRenderFrameTimerListener, |
|
45 public MSvgRequestObserver |
|
46 { |
|
47 |
|
48 public: |
|
49 |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * @since 3.1 |
|
53 */ |
|
54 static CSvgRenderFrameControl* NewL( |
|
55 const CCoeControl* aParent, |
|
56 RFile& aFileHandle, |
|
57 MSvgtAppObserver* aObserver = NULL ); |
|
58 |
|
59 /** |
|
60 * Two-phased constructor. |
|
61 * @since 3.1 |
|
62 */ |
|
63 static CSvgRenderFrameControl* NewLC( |
|
64 const CCoeControl* aParent, |
|
65 RFile& aFileHandle, |
|
66 MSvgtAppObserver* aObserver = NULL ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 */ |
|
71 virtual ~CSvgRenderFrameControl(); |
|
72 |
|
73 |
|
74 /** |
|
75 * From CCoeControl, |
|
76 * @since 3.1 |
|
77 */ |
|
78 void Draw(const TRect& aRect) const; |
|
79 |
|
80 /** |
|
81 * From CCoeControl, |
|
82 * @since 3.1 |
|
83 */ |
|
84 void SizeChanged(); |
|
85 |
|
86 public : // From MSvgRequestObserver |
|
87 |
|
88 /** |
|
89 * From MSvgRequestObserver, Method Called by Svg Engine, |
|
90 * when the frame buffer is updated and has to be redrawn |
|
91 * @since 3.1 |
|
92 */ |
|
93 virtual void UpdateScreen(); |
|
94 |
|
95 /** |
|
96 * From MSvgRequestObserver, Method Called by Svg Engine, |
|
97 * when there is a script support |
|
98 * @since 3.1 |
|
99 */ |
|
100 virtual TBool ScriptCall( const TDesC& aScript, |
|
101 CSvgElementImpl* aCallerElement ); |
|
102 |
|
103 /** |
|
104 * From MSvgRequestObserver, Method Called by Svg Engine, |
|
105 * when it encounters an image element |
|
106 * @since 3.1 |
|
107 */ |
|
108 virtual TInt FetchImage( const TDesC& aUri, RFs& aSession, |
|
109 RFile& aFileHandle ); |
|
110 |
|
111 TInt FetchFont( const TDesC& /* aUri */, |
|
112 RFs& /* aSession */, RFile& /* aFileHandle */ ); |
|
113 |
|
114 /** |
|
115 * This Method is called by the Svg engine to Get the SMIL |
|
116 * Fit Attribute Value |
|
117 * @since 3.1 |
|
118 */ |
|
119 virtual void GetSmilFitValue( TDes& aSmilValue ); |
|
120 |
|
121 /** |
|
122 * This Method updates the presentation status |
|
123 * @since 3.1 |
|
124 */ |
|
125 virtual void UpdatePresentation(const TInt32& aNoOfAnimation); |
|
126 |
|
127 public: // From MSvgRenderFrameTimerListener |
|
128 |
|
129 /** |
|
130 * This function is a callback from animation timer, |
|
131 * when there is an animation timeout. |
|
132 * @since 3.1 |
|
133 */ |
|
134 virtual void AnimationTimeOut(); |
|
135 |
|
136 |
|
137 public: // New Function |
|
138 |
|
139 /* |
|
140 * Starts the timer |
|
141 * @since 3.1 |
|
142 */ |
|
143 void SetTimer(); |
|
144 |
|
145 /* |
|
146 * Cancels the timer |
|
147 * @since 3.1 |
|
148 */ |
|
149 void CancelTimer(); |
|
150 |
|
151 /* |
|
152 * Processes the command sent by the user of the control |
|
153 * @param aCommandId - command to be processed |
|
154 * @since 3.1 |
|
155 */ |
|
156 virtual void ProcessViewerCommandL( TInt aCommandId ); |
|
157 |
|
158 /* |
|
159 * Gets the current index of the frame buffers |
|
160 * @since 3.1 |
|
161 */ |
|
162 TInt GetCurrentIndex() const; |
|
163 |
|
164 /* |
|
165 * Sets the index of the buffer to be used |
|
166 * @param aIndex - index to be set |
|
167 * @since 3.1 |
|
168 */ |
|
169 void SetCurrentIndex( TInt aIndex ); |
|
170 |
|
171 /** |
|
172 * This function initializes the svg engine. |
|
173 * This function is also used to check the validity of the file. |
|
174 * @param aCheckFile True if used in check file mode |
|
175 * False otherwise |
|
176 * @since 3.1 |
|
177 */ |
|
178 void InitializeEngineL( TBool aCheckFile, |
|
179 MSvgRequestObserver* aObserver = NULL ); |
|
180 |
|
181 |
|
182 /** |
|
183 * This function deletes the svg engine. |
|
184 * @since 3.1 |
|
185 */ |
|
186 void DeleteEngine(); |
|
187 |
|
188 /** |
|
189 * This function uses the svg engine to get the frames in an array |
|
190 * of buffers. |
|
191 * @since 3.1 |
|
192 */ |
|
193 TInt RenderMyFrames(); |
|
194 |
|
195 /** |
|
196 * This function moves the index of the array |
|
197 * of buffers. |
|
198 * @since 3.1 |
|
199 */ |
|
200 void MoveIndex(); |
|
201 |
|
202 /** |
|
203 * This function logs the debug message |
|
204 * @param aMsg - message to be logged |
|
205 * @since 3.1 |
|
206 */ |
|
207 void PrintDebugMsg( const TDesC& aMsg ) const; |
|
208 |
|
209 |
|
210 public: |
|
211 /** |
|
212 * Default Constructor |
|
213 * @since 3.1 |
|
214 */ |
|
215 CSvgRenderFrameControl( RFile& aFileHandle , |
|
216 MSvgtAppObserver* aObserver = NULL ); |
|
217 |
|
218 |
|
219 /** |
|
220 * 2nd phase constructor |
|
221 * @since 3.1 |
|
222 */ |
|
223 void ConstructL( const CCoeControl* aParent ); |
|
224 |
|
225 private: |
|
226 |
|
227 // Pointer to the Svg Engine |
|
228 CSvgEngineInterfaceImpl* iSvgEngine; |
|
229 |
|
230 // Frame buffer to be given to svg engine during initialization |
|
231 CFbsBitmap* iBmap; |
|
232 |
|
233 // Array of bitmaps generated by RenderFrames |
|
234 RPointerArray<CFbsBitmap> iBitmapFrames; |
|
235 |
|
236 // Array of corresponding masks for the Bitmaps |
|
237 RPointerArray<CFbsBitmap> iMaskFrames; |
|
238 |
|
239 // Array of TimeInterval between frames |
|
240 RArray<TUint> iDelayIntervals; |
|
241 |
|
242 // file handle of the svg file to be set as ScreenSaver. |
|
243 RFile* iFileHandle; |
|
244 |
|
245 // Index of the bitmap in the array |
|
246 TInt iCurrentFrame; |
|
247 |
|
248 // Start duration to be given to RenderFrames |
|
249 TUint iDuration; |
|
250 |
|
251 // Handle to the Svg Dom |
|
252 TInt iSvgDom; |
|
253 |
|
254 // timer |
|
255 CSvgRenderFrameTimer* iRenderFrameTimer; |
|
256 |
|
257 // boolean to check whether it is in play or paused state |
|
258 TBool iCanPlay; |
|
259 |
|
260 // size of the control currently |
|
261 TRect iRect; |
|
262 |
|
263 // Parent Control |
|
264 const CCoeControl* iParent; |
|
265 |
|
266 // App observer pointer |
|
267 MSvgtAppObserver* iAppObserver; |
|
268 |
|
269 }; |
|
270 |
|
271 #endif // SVGRENDERFRAMECONTROL_H |
|
272 // End of File |