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