|
1 /* |
|
2 * Copyright (c) 2003-2006 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 * Implementation of SmilMediaRenderer, a image renderer. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef IMAGE_RENDERER_H |
|
22 #define IMAGE_RENDERER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <smilmediarendererinterface.h> |
|
26 #include <smiltime.h> |
|
27 #include <smilactiveinterface.h> |
|
28 #include <MIHLViewerObserver.h> |
|
29 #include <eiksbfrm.h> |
|
30 |
|
31 #include "SmilMediaRendererBase.h" |
|
32 |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class MSmilFocus; |
|
36 class MIHLFileImage; |
|
37 class MIHLBitmap; |
|
38 class MIHLImageViewer; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * CSmilImageRenderer provides SMIL media renderer interface for |
|
44 * image source files. |
|
45 * This class is used by SMIL Engine to perform the image rending. |
|
46 * |
|
47 * @lib smilmediarenderer.lib |
|
48 * @since 2.0 |
|
49 */ |
|
50 NONSHARABLE_CLASS(CSmilImageRenderer) : public CSmilMediaRendererBase, |
|
51 public MIHLViewerObserver, |
|
52 public MSmilActive, |
|
53 public MEikScrollBarObserver |
|
54 { |
|
55 public: // Methods |
|
56 |
|
57 // Constructors and destructor |
|
58 |
|
59 /** |
|
60 * Static constructor. |
|
61 * |
|
62 * @since 2.0 |
|
63 * @param aFileHandle IN Source file handle. |
|
64 * @param aMedia IN SMIL media object. |
|
65 * @param aDrmCommon IN DRM Common |
|
66 * @param aDrmHelper IN DRM Helper |
|
67 * |
|
68 * @return Initialized image renderer object. |
|
69 */ |
|
70 static CSmilImageRenderer* NewL( RFile& aFileHandle, |
|
71 MSmilMedia* aMedia, |
|
72 DRMCommon& aDrmCommon, |
|
73 CDRMHelper& aDrmHelper ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 * |
|
78 * @since 2.0 |
|
79 */ |
|
80 virtual ~CSmilImageRenderer(); |
|
81 |
|
82 public: // From MSmilMediaRenderer |
|
83 |
|
84 /** |
|
85 * From MSmilMediaRenderer Called by the SMIL engine to signal |
|
86 * that the engine is no more referencing renderer. |
|
87 * |
|
88 * @since 2.0 |
|
89 * |
|
90 * @return void |
|
91 */ |
|
92 void Close(); |
|
93 |
|
94 /** |
|
95 * From MSmilMediaRenderer Returns if renderer is visual |
|
96 * (i.e. draws something to the screen). |
|
97 * |
|
98 * @since 2.0 |
|
99 * |
|
100 * @return Returns ETrue since the media type is visual. |
|
101 */ |
|
102 TBool IsVisual() const; |
|
103 |
|
104 /** |
|
105 * From MSmilMediaRenderer Returns if renderer is non-transparent |
|
106 * (i.e. fills all the pixels on specied region). |
|
107 * |
|
108 * @since 2.0 |
|
109 * |
|
110 * @return Returns EFalse if source image is non-transparent |
|
111 * otherwise returns ETrue. |
|
112 */ |
|
113 TBool IsOpaque() const; |
|
114 |
|
115 /** |
|
116 * From MSmilMediaRenderer Returns if renderer is scrollable. |
|
117 * |
|
118 * @since 2.0 |
|
119 * |
|
120 * @return Returns ETrue if image is scrollable and EFalse if |
|
121 * it is not. |
|
122 */ |
|
123 TBool IsScrollable() const; |
|
124 |
|
125 /** |
|
126 * From MSmilMediaRenderer Returns if renderer is Symbian control. |
|
127 * |
|
128 * @since 2.0 |
|
129 * |
|
130 * @return Returns ETrue since all the renderers are implemented |
|
131 * as controls. |
|
132 */ |
|
133 TBool IsControl() const; |
|
134 |
|
135 /** |
|
136 * From MSmilMediaRenderer Returns the unscalable size of the |
|
137 * visual media object. |
|
138 * |
|
139 * @since 2.0 |
|
140 * |
|
141 * @return Width in pixels. |
|
142 */ |
|
143 TInt IntrinsicWidth() const; |
|
144 |
|
145 /** |
|
146 * From MSmilMediaRenderer Returns the unscalable size of the |
|
147 * visual media object. |
|
148 * |
|
149 * @since 2.0 |
|
150 * |
|
151 * @return Height in pixels. |
|
152 */ |
|
153 TInt IntrinsicHeight() const; |
|
154 |
|
155 /** |
|
156 * From MSmilMediaRenderer Returns the duration of the media object. |
|
157 * |
|
158 * @since 2.0 |
|
159 * |
|
160 * @return Returns duration of image (Note! zero duration means still |
|
161 * image). |
|
162 */ |
|
163 TSmilTime IntrinsicDuration() const; |
|
164 |
|
165 /** |
|
166 * From MSmilMediaRenderer Called by the engine to signal that |
|
167 * the media is going to be played soon. |
|
168 * |
|
169 * @since 2.0 |
|
170 * |
|
171 * @return void |
|
172 */ |
|
173 void PrepareMediaL(); |
|
174 |
|
175 /** |
|
176 * From MSmilMediaRenderer Called by the engine to seek the media |
|
177 * to given position in its local timeline. |
|
178 * |
|
179 * @since 2.0 |
|
180 * |
|
181 * @param aTime IN Seek position. |
|
182 * |
|
183 * @return void |
|
184 */ |
|
185 void SeekMediaL( const TSmilTime& aTime ); |
|
186 |
|
187 /** |
|
188 * From MSmilMediaRenderer Called by the engine to start media |
|
189 * playback and to make visual media visible. |
|
190 * |
|
191 * @since 2.0 |
|
192 * |
|
193 * @return void |
|
194 */ |
|
195 void ShowMediaL(); |
|
196 |
|
197 /** |
|
198 * From MSmilMediaRenderer Called by the engine to stop media |
|
199 * playback and remove visual media from the screen. |
|
200 * |
|
201 * @since 2.0 |
|
202 * |
|
203 * @return void |
|
204 */ |
|
205 void HideMedia(); |
|
206 |
|
207 /** |
|
208 * From MSmilMediaRenderer Called by the engine to pause media playback. |
|
209 * |
|
210 * @since 2.0 |
|
211 * |
|
212 * @return void |
|
213 */ |
|
214 void FreezeMedia(); |
|
215 |
|
216 /** |
|
217 * From MSmilMediaRenderer Called by the engine to continue paused |
|
218 * media playback. |
|
219 * |
|
220 * @since 2.0 |
|
221 * |
|
222 * @return void |
|
223 */ |
|
224 void ResumeMedia(); |
|
225 |
|
226 /** |
|
227 * From MSmilMediaRenderer Called by the engine to make a media |
|
228 * renderer draw its content. |
|
229 * |
|
230 * @since 2.0 |
|
231 * |
|
232 * @param aGc IN Graphical context performing the drawing. |
|
233 * @param aRect IN Target rectangle. |
|
234 * @param aTransitionFilter IN Transition effects if present. |
|
235 * @param aFocus IN Focus indication if focussed. |
|
236 * |
|
237 * @return void |
|
238 */ |
|
239 void Draw( CGraphicsContext& aGc, |
|
240 const TRect& aRect, |
|
241 CSmilTransitionFilter* aTransitionFilter, |
|
242 const MSmilFocus* aFocus ); |
|
243 |
|
244 /** |
|
245 * From MSmilMediaRenderer Move scrollable media to given position. |
|
246 * |
|
247 * @since 2.0 |
|
248 * |
|
249 * @param aDirX IN Amount of pixels to move on X direction. |
|
250 * @param aDirY IN Amount of pixels to move on Y direction. |
|
251 * |
|
252 * @return void |
|
253 */ |
|
254 void Scroll( TInt aDirX, TInt aDirY ); |
|
255 |
|
256 /** |
|
257 * from MEikScrollBarObserver |
|
258 * Handles the scrollevents |
|
259 */ |
|
260 void HandleScrollEventL( CEikScrollBar* aScrollBar, |
|
261 TEikScrollEvent aEventType ); |
|
262 |
|
263 protected: // From MSmilActive |
|
264 |
|
265 /** |
|
266 * Called when the requested time has been reached. |
|
267 * |
|
268 * @since 3.0 |
|
269 * |
|
270 * @param aTime IN Current time, relative to the requesting media obect. |
|
271 */ |
|
272 void ActivateL( const TSmilTime& aTime ); |
|
273 |
|
274 protected: // From MIHLViewerObserver |
|
275 |
|
276 /** |
|
277 * From MIHLViewerObserver Notifies client when viewer bitmap content is changed. |
|
278 * Leave situation is handled in ViewerError() callback. |
|
279 * |
|
280 * @since 3.0 |
|
281 * |
|
282 * @return void |
|
283 */ |
|
284 void ViewerBitmapChangedL(); |
|
285 |
|
286 /** |
|
287 * From MIHLViewerObserver Notifies client if error occurs in viewer. |
|
288 * |
|
289 * @since 2.0 |
|
290 * |
|
291 * @param aError IN System wide error code. |
|
292 * |
|
293 * @return void |
|
294 */ |
|
295 void ViewerError( TInt aError ); |
|
296 |
|
297 private: //Types |
|
298 |
|
299 // Scrolling directions. |
|
300 enum TDirection |
|
301 { |
|
302 EScrollUp, |
|
303 EScrollDown, |
|
304 EScrollLeft, |
|
305 EScrollRight |
|
306 }; |
|
307 |
|
308 // Internal states. |
|
309 enum TState |
|
310 { |
|
311 ENotReady = 0, |
|
312 EReady, |
|
313 EPlaying, |
|
314 EPaused, |
|
315 EHidden, |
|
316 EError |
|
317 }; |
|
318 |
|
319 private: //Methods |
|
320 |
|
321 /** |
|
322 * C++ default constructor |
|
323 */ |
|
324 CSmilImageRenderer(); |
|
325 |
|
326 /** |
|
327 * Constructor. |
|
328 */ |
|
329 CSmilImageRenderer( MSmilMedia* aMedia, |
|
330 DRMCommon& aDrmCommon, |
|
331 CDRMHelper& aDrmHelper ); |
|
332 |
|
333 /** |
|
334 * By default Symbian 2nd phase constructor is private. |
|
335 */ |
|
336 void ConstructL( RFile& aFileHandle ); |
|
337 |
|
338 /** |
|
339 * Creates viewer and configures it. |
|
340 */ |
|
341 void InitializeViewerL(); |
|
342 |
|
343 /** |
|
344 * Converts the specified frame. |
|
345 */ |
|
346 void ConvertFrameL( TInt aFrame ); |
|
347 |
|
348 /** |
|
349 * Initializes the scroll bars. |
|
350 */ |
|
351 void SetupScrollingL(); |
|
352 |
|
353 /** |
|
354 * Calculate zoom ratio for meet fit attribute. |
|
355 */ |
|
356 TReal CalculateMeetRatio( const TSize& aRegion, const TSize& aImage ) const; |
|
357 |
|
358 /** |
|
359 * Calculate zoom ratio for slice fit attribute. |
|
360 */ |
|
361 TReal CalculateSliceRatio( const TSize& aRegion, const TSize& aImage ) const; |
|
362 |
|
363 /** |
|
364 * Sets internal state variables |
|
365 */ |
|
366 void SetState( TInt aNewState ); |
|
367 |
|
368 /** |
|
369 * Checks if scrolling to specified direction is possible. |
|
370 */ |
|
371 TBool IsScrollingPossible( TDirection aDirection ) const; |
|
372 |
|
373 /** |
|
374 * Calculates single scrolling step size to specified direction. |
|
375 */ |
|
376 void CalculateScrollStepSize( TDirection aDirection, |
|
377 TSize& aScrollingStep, TInt aStepSize = 1 ) const; |
|
378 |
|
379 /** |
|
380 * Draws the scrollbar(s) |
|
381 */ |
|
382 void DrawScrollBarL(); |
|
383 |
|
384 /** |
|
385 * Scrolls without redrawing the thumbs on the scrollbar |
|
386 * |
|
387 * @param aDirX IN Amount of pixels to move on X direction. |
|
388 * @param aDirY IN Amount of pixels to move on Y direction. |
|
389 * |
|
390 * @return void |
|
391 */ |
|
392 void ScrollWithOutThumbUpdate( TInt aDirX, TInt aDirY ); |
|
393 |
|
394 private: // Data |
|
395 |
|
396 // Source image |
|
397 MIHLFileImage* iSourceImage; |
|
398 |
|
399 // Destination bitmap |
|
400 MIHLBitmap* iDestinationBitmap; |
|
401 |
|
402 // Image viewer used as engine |
|
403 MIHLImageViewer* iEngine; |
|
404 |
|
405 // Total duration of the animation. |
|
406 TSmilTime iTotalLength; |
|
407 |
|
408 // Error flag |
|
409 TInt iError; |
|
410 |
|
411 // Specifies whether renderer is scrollable. |
|
412 TBool iIsScrollable; |
|
413 |
|
414 // Scrolling rectangle. |
|
415 TRect iImageScrollRect; |
|
416 |
|
417 // Previous internal state. |
|
418 TInt iPrevState; |
|
419 |
|
420 // Current internal state. |
|
421 TInt iCurrState; |
|
422 |
|
423 // Specifies the time taken by some operation. |
|
424 TTimeIntervalMicroSeconds iProcessingDelay; |
|
425 |
|
426 // Image bitmap size |
|
427 TSize iSourceSize; |
|
428 |
|
429 // Indicates whether image is animation. Value is |
|
430 // stored because we lose this information when |
|
431 // iEngine and iSourceImage are deleted for memory |
|
432 // optimization. |
|
433 TBool iAnimation; |
|
434 |
|
435 #ifdef RD_SCALABLE_UI_V2 |
|
436 // Scrollbar frame |
|
437 CEikScrollBarFrame* iSBFrame; |
|
438 |
|
439 //indicator whether or not the scrollbar needs to be |
|
440 // initialised and drawn |
|
441 TBool iNotYetDrawn; |
|
442 |
|
443 //save the thumb position if replay is needed |
|
444 TInt iThumbPosX; |
|
445 |
|
446 //save the thumb position if replay is needed |
|
447 TInt iThumbPosY; |
|
448 |
|
449 //from scrollbar, member because maxvalue of scrollbar |
|
450 // is uninitialised |
|
451 TInt iScrollSpanY; |
|
452 TInt iScrollSpanX; |
|
453 #endif // RD_SCALABLE_UI_V2 |
|
454 }; |
|
455 |
|
456 #endif // IMAGE_RENDERER_H |
|
457 |
|
458 // End of File |