80
|
1 |
/*
|
87
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
80
|
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: JNI methods
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include "com_nokia_microedition_m2g_M2GScalableGraphics.h"
|
|
20 |
#include "CM2GRenderContext.h"
|
|
21 |
#include "MM2GSVGProxy.h" // TM2GRenderRect
|
|
22 |
#include <graphics.h>
|
|
23 |
|
|
24 |
M2G_NS_START
|
|
25 |
#include "M2GUtils.h"
|
|
26 |
|
|
27 |
// EXTERNAL DATA STRUCTURES
|
|
28 |
|
|
29 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
30 |
|
|
31 |
// CONSTANTS
|
|
32 |
|
|
33 |
// MACROS
|
|
34 |
|
|
35 |
// LOCAL CONSTANTS AND MACROS
|
|
36 |
|
|
37 |
// MODULE DATA STRUCTURES
|
|
38 |
|
|
39 |
// LOCAL FUNCTION PROTOTYPES
|
|
40 |
|
|
41 |
// FORWARD DECLARATIONS
|
|
42 |
|
|
43 |
// CLASS DECLARATION
|
|
44 |
|
|
45 |
// ================================ FUNCTIONS ==================================
|
|
46 |
|
|
47 |
// -----------------------------------------------------------------------------
|
|
48 |
// Java_com_nokia_microedition_m2g_M2GScalableGraphics::_bind
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
/**
|
|
51 |
* Calls MM2GRenderContext::BindL method.
|
|
52 |
* @since Series S60 3.0
|
|
53 |
* @param aRenderContextHandle Render context handle.
|
|
54 |
* @param aTargetHandle Target graphics handle
|
|
55 |
* @throws exception if not ok
|
|
56 |
*/
|
|
57 |
|
|
58 |
JNIEXPORT jint JNICALL
|
|
59 |
Java_com_nokia_microedition_m2g_M2GScalableGraphics__1bind(
|
|
60 |
JNIEnv* aJni,
|
|
61 |
jobject,
|
|
62 |
jint aRenderContextHandle,
|
87
|
63 |
jint aTargetHandle)
|
80
|
64 |
{
|
|
65 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _bind - begin");
|
87
|
66 |
|
80
|
67 |
TInt err = KM2GNotOk;
|
87
|
68 |
|
80
|
69 |
M2G_DO_LOCK
|
87
|
70 |
|
80
|
71 |
if (aRenderContextHandle)
|
87
|
72 |
{
|
80
|
73 |
MM2GRenderContext* rc = JavaUnhand<MM2GRenderContext>(aRenderContextHandle);
|
|
74 |
TRAP(err,rc->BindL(aTargetHandle););
|
87
|
75 |
}
|
80
|
76 |
|
|
77 |
M2G_DO_UNLOCK(aJni)
|
87
|
78 |
|
80
|
79 |
M2GGeneral::CheckErrorCode(aJni, err);
|
|
80 |
M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GScalableGraphics ) _bind: %d - end", err);
|
|
81 |
|
87
|
82 |
return err;
|
80
|
83 |
}
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
// Java_com_nokia_microedition_m2g_M2GScalableGraphics::_createRenderContext
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
/**
|
|
91 |
* Calls MM2GRenderContext::NewL method.
|
|
92 |
* @since Series S60 3.0
|
|
93 |
* @param aSvgProxyHandle Proxy instance.
|
|
94 |
* @param aHandle Render context handle.
|
|
95 |
* @throws exception if not ok
|
|
96 |
*/
|
|
97 |
|
|
98 |
JNIEXPORT jint JNICALL
|
|
99 |
Java_com_nokia_microedition_m2g_M2GScalableGraphics__1createRenderContext(
|
|
100 |
JNIEnv* aJni,
|
|
101 |
jobject,
|
87
|
102 |
jint aSvgProxyHandle)
|
80
|
103 |
{
|
|
104 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _createRenderContext - begin");
|
|
105 |
TInt handle = M2G_INVALID_HANDLE;
|
|
106 |
TInt err = KM2GNotOk;
|
87
|
107 |
|
80
|
108 |
M2G_DO_LOCK
|
87
|
109 |
|
80
|
110 |
if (aSvgProxyHandle)
|
87
|
111 |
{
|
|
112 |
TRAP(err, MM2GRenderContext* rchandle = CM2GRenderContext::NewL(JavaUnhand<MM2GSVGProxy> (aSvgProxyHandle)); handle = JavaMakeHandle(rchandle););
|
|
113 |
}
|
80
|
114 |
M2G_DO_UNLOCK(aJni)
|
87
|
115 |
|
80
|
116 |
handle = M2GGeneral::CheckErrorCodeAndHandle(aJni, err, handle, err);
|
|
117 |
|
|
118 |
M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GScalableGraphics ) _createRenderContext: %d - end", handle);
|
|
119 |
|
|
120 |
return handle;
|
|
121 |
}
|
|
122 |
|
|
123 |
// -----------------------------------------------------------------------------
|
|
124 |
// Java_com_nokia_microedition_m2g_M2GScalableGraphics::_deleteRenderContext
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
/**
|
|
127 |
* Class: com_nokia_microedition_m2g_M2GScalableGraphics
|
|
128 |
* Method: deleteRenderContext
|
|
129 |
* Signature:
|
|
130 |
*/
|
|
131 |
JNIEXPORT void JNICALL
|
|
132 |
Java_com_nokia_microedition_m2g_M2GScalableGraphics__1deleteRenderContext(
|
|
133 |
JNIEnv* aJni,
|
|
134 |
jobject,
|
|
135 |
jint aRenderContextHandle)
|
|
136 |
{
|
|
137 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _deleteRenderContext - begin");
|
87
|
138 |
|
80
|
139 |
M2G_DO_LOCK
|
87
|
140 |
|
80
|
141 |
if (aRenderContextHandle)
|
87
|
142 |
{
|
80
|
143 |
MM2GRenderContext* rc = JavaUnhand<MM2GRenderContext>(aRenderContextHandle);
|
|
144 |
delete rc;
|
87
|
145 |
}
|
80
|
146 |
M2G_DO_UNLOCK(aJni)
|
87
|
147 |
|
80
|
148 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _deleteRenderContext - end");
|
|
149 |
}
|
|
150 |
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
// Java_com_nokia_microedition_m2g_M2GScalableGraphics::_release
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
/**
|
|
155 |
* Calls MM2GRenderContext::ReleaseL method.
|
|
156 |
* @since Series S60 3.0
|
|
157 |
* @param aRenderContextHandle Context handle
|
|
158 |
* @return KM2GOk if ok
|
|
159 |
*/
|
|
160 |
|
|
161 |
JNIEXPORT jint JNICALL
|
|
162 |
Java_com_nokia_microedition_m2g_M2GScalableGraphics__1release(
|
|
163 |
JNIEnv* aJni,
|
|
164 |
jobject,
|
87
|
165 |
jint /*aSurfaceHandle*/,
|
80
|
166 |
jint aRenderContextHandle)
|
|
167 |
{
|
87
|
168 |
|
80
|
169 |
// Release used target surface
|
|
170 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _release - begin");
|
|
171 |
TInt err = KM2GNotOk;
|
|
172 |
M2G_DO_LOCK
|
87
|
173 |
|
80
|
174 |
if (aRenderContextHandle)
|
87
|
175 |
{
|
80
|
176 |
MM2GRenderContext* rc = JavaUnhand<MM2GRenderContext>(aRenderContextHandle);
|
|
177 |
TRAP(err,rc->ReleaseL(););
|
87
|
178 |
}
|
|
179 |
M2G_DO_UNLOCK(aJni)
|
|
180 |
|
80
|
181 |
M2GGeneral::CheckErrorCode(aJni, err);
|
87
|
182 |
|
|
183 |
return err;
|
|
184 |
|
80
|
185 |
}
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
// Java_com_nokia_microedition_m2g_M2GScalableGraphics::_render
|
|
188 |
// -----------------------------------------------------------------------------
|
|
189 |
/**
|
|
190 |
* Calls MM2GRenderContext::RenderL method.
|
|
191 |
* @since Series S60 3.0
|
|
192 |
* @param aRenderContextHandle Context handle
|
|
193 |
* @param aDocumentHandle Document handle.
|
|
194 |
* @param aSvgW Svg width.
|
|
195 |
* @param aSvgH Svg heigth.
|
|
196 |
* @param aCurrentTime Current time.
|
|
197 |
* @throws Exception if not ok
|
|
198 |
*/
|
|
199 |
|
|
200 |
JNIEXPORT jint JNICALL
|
|
201 |
Java_com_nokia_microedition_m2g_M2GScalableGraphics__1renderLCDUI(
|
|
202 |
JNIEnv* aJni,
|
|
203 |
jobject,
|
|
204 |
jint aRenderContextHandle,
|
|
205 |
jint aDocumentHandle,
|
|
206 |
jint aX, jint aY,
|
|
207 |
jint aClipX, jint aClipY, jint aClipW, jint aClipH,
|
|
208 |
jint aSvgW, jint aSvgH,
|
|
209 |
jfloat aCurrentTime)
|
|
210 |
{
|
|
211 |
M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GScalableGraphics ) _render, time:%f - begin", aCurrentTime);
|
|
212 |
|
|
213 |
TM2GRenderRect rr(aX, aY, aClipX, aClipY, aClipW, aClipH);
|
|
214 |
TInt err = KM2GNotOk;
|
|
215 |
|
|
216 |
M2G_DO_LOCK
|
87
|
217 |
|
80
|
218 |
if (aRenderContextHandle && aDocumentHandle)
|
87
|
219 |
{
|
|
220 |
MM2GRenderContext* rc = JavaUnhand<MM2GRenderContext>(aRenderContextHandle);
|
|
221 |
TRAP(err,rc->RenderLCDUIL(aDocumentHandle, aCurrentTime, aSvgW, aSvgH, rr););
|
|
222 |
}
|
80
|
223 |
M2G_DO_UNLOCK(aJni)
|
87
|
224 |
|
|
225 |
M2GGeneral::CheckErrorCode(aJni, err);
|
80
|
226 |
M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GScalableGraphics ) _render: %d - end", err);
|
|
227 |
return err;
|
|
228 |
}
|
|
229 |
|
|
230 |
|
|
231 |
JNIEXPORT jintArray JNICALL
|
|
232 |
Java_com_nokia_microedition_m2g_M2GScalableGraphics__1renderESWT(
|
|
233 |
JNIEnv* aJni,
|
|
234 |
jobject,
|
|
235 |
jint aRenderContextHandle,
|
|
236 |
jint aDocumentHandle,
|
|
237 |
jint aX, jint aY,
|
|
238 |
jint aClipX, jint aClipY, jint aClipW, jint aClipH,
|
|
239 |
jint aSvgW, jint aSvgH,
|
|
240 |
jfloat aCurrentTime,
|
|
241 |
jint aUseNativeClear
|
|
242 |
)
|
|
243 |
{
|
|
244 |
M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GScalableGraphics ) _render, time:%f - begin", aCurrentTime);
|
|
245 |
TM2GRenderRect rr(aX, aY, aClipX, aClipY, aClipW, aClipH);
|
|
246 |
TInt err = KM2GNotOk;
|
|
247 |
jintArray returnDataJava = aJni->NewIntArray(10);
|
87
|
248 |
|
80
|
249 |
M2G_DO_LOCK
|
87
|
250 |
|
80
|
251 |
TInt returnData[10];
|
87
|
252 |
|
80
|
253 |
if (aRenderContextHandle && aDocumentHandle)
|
87
|
254 |
{
|
80
|
255 |
MM2GRenderContext* rc = JavaUnhand<MM2GRenderContext>(aRenderContextHandle);
|
87
|
256 |
TRAP(err,rc->RenderESWTL(aDocumentHandle,aCurrentTime,aSvgW,aSvgH,rr,aUseNativeClear,returnData););
|
|
257 |
}
|
80
|
258 |
M2G_DO_UNLOCK(aJni)
|
|
259 |
|
87
|
260 |
|
80
|
261 |
if (returnDataJava != NULL)
|
|
262 |
aJni->SetIntArrayRegion(returnDataJava, 0, 10, const_cast<TInt*>(returnData));
|
87
|
263 |
|
|
264 |
M2GGeneral::CheckErrorCode(aJni, err);
|
80
|
265 |
M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GScalableGraphics ) _render: %d - end", err);
|
|
266 |
return returnDataJava;
|
|
267 |
}
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
// Java_com_nokia_microedition_m2g_M2GScalableGraphics::_setRenderingQuality
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
/**
|
|
272 |
* Calls MM2GRenderContext::SetRenderingQuality method.
|
|
273 |
* @since Series S60 3.0
|
|
274 |
* @param aRenderContextHandle Context handle
|
|
275 |
* @param aMode
|
|
276 |
* @throws Exception if not ok
|
|
277 |
*/
|
|
278 |
JNIEXPORT void JNICALL
|
|
279 |
Java_com_nokia_microedition_m2g_M2GScalableGraphics__1setRenderingQuality(
|
|
280 |
JNIEnv* aJni,
|
|
281 |
jobject,
|
|
282 |
jint aRenderContextHandle, jint aMode)
|
|
283 |
{
|
|
284 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _setRenderingQuality - begin");
|
|
285 |
TInt err = KM2GNotOk;
|
87
|
286 |
|
80
|
287 |
M2G_DO_LOCK
|
87
|
288 |
|
|
289 |
if (aRenderContextHandle)
|
|
290 |
{
|
80
|
291 |
MM2GRenderContext* rc = JavaUnhand<MM2GRenderContext>(aRenderContextHandle);
|
|
292 |
TRAP(err,rc->SetRenderingQualityL(aMode););
|
87
|
293 |
}
|
80
|
294 |
M2G_DO_UNLOCK(aJni)
|
87
|
295 |
|
80
|
296 |
M2GGeneral::CheckErrorCode(aJni, err);
|
|
297 |
|
|
298 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _setRenderingQuality - end");
|
|
299 |
}
|
|
300 |
|
|
301 |
// -----------------------------------------------------------------------------
|
|
302 |
// Java_com_nokia_microedition_m2g_M2GScalableGraphics::_setTransparency
|
|
303 |
// -----------------------------------------------------------------------------
|
|
304 |
/**
|
|
305 |
* Calls MM2GRenderContext::SetTransparency method.
|
|
306 |
* @since Series S60 3.0
|
|
307 |
* @param aRenderContextHandle Context handle
|
|
308 |
* @param aAplha -
|
|
309 |
*/
|
|
310 |
JNIEXPORT void JNICALL
|
|
311 |
Java_com_nokia_microedition_m2g_M2GScalableGraphics__1setTransparency(
|
|
312 |
JNIEnv* aJni,
|
|
313 |
jobject,
|
|
314 |
jint aRenderContextHandle,
|
|
315 |
jfloat aAlpha)
|
|
316 |
{
|
|
317 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _setTransparency - begin");
|
|
318 |
TInt err = KM2GNotOk;
|
87
|
319 |
|
80
|
320 |
M2G_DO_LOCK
|
87
|
321 |
|
80
|
322 |
if (aRenderContextHandle)
|
87
|
323 |
{
|
80
|
324 |
MM2GRenderContext* rc = JavaUnhand<MM2GRenderContext>(aRenderContextHandle);
|
87
|
325 |
TRAP(err,rc->SetTransparency((TReal32)aAlpha););
|
|
326 |
}
|
80
|
327 |
M2G_DO_UNLOCK(aJni)
|
87
|
328 |
|
80
|
329 |
M2GGeneral::CheckErrorCode(aJni, err);
|
|
330 |
|
|
331 |
M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GScalableGraphics ) _setTransparency - end");
|
|
332 |
}
|
|
333 |
|
|
334 |
M2G_NS_END
|
|
335 |
|
|
336 |
|
|
337 |
|