|
1 /* |
|
2 * Copyright (c) 2005-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: Render context |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CM2GRENDERCONTEXT_H |
|
19 #define CM2GRENDERCONTEXT_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <fbs.h> |
|
23 #include "MM2GRenderContext.h" |
|
24 #include <graphics.h> |
|
25 |
|
26 class CSvgtBitmap; |
|
27 |
|
28 M2G_NS_START |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // DATA TYPES |
|
35 |
|
36 // FUNCTION PROTOTYPES |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class MM2GSVGProxy; |
|
40 class CBitmapContext; |
|
41 #ifdef RD_JAVA_NGA_ENABLED |
|
42 class MMIDCanvas; |
|
43 #endif // RD_JAVA_NGA_ENABLED |
|
44 |
|
45 // CLASS DECLARATION |
|
46 /** |
|
47 * Render context |
|
48 */ |
|
49 |
|
50 |
|
51 class CM2GRenderContext : public CBase, public MM2GRenderContext |
|
52 { |
|
53 private: // METHODS |
|
54 /** |
|
55 * C++ default constructor. |
|
56 */ |
|
57 CM2GRenderContext(); |
|
58 |
|
59 /** |
|
60 * C++ copy constructor |
|
61 */ |
|
62 CM2GRenderContext(const CM2GRenderContext&); |
|
63 |
|
64 /** |
|
65 * C++ assignment operator |
|
66 */ |
|
67 CM2GRenderContext& operator=(const CM2GRenderContext&); |
|
68 |
|
69 /** |
|
70 * Initialization |
|
71 */ |
|
72 void ConstructL(MM2GSVGProxy* aProxy); |
|
73 |
|
74 public: // METHODS |
|
75 /** |
|
76 * Two-phased constructor. |
|
77 */ |
|
78 static CM2GRenderContext* NewL(MM2GSVGProxy* aProxy); |
|
79 |
|
80 /** |
|
81 * Destructor. |
|
82 */ |
|
83 virtual ~CM2GRenderContext(); |
|
84 |
|
85 /** |
|
86 * @see MM2GRenderContext::BindL() |
|
87 */ |
|
88 virtual void BindL(TInt& aGraphicsHandle); |
|
89 |
|
90 /** |
|
91 * @see MM2GRenderContext::InitImageBitmapL() |
|
92 */ |
|
93 virtual void InitImageBitmapL(); |
|
94 |
|
95 /** |
|
96 * @see MM2GRenderContext::BlitToL() |
|
97 */ |
|
98 virtual void ReleaseL(); |
|
99 |
|
100 /** |
|
101 * @see MM2GRenderContext::RenderL() |
|
102 */ |
|
103 virtual void RenderLCDUIL( |
|
104 TM2GSvgDocumentHandle& aSvgDocumentHandle, |
|
105 const TReal32 aCurrentTime, |
|
106 TInt aSvgW, TInt aSvgH, |
|
107 TM2GRenderRect& aRect); |
|
108 virtual void RenderESWTL( |
|
109 TM2GSvgDocumentHandle& aSvgDocHandle, |
|
110 const TReal32 aCurrentTime, |
|
111 TInt aSvgW, TInt aSvgH, |
|
112 TM2GRenderRect& aRect, |
|
113 TBool aUseNativeClear, |
|
114 TInt* aReturnData); |
|
115 |
|
116 /** |
|
117 * @see MM2GRenderContext::SetRenderingQualityL() |
|
118 */ |
|
119 virtual void SetRenderingQualityL(TInt aMode); |
|
120 |
|
121 /** |
|
122 * @see MM2GRenderContext::SetTransparency() |
|
123 */ |
|
124 virtual void SetTransparency(TReal32 aAlpha); |
|
125 |
|
126 |
|
127 TInt SaveBitmapL(const CFbsBitmap& aNVGBitmap, const TFileName& aFileName); |
|
128 protected: // METHODS |
|
129 /** |
|
130 * Get the image's bitmap handle |
|
131 * |
|
132 * @return Svg surface handle. |
|
133 * @throws Exception if not ok. |
|
134 */ |
|
135 TM2GBitmapHandle GetImgHandleL() const; |
|
136 |
|
137 private: |
|
138 /** |
|
139 * Prepare viewbox and anchor |
|
140 * |
|
141 * @param aRr clip area information |
|
142 * @return aViewbox render rectangle area |
|
143 * @return aAnchor recalculated anchor point |
|
144 */ |
|
145 void PrepareViewbox( |
|
146 TM2GRenderRect& aRr, |
|
147 TInt aSvgW, TInt aSvgH, |
|
148 TRect& aViewbox, TPoint& aAnchor); |
|
149 |
|
150 /** |
|
151 * Renders a SVG document at a current time. |
|
152 * |
|
153 * <p> The rendering is done in 2 steps: |
|
154 * <li> render the document on an internal SVG buffer (iSvg) |
|
155 * <li> alpha-blend it with the bound graphics target (iGraphicsBitmap) |
|
156 * |
|
157 * @note if transparency factor is not set, iSvg is simply blitted onto iGraphicsTarget |
|
158 * |
|
159 * @param aSvgDocumentHandle handle to SVG document |
|
160 * @param aCurrentTime the current time of the animation |
|
161 * @param aSvgW Svg image viewport width |
|
162 * @param aSvgH Svg image viewport height |
|
163 * @param aRect contains position about the rendered area |
|
164 * @param aAnchor anchor point |
|
165 * |
|
166 * @since S60 3.1 |
|
167 */ |
|
168 void RenderLCDUIL( |
|
169 TM2GSvgDocumentHandle& aSvgDocumentHandle, |
|
170 const TReal32 aCurrentTime, |
|
171 const TRect& aViewbox, |
|
172 const TPoint& aAnchor); |
|
173 |
|
174 void RenderESWTL( |
|
175 TM2GSvgDocumentHandle& aSvgDocHandle, |
|
176 TReal32 aCurrentTime, |
|
177 const TRect& aViewbox, |
|
178 const TPoint& aAnchor, |
|
179 TBool aUseNativeClear, |
|
180 TInt* aReturnData); |
|
181 |
|
182 /** |
|
183 * Clear the bitmap with 0 |
|
184 * Fills all pixel with 0 value |
|
185 * |
|
186 * @param aBmp the bitmap to be filled |
|
187 */ |
|
188 void CM2GRenderContext::ClearBitmapL(CFbsBitmap* aBmp); |
|
189 |
|
190 /** |
|
191 * Fills all the pixels of a bitmap with a specific byte |
|
192 * |
|
193 * @param aBmp the bitmap to be filled |
|
194 * @param aChar the character(byte) to fill with |
|
195 */ |
|
196 void FillBitmapL(CFbsBitmap* aBmp, const TUint8& aChar); |
|
197 |
|
198 |
|
199 private: // VARIABLES |
|
200 |
|
201 //For WindowsSurface CFbsBitmap || Qimage |
|
202 Java::GFX::WindowSurface* iWindowSurface; |
|
203 |
|
204 |
|
205 MM2GSVGProxy* iProxy; |
|
206 |
|
207 TM2GSvgEngineHandle iEngineHandle; |
|
208 |
|
209 TReal32 iAlpha; |
|
210 TUint8 iScaledAlpha; |
|
211 |
|
212 //for eswt compatibility |
|
213 CFbsBitmap* iImgBmp; |
|
214 RFbsSession iFbsSession; |
|
215 |
|
216 |
|
217 // Temporary buffer ( offscreen ) for QImage support |
|
218 QImage* iOffScreenQImage; |
|
219 CFbsBitmap* iOffScreenBitmap; |
|
220 |
|
221 QImage* iTargetQImage; |
|
222 |
|
223 Java::GFX::WindowSurfaceType wSurfaceType; |
|
224 CSvgtBitmap * targetBitmap; |
|
225 |
|
226 CFbsBitmap* tempBitmapForMask ; |
|
227 |
|
228 protected: |
|
229 TM2GSvgBitmapHandle GetBufferHandleL() const; |
|
230 void InitializeQImageOffscreenBufferL(TSize aScreenSize,QImage* aQimage); |
|
231 void InitializeCFbsBitmapOffscreenBufferL(TSize aScreenSize,CFbsBitmap* aBitmap); |
|
232 void ClearSurfaceL(TM2GSvgBitmapHandle aSvgtBmpHandle); |
|
233 private: |
|
234 |
|
235 }; |
|
236 /*----------------------------------------------------------- |
|
237 class : CFbsBitmapHack |
|
238 purpose: Class is provided as a solution for double render |
|
239 issue in eSWT |
|
240 *-----------------------------------------------------------*/ |
|
241 class CFbsBitmapHack : public CFbsBitmap |
|
242 { |
|
243 public: |
|
244 TInt GetMyHandle() |
|
245 { |
|
246 return iHandle; |
|
247 } |
|
248 }; |
|
249 |
|
250 |
|
251 M2G_NS_END |
|
252 #endif // CM2GRENDERCONTEXT_H |