|
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_CSVGENGINEIMPL__ |
|
20 #define __INC_CSVGENGINEIMPL__ |
|
21 |
|
22 #if !defined(__E32BASE_H__) |
|
23 #include <e32base.h> |
|
24 #endif |
|
25 |
|
26 #include <fbs.h> |
|
27 |
|
28 |
|
29 #include "SVGEngineInterfaceImpl.h" |
|
30 #include "GfxAffineTransform.h" |
|
31 #include "SVGEvent.h" |
|
32 #include "SVGDocumentImpl.h" |
|
33 #include "SVGRequestObserver.h" |
|
34 #include "SVGImageElementImpl.h" |
|
35 #include "SVGFourPointRect.h" |
|
36 #include "SVGListener.h" |
|
37 #include "SVGFontHashMap.h" |
|
38 #include "SvgBitmapFontProvider.h" |
|
39 #include <SVGRendererId.h> |
|
40 |
|
41 // Svg Engine states |
|
42 enum TSvgEngineState |
|
43 { |
|
44 ESVGEngineRunning, |
|
45 ESVGEnginePaused, |
|
46 ESVGEngineNotStarted, |
|
47 ESVGEngineStopped |
|
48 }; |
|
49 typedef TUint8 TAnimStatus; |
|
50 |
|
51 |
|
52 class CSvgSchemaData; |
|
53 class CSvgElementImpl; |
|
54 class MXmlDOMImplementation; |
|
55 class CGfx2dGc; |
|
56 |
|
57 class CSvgEventHandler; |
|
58 class MSvgEventReceiver; |
|
59 class CSvgErrorImpl; |
|
60 class CSvgAElementImpl; |
|
61 class CSvgTextAreaElementImpl; |
|
62 class CSvgTextElementImpl; |
|
63 |
|
64 class CSvgExternalDataHandler; |
|
65 class MSvgDataRequester; |
|
66 |
|
67 // temporary for debugging |
|
68 class CSvgTimer; |
|
69 // temporary for debugging |
|
70 |
|
71 //This includes the main rendering loop. |
|
72 |
|
73 /** |
|
74 * Class description goes here. |
|
75 * |
|
76 * @lib SVGEngine.lib |
|
77 * @since 1.0 |
|
78 */ |
|
79 class CSvgEngineImpl : public CBase, public MSVGImageLoadingObserver |
|
80 { |
|
81 public: // Constructor & Destructor |
|
82 |
|
83 static CSvgEngineImpl* NewL(CSvgBitmapFontProvider *aSvgBitmapFontProvider); |
|
84 |
|
85 static CSvgEngineImpl* NewLC(CSvgBitmapFontProvider *aSvgBitmapFontProvider); |
|
86 |
|
87 void ConstructL(CSvgBitmapFontProvider *aSvgBitmapFontProvider); |
|
88 |
|
89 /** |
|
90 * Two phase constructor |
|
91 * |
|
92 * @since 1.0 |
|
93 * @param aFrameBuffer - Pointer to a buffer where the SVG document raster is drawn |
|
94 * @param aReqObserver - Pointer to a client side object that implements the MSvgRequestObserver interface |
|
95 * @return An instance of the SVG Engine |
|
96 */ |
|
97 static CSvgEngineImpl* NewL( CFbsBitmap* aFrameBuffer, |
|
98 MSvgRequestObserver* aReqObserver, TFontSpec& aFontSpec, CSvgBitmapFontProvider *aSvgBitmapFontProvider ); |
|
99 |
|
100 /** |
|
101 * Two phase constructor |
|
102 * |
|
103 * @since 1.0 |
|
104 * @param aFrameBuffer - Pointer to a buffer where the SVG document raster is drawn |
|
105 * @param aReqObserver - Pointer to a client side object that implements the MSvgRequestObserver interface |
|
106 * @return An instance of the SVG Engine |
|
107 */ |
|
108 static CSvgEngineImpl* NewLC( CFbsBitmap* aFrameBuffer, |
|
109 MSvgRequestObserver* aReqObserver, TFontSpec& aFontSpec, CSvgBitmapFontProvider *aSvgBitmapFontProvider ); |
|
110 |
|
111 /** |
|
112 * Destructor |
|
113 * |
|
114 * @since 1.0 |
|
115 * @param None |
|
116 * @return None |
|
117 */ |
|
118 |
|
119 virtual ~CSvgEngineImpl(); |
|
120 |
|
121 static CSvgEngineImpl* NewL( CFbsBitmap* aFrameBuffer, |
|
122 MSvgRequestObserver* aReqObserver, TFontSpec& aFontSpec, CSvgBitmapFontProvider *aSvgBitmapFontProvider,SVGRendererId aRendererType ); |
|
123 static CSvgEngineImpl* NewLC( CFbsBitmap* aFrameBuffer, |
|
124 MSvgRequestObserver* aReqObserver, TFontSpec& aFontSpec, CSvgBitmapFontProvider *aSvgBitmapFontProvider,SVGRendererId aRendererType ); |
|
125 public: // New Functions |
|
126 /** |
|
127 * Get the NVG-TLV data |
|
128 * |
|
129 * @since 1.0 |
|
130 * @return descriptor pointing to the encoded data. |
|
131 */ |
|
132 const TPtrC8 TLVEncodedData() const; |
|
133 |
|
134 /** |
|
135 * Kick off the process of rasterizing the SVG document elements |
|
136 * |
|
137 * @since 1.0 |
|
138 * @param aRootElement - Root element of the SVG document |
|
139 * @return None |
|
140 */ |
|
141 void DrawElementsL( CSvgElementImpl* aRootElement); |
|
142 /** |
|
143 * Kick off the process of placing graphical objects in their positions for rasterization |
|
144 * |
|
145 * @since 1.0 |
|
146 * @param aRootElement - Root element of the SVG document |
|
147 * @return None |
|
148 */ |
|
149 void UpdateCTM(CSvgDocumentImpl* aSvgDocument ); |
|
150 |
|
151 |
|
152 /** |
|
153 * Invalidate the current raster and hence kick off another round of rasterization |
|
154 * process |
|
155 * |
|
156 * @since 1.0 |
|
157 * @param None |
|
158 * @return None |
|
159 */ |
|
160 void RedrawL(); |
|
161 |
|
162 |
|
163 /** |
|
164 * Destroy the current representation of the SVG document |
|
165 * |
|
166 * @since 1.0 |
|
167 * @param None |
|
168 * @return None |
|
169 */ |
|
170 void Destroy(); |
|
171 |
|
172 /** |
|
173 * An acessor to the document object that represents the current SVG source |
|
174 * |
|
175 * @since 1.0 |
|
176 * @param None |
|
177 * @return Pointer to the document object instance. |
|
178 */ |
|
179 CSvgDocumentImpl* Document(); |
|
180 |
|
181 /** |
|
182 * Overwrite the current path information in the given element |
|
183 * |
|
184 * |
|
185 * @param hPath - handle to a path |
|
186 * @param hElement - handle to a path element |
|
187 * @return none |
|
188 */ |
|
189 void UpdatePath( CGfxGeneralPath* hPath, CSvgElementImpl* hElement ); |
|
190 |
|
191 /** |
|
192 * Kick off the processing of SVG source, and animation time frames |
|
193 * |
|
194 * @since 1.0 |
|
195 * @param None |
|
196 * @return A boolean value that indicates success/failure |
|
197 */ |
|
198 |
|
199 TBool StartFrameLoopL(); |
|
200 |
|
201 /** |
|
202 * Obtain an image source embedded within a SVG source (JPEG, PNG) |
|
203 * |
|
204 * @since 1.0 |
|
205 * @param aUri - A string buffer with the URI of the image source |
|
206 * @param aFileName - A string buffer with the contents of the image source |
|
207 * @return ETrue - Success, EFalse - Failure |
|
208 * |
|
209 */ |
|
210 TBool FetchImage( const TDesC& aUri, RFs& aSession, RFile& aFileHandle ); |
|
211 |
|
212 /** |
|
213 * Return the animation duration for the given document, if NULL (default) |
|
214 * then use the document attached to engine. The value 0xFFFFFFFF is |
|
215 * return is the animation is indefinite. |
|
216 * |
|
217 * @since 1.0 |
|
218 * @param aDocumentElement - document to find animation duration. |
|
219 * @return An integer containing the aniamtion duration value |
|
220 */ |
|
221 TUint32 Duration( CSvgDocumentImpl* aDocumentElement = NULL ); |
|
222 |
|
223 /** |
|
224 * Accessor for the Graphics Context object |
|
225 * |
|
226 * @since 1.0 |
|
227 * @param None |
|
228 * @return A pointer to the Graphics Context object |
|
229 */ |
|
230 CGfx2dGc* GraphicsContext(); |
|
231 |
|
232 /** |
|
233 * Internally render SVG source into a buffer (rasterization) |
|
234 * |
|
235 * @since 1.0 |
|
236 * @param aSvgData - A string buffer containing the SVG source |
|
237 * @param aFrameBuffer - A bitmap passed by the client that will contain the raster |
|
238 * @param aPreserveAspectRatio - The aspect ratio (see SVG spec for more) for the raster |
|
239 * @return TBool - ETrue/EFalse indicate presence/absence of the resource |
|
240 */ |
|
241 TInt RenderFileToBuffer( const TDesC8& aSvgData, |
|
242 CFbsBitmap* aFrameBuffer, |
|
243 CFbsBitmap* aMask, |
|
244 TBool aPreserveAspectRatio ); |
|
245 |
|
246 |
|
247 void RenderFileL( const TDesC8& aSvgData, |
|
248 CFbsBitmap* aFrameBuffer, |
|
249 CFbsBitmap* aMask, |
|
250 TBool aPreserveAspectRatio); |
|
251 |
|
252 |
|
253 /** |
|
254 * A private method that toggles debug info for developers |
|
255 * |
|
256 * @since 1.0 |
|
257 * @param None |
|
258 * @return None |
|
259 */ |
|
260 void SwitchDebugInfo(TBool debug); |
|
261 |
|
262 /** |
|
263 * A private method that switch between OpenVG and VGR implementation |
|
264 * |
|
265 * @since 1.0 |
|
266 * @param TBool aCustomOption ETrue set OpenVG |
|
267 * @return None |
|
268 */ |
|
269 void CustomOption( TBool aCustomOption ); |
|
270 |
|
271 /** |
|
272 * This method is for future extension, in which an external script engine |
|
273 * could be used to evaluate a script description. |
|
274 * |
|
275 * @since 1.0 |
|
276 * @param : aScript -- A description of script from the "on" attribute. |
|
277 * |
|
278 * @param : aCallerElement -- The element that calls the script by a |
|
279 * an event of the "on" attribute. |
|
280 * @return : For future use. Value is ignored. |
|
281 */ |
|
282 TBool ScriptCall( const TDesC& aScript, |
|
283 CSvgElementImpl* aCallerElement ); |
|
284 |
|
285 /** |
|
286 * Set the URI information in the Engine |
|
287 * |
|
288 * @since 1.0 |
|
289 * @param |
|
290 * @return |
|
291 */ |
|
292 void LinkRequest( const TDesC& aUri ); |
|
293 /** |
|
294 * Need method description |
|
295 * |
|
296 * @since 1.0 |
|
297 * @param |
|
298 * @return |
|
299 */ |
|
300 void LinkRequestWithShow(const TDesC& aUri, const TDesC& aLinkShow); |
|
301 |
|
302 /** |
|
303 * Accessor for the current engine time |
|
304 * |
|
305 * @since 1.0 |
|
306 * @param None |
|
307 * @return An integer that represents the current engine time |
|
308 */ |
|
309 TInt32 CurrentTIme(); |
|
310 |
|
311 /** |
|
312 * Set SVG Dimensions to Frame buffer size |
|
313 * |
|
314 * @since 1.0 |
|
315 * @param None |
|
316 * @return An integer that represents the current engine time |
|
317 */ |
|
318 |
|
319 void SetSvgDimensionToFrameBufferL(TUint aWidth, TUint aHeight); |
|
320 |
|
321 /** |
|
322 * Generate mask bitmap from alpha channel of the framebuffer |
|
323 * |
|
324 * @since |
|
325 * @param |
|
326 * @return |
|
327 */ |
|
328 void GenerateMask( CFbsBitmap* aMask ); |
|
329 |
|
330 /** |
|
331 * Set background color |
|
332 * |
|
333 * @since |
|
334 * @param |
|
335 * @return |
|
336 */ |
|
337 void SetBackgroundColor(TUint32 aRGBA8888Color); |
|
338 |
|
339 /** |
|
340 * Returns SVG Engine State |
|
341 * |
|
342 * @since 1.0 |
|
343 * @param None |
|
344 * @return An integer that represents SVG Engine state |
|
345 */ |
|
346 TSvgEngineState SVGEngineState(); |
|
347 |
|
348 /** |
|
349 * Sets SVG Engine state |
|
350 * |
|
351 * @since 1.0 |
|
352 * @param An integer that represents SVG Engine state |
|
353 * @return void |
|
354 */ |
|
355 void SetSVGEngineState(TSvgEngineState aState); |
|
356 |
|
357 /** |
|
358 * Sets the GDI context from the Bitmap. |
|
359 * |
|
360 * @since 1.0 |
|
361 * @param : aFrameBuffer -- Bitmap to draw svg content. |
|
362 * @param : aReqObserver -- Request observer called by svg engine. |
|
363 * @return |
|
364 */ |
|
365 void SetGdiContextL(CFbsBitmap* aCurrentBitmap, CFbsBitmap* aMask = NULL); |
|
366 |
|
367 void SetGdiContextL(CFbsBitmap* aCurrentBitmap, CFbsBitmap* aMask,TSize aCurrentBitmapSize,TDisplayMode aRenderDspMode,TDisplayMode aMaskDspMode); |
|
368 /** |
|
369 * Start the Engine so that the first frame is drawn when the call is finished. |
|
370 * |
|
371 * |
|
372 * @param : aError |
|
373 * @return: None |
|
374 */ |
|
375 void StartEngine(CSvgErrorImpl* aError = NULL); |
|
376 void RenderFrame( TUint aCurrentTime ); |
|
377 |
|
378 /** |
|
379 * Set the Document |
|
380 * |
|
381 * |
|
382 * @param : CSvgDocumentImpl* aDocument |
|
383 * @return: None |
|
384 */ |
|
385 void SetDocument(CSvgDocumentImpl* aDocument); |
|
386 |
|
387 /** |
|
388 * Given a document handle and a url this call attaches |
|
389 * the given data (ldata) to every element that references that url |
|
390 *@param aDocument - Document Pointer |
|
391 *@param lUrl- uri string that is an external resource to be retrieved |
|
392 *@param ldata - byte array containing the data that that external resource recieved |
|
393 *@return none |
|
394 */ |
|
395 |
|
396 void ChangeDuration( TUint32 aTimerDuration ); |
|
397 |
|
398 void Resume(TInt32 aTime); |
|
399 |
|
400 void SeekEngine( TUint32 aTime); |
|
401 |
|
402 void SetMediaTime(TUint32 aTimeInMilliSeconds); |
|
403 |
|
404 /** |
|
405 * Initializes the SVG Engine primarily with width and height informtion |
|
406 * This is based on the attribute specifications for the root 'svg' element |
|
407 * |
|
408 * @since 1.0 |
|
409 * @param None |
|
410 * @return None |
|
411 */ |
|
412 void InitializeEngineL(); |
|
413 |
|
414 /** |
|
415 * Get all the bounding-boxes for the given text and the contexts include |
|
416 * the text was found. The bounding-boxes are transformed, taking zooming/panning |
|
417 * in account. |
|
418 * |
|
419 * @param : aString -- String to search in the document. |
|
420 * @param : aBoundingBoxes -- Array to hold bounding-boxes info. |
|
421 * @param : aTexts -- Array to hold complete text of cdata where aString was found. |
|
422 * @return: None |
|
423 */ |
|
424 /* |
|
425 void FindBBoxesForHorizontalText( const TDesC& aString, |
|
426 RArray<TRect>& aBoundingBoxes, |
|
427 RArray<TPtrC>& aTexts, |
|
428 RArray<TInt>& aElementIds, |
|
429 TBool aCaseSensitive ); |
|
430 */ |
|
431 /** |
|
432 * Get all the bounding-boxes for the given text and the contexts include |
|
433 * the text was found. The bounding-boxes are transformed, taking zooming/panning |
|
434 * in account. |
|
435 * |
|
436 * @param : aString -- String to search in the document. |
|
437 * @param : aBoundingBoxes -- Array to hold bounding-boxes info. |
|
438 * @param : aTexts -- Array to hold complete text of cdata where aString was found. |
|
439 * @return: None |
|
440 */ |
|
441 void FindBBoxesForRotatedText( const TDesC& aString, |
|
442 RPointerArray<MRect>& aBoundingBoxes, |
|
443 RArray<TPtrC>& aTexts, |
|
444 RArray<TInt>& aElementIds, |
|
445 TBool aCaseSensitive ); |
|
446 |
|
447 /** |
|
448 * Process the given coordinate to determine if it is inside/outside a |
|
449 * hyperlink; then, notify the hyperlink listeners. |
|
450 * |
|
451 * @param : aX -- x coordinate |
|
452 * @param : aY -- y coordinate |
|
453 * @return: None |
|
454 */ |
|
455 void CheckForHyperlinkMouseover( TInt aX, TInt aY ); |
|
456 |
|
457 /** |
|
458 * Add a hyperlink listener. |
|
459 * |
|
460 * @param : aListener -- hyperlink listener |
|
461 * @param : aY -- y coordinate |
|
462 * @return: None |
|
463 */ |
|
464 void AddHyperlinkListener( MSvgHyperlinkListener* aListener ); |
|
465 |
|
466 /** |
|
467 * Add a textbox listener. |
|
468 * |
|
469 * @param : aListener -- textbox listener |
|
470 * @return: None |
|
471 */ |
|
472 void AddTextAreaListener( MSvgTextAreaListener* aListener ); |
|
473 |
|
474 /** |
|
475 * Remove a textbox listener. |
|
476 * |
|
477 * @param : aListener -- textbox listener |
|
478 * @return: None |
|
479 */ |
|
480 void RemoveTextAreaListener( MSvgTextAreaListener* aListener ); |
|
481 |
|
482 void NotifyTextAreaEntered( CSvgTextAreaElementImpl* aTextAreaElement ); |
|
483 |
|
484 void NotifyTextAreaExited( CSvgTextAreaElementImpl* aTextAreaElement ); |
|
485 |
|
486 void AddTextListener( MSvgTextListener* aListener ); |
|
487 |
|
488 void RemoveTextListener( MSvgTextListener* aListener ); |
|
489 |
|
490 void NotifyTextEntered( CSvgTextElementImpl* aTextElement ); |
|
491 |
|
492 void NotifyTextExited( CSvgTextElementImpl* aTextElement ); |
|
493 |
|
494 /** |
|
495 * Add an interactive element listener. |
|
496 * @since v3.2 |
|
497 * @param : aListener - interactive element listener |
|
498 * @return: None |
|
499 */ |
|
500 void AddInteractiveElementListener( MSvgInteractiveElementListener* aListener ); |
|
501 |
|
502 /** |
|
503 * Notify the client when the pointer enters an interactive element. |
|
504 * @since v3.2 |
|
505 * @param : aElement - The element which has some animation |
|
506 * @return: None |
|
507 */ |
|
508 void NotifyInteractiveElementEntered(CSvgElementImpl* aElement); |
|
509 |
|
510 /** |
|
511 * Notify the client when the pointer exists an interactive element. |
|
512 * @since v3.2 |
|
513 * @param : aElement - The element which has some animation |
|
514 * @return: None |
|
515 */ |
|
516 void NotifyInteractiveElementExited(CSvgElementImpl* aElement); |
|
517 |
|
518 /** |
|
519 * Remove an interactive element listener. |
|
520 * @since v3.2 |
|
521 * @param : aListener - interactive element listener |
|
522 * @return: None |
|
523 */ |
|
524 void RemoveInteractiveElementListener( MSvgInteractiveElementListener* aListener ); |
|
525 |
|
526 /** |
|
527 * Add a hyperlink listener. |
|
528 * |
|
529 * @param : aListener -- hyperlink listener |
|
530 * @param : aY -- y coordinate |
|
531 * @return: None |
|
532 */ |
|
533 void RemoveHyperlinkListener( MSvgHyperlinkListener* aListener ); |
|
534 |
|
535 void NotifyElementActivatedLinkEntered( CSvgElementImpl* aElement); |
|
536 |
|
537 void NotifyElementActivatedLinkExited( CSvgElementImpl* aElement); |
|
538 /** |
|
539 * Add a hyperlink listener. |
|
540 * |
|
541 * @param : aListener -- hyperlink listener |
|
542 * @param : aY -- y coordinate |
|
543 * @return: None |
|
544 */ |
|
545 void AddAnimationListener( MSvgAnimationListener* aListener ); |
|
546 |
|
547 /** |
|
548 * Add a hyperlink listener. |
|
549 * |
|
550 * @param : aListener -- hyperlink listener |
|
551 * @param : aY -- y coordinate |
|
552 * @return: None |
|
553 */ |
|
554 void RemoveAnimationListener( MSvgAnimationListener* aListener ); |
|
555 |
|
556 void NotifyAnimationStarted(); |
|
557 |
|
558 void NotifyAnimationPaused(); |
|
559 |
|
560 void NotifyAnimationEnded(); |
|
561 |
|
562 //ViewPort Listener |
|
563 void GetViewPort(TInt getWidth, TInt getHeight, TBool isWidthInPer, TBool isHeightInPer, TInt &setWidth, TInt &setHeight); |
|
564 |
|
565 // Return ETrue if the given element (id) is visible on the frame buffer. |
|
566 TBool IsElementVisible( TInt aElementId ); |
|
567 |
|
568 /** |
|
569 * Get Size |
|
570 * |
|
571 * @since 1.0 |
|
572 * @param None |
|
573 * @return None |
|
574 */ |
|
575 TSize GetSize(); |
|
576 /** |
|
577 * Need method description |
|
578 * |
|
579 * @since 1.0 |
|
580 * @param |
|
581 * @return |
|
582 */ |
|
583 void UpdatePresentation(const TInt32& aParam); |
|
584 |
|
585 /** |
|
586 * Return the data pointed to by the given URI string, |
|
587 * from an external source. Calling client takes ownership |
|
588 * of returned HBufC8 pointer. |
|
589 * |
|
590 * @since 1.0 |
|
591 * @param |
|
592 * @return |
|
593 */ |
|
594 HBufC8* FetchExternalDataL( const TDesC& aUri ); |
|
595 |
|
596 |
|
597 void AddViewPortListener(MSvgViewPortListener* aListener); |
|
598 |
|
599 void RemoveViewPortListener(MSvgViewPortListener* aListener); |
|
600 |
|
601 /** |
|
602 * This method sets the volume with user input as a percentage |
|
603 * value (unsigned between 0 and 100 ) for the currently loaded |
|
604 * document |
|
605 * |
|
606 * @since S60 3.1 |
|
607 * @param aPercentage percentage value of volume |
|
608 * @return none |
|
609 */ |
|
610 void SetAudioVolume( TInt aPercentage ); |
|
611 TBool IsSVGEnginePaused(); |
|
612 |
|
613 void SetBitmapHeader(const TDesC* aHeaderData); |
|
614 public: // Functions from base classes |
|
615 // From CSvgElementImpl |
|
616 /** |
|
617 * Process various events received by the client for the SVG image |
|
618 * |
|
619 * @since 1.0 |
|
620 * @param aSvgDocument Pointer to the SVG Document on which event is |
|
621 * to be processed. |
|
622 * @param aEvent - Pointer to the object that contains SVG event information (implements MSvgEvent interface) |
|
623 * @return None |
|
624 */ |
|
625 void ProcessEventL( CSvgDocumentImpl* aSvgDocument, MSvgEvent* aEvent, |
|
626 TBool aRedraw = ETrue ); |
|
627 |
|
628 /** |
|
629 * Returns false only when document was loaded/prepared with in thumbnail mode |
|
630 * and the frame buffer is larger than 80x80 |
|
631 * Probably move 80x80 size to .mmp file (compiler option) |
|
632 * |
|
633 * @since 1.0 |
|
634 * @return EFalse if thumb nail restrictions apply to the current document. |
|
635 */ |
|
636 TBool PassesThumbNailRestriction(); |
|
637 |
|
638 /** |
|
639 * Obtain a font source embedded within an SVG source |
|
640 * |
|
641 * @since 1.0 |
|
642 * @param aUri - A string buffer with the URI of the font source |
|
643 * @param aFileHandle |
|
644 * @return ETrue - Success, EFalse - Failure |
|
645 * |
|
646 */ |
|
647 TBool FetchFont( const TDesC& aUri, RFs& aSession, RFile& aFileHandle ); |
|
648 |
|
649 /** |
|
650 * Set to ETrue to ignore notification to UpdateScreen in RequestObserver |
|
651 * |
|
652 * @param : aBool -- flag to indicate ignore UpdateScreen call |
|
653 * @return: None |
|
654 */ |
|
655 void SetIgnoreUpdateScreen( TBool aBool ); |
|
656 |
|
657 /** |
|
658 * Add a MSvgMouseListener to this SvgEngine |
|
659 * |
|
660 * @param : aListener -- listener to add to listener list |
|
661 * @return: None |
|
662 */ |
|
663 void AddMouseListener( const MSvgMouseListener* aListener ); |
|
664 |
|
665 /** |
|
666 * Remove a MSvgMouseListener to this SvgEngine |
|
667 * |
|
668 * @param : aListener -- listener to remove from listener list |
|
669 * @return: None |
|
670 */ |
|
671 void RemoveMouseListener( const MSvgMouseListener* aListener ); |
|
672 |
|
673 /** |
|
674 * Return number of mouselisteners. |
|
675 * |
|
676 * @return: mouse-listener count |
|
677 */ |
|
678 TInt MouseListenerCount(); |
|
679 |
|
680 /** |
|
681 * Return the (first) viewable element at the given point. |
|
682 * visible svg element. |
|
683 * |
|
684 * @param : aElements -- list to contain viewable elements with bounding-boxes containing |
|
685 * the given point. |
|
686 * @param : aX -- x coordinate |
|
687 * @param : aY -- y coordinate |
|
688 * @return: NULL, if none, lowest-level element containing point. |
|
689 */ |
|
690 void GetViewableElementsAtPoint(CSvgDocumentImpl* aSvgDocument, RPointerArray<CSvgElementImpl>& aElements, TInt aX, TInt aY ); |
|
691 |
|
692 /** |
|
693 * Find all elements in the subtree for "viewable" elements, including the given |
|
694 * starting node element. Viewable element are concrete elements that are drawn, |
|
695 * such as <rect>, <circle>, <path>, etc. |
|
696 * This function only checks for containing of the elements' bounding-boxes. |
|
697 * |
|
698 * @param : aStartElement -- starting node to search in subtree. |
|
699 * @param : aElementList -- List to containing "viewable" elements. |
|
700 * @return: None |
|
701 */ |
|
702 void FindAllViewableElements( CSvgElementImpl* aStartElement, RPointerArray<CSvgElementImpl>& iElementList ); |
|
703 |
|
704 /** |
|
705 * Find all elements in the subtree for non-viewable elements, including the given |
|
706 * starting node element. Viewable element are abstract elements that are not drawn, |
|
707 * such as <g>, <animate>, <animateMotion>, etc. |
|
708 * |
|
709 * @param : aStartElement -- starting node to search in subtree. |
|
710 * @param : aElementList -- List to containing non-viewable elements. |
|
711 * @return: None |
|
712 */ |
|
713 void FindAllNonViewableElements( CSvgElementImpl* aStartElement, RPointerArray<CSvgElementImpl>& iElementList ); |
|
714 |
|
715 /** |
|
716 * Send to mouse listeners of a mouse-pressed event. |
|
717 * |
|
718 * @param : aElements -- elements affected by mouse-event. |
|
719 * @param : aX -- X-cooordinate of mouse-event. |
|
720 * @param : aY -- X-cooordinate of mouse-event. |
|
721 * @return: None |
|
722 */ |
|
723 void NotifyMousePressed( RPointerArray<CSvgElementImpl>& aElements, |
|
724 TInt aX, TInt aY ); |
|
725 |
|
726 /** |
|
727 * Send to mouse listeners of a mouse-released event. |
|
728 * |
|
729 * @param : aElements -- elements affected by mouse-event. |
|
730 * @param : aX -- X-cooordinate of mouse-event. |
|
731 * @param : aY -- X-cooordinate of mouse-event. |
|
732 * @return: None |
|
733 */ |
|
734 void NotifyMouseReleased( RPointerArray<CSvgElementImpl>& aElements, |
|
735 TInt aX, TInt aY ); |
|
736 |
|
737 /** |
|
738 * Send to mouse listeners of a mouse-entered event. |
|
739 * |
|
740 * @param : aElements -- elements affected by mouse-event. |
|
741 * @param : aX -- X-cooordinate of mouse-event. |
|
742 * @param : aY -- X-cooordinate of mouse-event. |
|
743 * @return: None |
|
744 */ |
|
745 void NotifyMouseEntered( RPointerArray<CSvgElementImpl>& aElements, |
|
746 TInt aX, TInt aY ); |
|
747 /** |
|
748 * Send to mouse listeners of a mouse-exited event. |
|
749 * |
|
750 * @param : aElements -- elements affected by mouse-event. |
|
751 * @param : aX -- X-cooordinate of mouse-event. |
|
752 * @param : aY -- X-cooordinate of mouse-event. |
|
753 * @return: None |
|
754 */ |
|
755 void NotifyMouseExited( RPointerArray<CSvgElementImpl>& aElements, |
|
756 TInt aX, TInt aY ); |
|
757 |
|
758 /** |
|
759 * Send to mouse listeners of a mouse-moved event. |
|
760 * |
|
761 * @param : aElements -- elements affected by mouse-event. |
|
762 * @param : aX -- X-cooordinate of mouse-event. |
|
763 * @param : aY -- X-cooordinate of mouse-event. |
|
764 * @return: None |
|
765 */ |
|
766 void NotifyMouseMoved( RPointerArray<CSvgElementImpl>& aElements, |
|
767 TInt aX, TInt aY ); |
|
768 |
|
769 void NotifyHyperlinkEntered( CSvgAElementImpl* aAElementHandle ); |
|
770 void NotifyHyperlinkEntered( const TDesC& aUri ); |
|
771 |
|
772 void NotifyHyperlinkExited( CSvgAElementImpl* aAElementHandle ); |
|
773 void NotifyHyperlinkExited( const TDesC& aUri ); |
|
774 |
|
775 void NotifyHyperlinkActivated( CSvgAElementImpl* aAElementHandle ); |
|
776 void NotifyHyperlinkActivated( const TDesC& aUri ); |
|
777 |
|
778 void NotifyHyperlinkActivatedWithShow( const TDesC& aUri, const TDesC& aShow ); |
|
779 |
|
780 void NotifyTextAreaActivated( CSvgTextAreaElementImpl* aTextArea); |
|
781 |
|
782 void NotifyTextActivated( CSvgTextElementImpl* aTextElement); |
|
783 |
|
784 |
|
785 /** |
|
786 * Returns whether engine is ready to render |
|
787 * Used by SvgTimer |
|
788 */ |
|
789 TBool ReadyToRender(); |
|
790 |
|
791 /** |
|
792 * Reset animation timer to the beginning. |
|
793 */ |
|
794 void ResetTimer(); |
|
795 |
|
796 /** |
|
797 *Save Svg File After doing the text editing |
|
798 */ |
|
799 void SaveSvgL( const TDesC& aFileName ); |
|
800 |
|
801 /* |
|
802 *Write the buffer to the stream - saving the file -svg -text editing |
|
803 */ |
|
804 TInt WriteToStream(RFileWriteStream &aStream,TPtrC aWriteBuffer); |
|
805 |
|
806 /* |
|
807 *Function to process the <text> tag and do the needful |
|
808 */ |
|
809 |
|
810 HBufC* TextTagProcessingL(TPtrC* aCData, TInt &aStartOffset, TInt aOrgLength, |
|
811 TBool aEndingWithTag); |
|
812 |
|
813 /* |
|
814 *Function to process the <textArea> tag and do the needful |
|
815 */ |
|
816 HBufC* TextAreaTagProcessingL(TPtrC* aCData, TInt &aStartOffset, TInt aOrgLength, |
|
817 TBool aEndingWithTag); |
|
818 |
|
819 void ImageLoadingCompleted( TInt /*aErrorStatus*/ ); |
|
820 /* |
|
821 * Function used to set the Rendering Quality |
|
822 */ |
|
823 |
|
824 void SetRenderingQuality( const TInt32 aRenderQuality); |
|
825 void CSvgEngineImpl::ResetContext(); |
|
826 |
|
827 private: |
|
828 |
|
829 /** |
|
830 * Private constructor |
|
831 * |
|
832 * @since 1.0 |
|
833 * @return |
|
834 */ |
|
835 CSvgEngineImpl(); |
|
836 |
|
837 /** |
|
838 * Private constructor |
|
839 * |
|
840 * @since 1.0 |
|
841 * @param aFrameBuffer - Pointer to a buffer where the SVG document raster is drawn |
|
842 * @param aReqObserver - Pointer to a client side object that implements the MSvgRequestObserver interface |
|
843 * @return |
|
844 */ |
|
845 CSvgEngineImpl( CFbsBitmap* aFrameBuffer, |
|
846 MSvgRequestObserver* aReqObserver ); |
|
847 |
|
848 /** |
|
849 * A private constructor that constructs heap objects |
|
850 * |
|
851 * @since 1.0 |
|
852 * @param None |
|
853 * @return None |
|
854 */ |
|
855 void ConstructL(TFontSpec& aFontSpec, CSvgBitmapFontProvider *aSvgBitmapFontProvider ); |
|
856 |
|
857 void ConstructL(TFontSpec& aFontSpec, CSvgBitmapFontProvider *aSvgBitmapFontProvider,SVGRendererId aRendererType ); |
|
858 // |
|
859 void InitializeEventReceiverListL(CSvgElementImpl *aElement); |
|
860 |
|
861 /** |
|
862 * Initiate the process of opening embedded links in the SVG source |
|
863 * |
|
864 * @since 1.0 |
|
865 * @param None |
|
866 * @return None |
|
867 */ |
|
868 void DoHyperLinkingL(); |
|
869 |
|
870 /** |
|
871 * FInd out whether a given element is animation type |
|
872 * |
|
873 * @since 1.0 |
|
874 * @param aElement - A pointer to an element |
|
875 * @return Boolean returning a True/False |
|
876 */ |
|
877 TBool IsAnimationElement( CSvgElementImpl* aElement ); |
|
878 |
|
879 /** |
|
880 * A complex method that does color calculations for anti aliasing |
|
881 * |
|
882 * @since 1.0 |
|
883 * @param None |
|
884 * @return None |
|
885 */ |
|
886 void FilteredBlitXRGB4444() const; |
|
887 |
|
888 /** |
|
889 * A complex method that does color calculations for anti aliasing |
|
890 * |
|
891 * @since 1.0 |
|
892 * @param |
|
893 * @return |
|
894 */ |
|
895 void FilteredBlitRGB565() const; |
|
896 |
|
897 |
|
898 |
|
899 // opacity set routines |
|
900 CFbsBitmap* CreateOpacityFrameBufferL(); |
|
901 void CopyBuffer( TUint32* aSrc, TUint32* aDest, const TSize aSize ); |
|
902 |
|
903 |
|
904 void FindEditableElements( CSvgElementImpl* aStartElement, |
|
905 RPointerArray<CSvgElementImpl>& aList ); |
|
906 //for SaveSvgL |
|
907 TBool IsEndedWithCompleteTextTag(TDes &bufferptr,TInt EndOffset); |
|
908 |
|
909 public: |
|
910 CSvgElementImpl* iTextAreaHandle; |
|
911 |
|
912 RPointerArray<TSvgFourPointRect> iSvgTextBoundingBoxes; |
|
913 |
|
914 CSvgTimer* iTimer; |
|
915 MSvgRequestObserver* iRequestObserver; |
|
916 |
|
917 CFbsBitmap* iFrameBuffer; |
|
918 CFbsBitmap* iMask; |
|
919 |
|
920 TSize iFrameBufferSize; //NGA |
|
921 TDisplayMode iRenderDspMode; |
|
922 TDisplayMode iMaskDspMode; |
|
923 TFontSpec iBitmapFontSpec; |
|
924 CSvgFontHashMap* iFontHashMap; |
|
925 private: |
|
926 |
|
927 CSvgDocumentImpl* iSvgDocument; |
|
928 CGfx2dGc* iGfxContext; |
|
929 TPtrC iLinkUri; |
|
930 TUint32 iBackgroundColor; |
|
931 TPtrC iLinkShow; |
|
932 TBool iShowDebugInfo; |
|
933 |
|
934 TGfxRectangle2D iClipRect; |
|
935 TSvgEngineState iSvgEngineState; |
|
936 TAnimStatus iAnimationState; |
|
937 TBufC<1> NullString; |
|
938 CSvgErrorImpl* iSvgError; |
|
939 // Pointer/Hyperlink related |
|
940 RPointerArray<MSvgHyperlinkListener> iHyperlinkListeners; |
|
941 RPointerArray<MSvgTextAreaListener> iTextAreaListeners; |
|
942 RPointerArray<MSvgTextListener> iTextListeners; |
|
943 CSvgElementImpl* iMouseoverElement; |
|
944 //Animation related |
|
945 RPointerArray<MSvgAnimationListener> iAnimationListeners; |
|
946 |
|
947 //ViewPort |
|
948 MSvgViewPortListener* iViewPortListener; |
|
949 // MSvgMouseListener list |
|
950 RPointerArray<MSvgMouseListener> iSvgMouseListeners; |
|
951 |
|
952 //MSvgInteractiveElementListener list |
|
953 RPointerArray<MSvgInteractiveElementListener> iInteractiveElementListeners; |
|
954 |
|
955 // flag to prevent calling updatescreen (when ETrue) |
|
956 TBool iIgnoreUpdateScreen; |
|
957 |
|
958 TUint iTimeoutSeconds; |
|
959 TInt iRenderQuality; // Rendering Quality |
|
960 |
|
961 //Stores Font Type information as passed by CSvgEngineInterfaceImpl |
|
962 CSvgBitmapFontProvider *iSvgBitmapFontProvider; |
|
963 public: |
|
964 TBool iCustomOption; |
|
965 TBool iFrameBufferOverridesViewport; |
|
966 TBool iClientDefinedViewPort; |
|
967 CDesC16ArrayFlat* iSvgNames; |
|
968 }; |
|
969 |
|
970 #endif //__INC_CSVGENGINEIMPL__ |