|
1 /******************************************************************************* |
|
2 * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - initial API and implementation |
|
10 *******************************************************************************/ |
|
11 #include <QFont> |
|
12 #include <QFontMetrics> |
|
13 #include <QSharedDataPointer> |
|
14 #include <QByteArray> |
|
15 #include <QBuffer> |
|
16 #include <QImageReader> |
|
17 #include <QSize> |
|
18 #include <QSvgRenderer> |
|
19 |
|
20 #include <org_eclipse_swt_internal_qt_graphics_OS.h> |
|
21 #include "graphics.h" |
|
22 #include "gfxlog.h" |
|
23 #include "jniutils.h" |
|
24 #include "swtapplication.h" |
|
25 #include "autorelease.h" |
|
26 #include "gfxutils.h" |
|
27 |
|
28 using namespace Java::GFX; |
|
29 |
|
30 #define POINTER_TO_HANDLE(pointer) reinterpret_cast<jint>( pointer ) |
|
31 #define HANDLE_TO_POINTER(type, variable, handle) type variable = reinterpret_cast<type>( handle ) |
|
32 #define ARRAY_CAST(type, variable) reinterpret_cast<type>( variable ) |
|
33 |
|
34 #define GFX_TRY try |
|
35 #define GFX_CATCH \ |
|
36 catch(std::bad_alloc const&) \ |
|
37 { \ |
|
38 GfxException e(EGfxErrorNoMemory, "Bad alloc"); \ |
|
39 swtApp->jniUtils().Throw(aJniEnv, e); \ |
|
40 } \ |
|
41 catch(GfxException e) \ |
|
42 { \ |
|
43 swtApp->jniUtils().Throw(aJniEnv, e); \ |
|
44 } |
|
45 |
|
46 |
|
47 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1get_1windowsurface |
|
48 (JNIEnv* aJniEnv, jclass, jint aHandle) |
|
49 { |
|
50 WindowSurface* ws = NULL; |
|
51 GFX_TRY |
|
52 { |
|
53 SWT_LOG_JNI_CALL(); |
|
54 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
55 ws = gc->getWindowSurface(); |
|
56 } |
|
57 GFX_CATCH |
|
58 |
|
59 return POINTER_TO_HANDLE(ws); |
|
60 } |
|
61 |
|
62 // Creates a new instance of native graphics context (gc) |
|
63 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1init |
|
64 (JNIEnv* aJniEnv , jclass) |
|
65 { |
|
66 GraphicsContext* gc = 0; |
|
67 GFX_TRY |
|
68 { |
|
69 SWT_LOG_JNI_CALL(); |
|
70 gc = GraphicsFactory::createGraphicsContext(); |
|
71 } |
|
72 GFX_CATCH |
|
73 |
|
74 return POINTER_TO_HANDLE(gc); |
|
75 } |
|
76 |
|
77 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1dispose |
|
78 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
79 { |
|
80 GFX_TRY |
|
81 { |
|
82 SWT_LOG_JNI_CALL(); |
|
83 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
84 gc->dispose(); |
|
85 gc = NULL; |
|
86 } |
|
87 GFX_CATCH |
|
88 } |
|
89 |
|
90 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1bindTarget |
|
91 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aTarget, jint aType, jint aBufferFlushTargetHandle) |
|
92 { |
|
93 GFX_TRY |
|
94 { |
|
95 SWT_LOG_JNI_CALL(); |
|
96 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
97 gc->bindTarget(aTarget, (TTargetType)aType, static_cast<int>(aBufferFlushTargetHandle)); |
|
98 } |
|
99 GFX_CATCH |
|
100 } |
|
101 |
|
102 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1render |
|
103 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aBufferHandle) |
|
104 { |
|
105 GFX_TRY |
|
106 { |
|
107 SWT_LOG_JNI_CALL(); |
|
108 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
109 HANDLE_TO_POINTER(Buffer*, buffer, aBufferHandle); |
|
110 gc->render(buffer); |
|
111 } |
|
112 GFX_CATCH |
|
113 } |
|
114 |
|
115 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1releaseTarget |
|
116 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
117 { |
|
118 GFX_TRY |
|
119 { |
|
120 SWT_LOG_JNI_CALL(); |
|
121 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
122 gc->releaseTarget(); |
|
123 } |
|
124 GFX_CATCH |
|
125 } |
|
126 |
|
127 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1copyArea__IIII |
|
128 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aTargetHandle, jint aX, jint aY) |
|
129 { |
|
130 GFX_TRY |
|
131 { |
|
132 SWT_LOG_JNI_CALL(); |
|
133 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
134 HANDLE_TO_POINTER(Image*, image, aTargetHandle); |
|
135 |
|
136 gc->copyArea(image, aX, aY); |
|
137 } |
|
138 GFX_CATCH |
|
139 } |
|
140 |
|
141 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1copyArea__IIIIIIIZ |
|
142 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aSrcX, jint aSrcY, jint aWidth, jint aHeight, jint aDestX, jint aDestY, jboolean aPaint) |
|
143 { |
|
144 GFX_TRY |
|
145 { |
|
146 SWT_LOG_JNI_CALL(); |
|
147 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
148 gc->copyArea(aSrcX, aSrcY, aWidth, aHeight, aDestX, aDestY, aPaint == JNI_TRUE ? true : false); |
|
149 } |
|
150 GFX_CATCH |
|
151 } |
|
152 |
|
153 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawArc |
|
154 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jint aStartAngle, jint aArcAngle) |
|
155 { |
|
156 GFX_TRY |
|
157 { |
|
158 SWT_LOG_JNI_CALL(); |
|
159 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
160 gc->drawArc(aX, aY, aWidth, aHeight, aStartAngle, aArcAngle); |
|
161 } |
|
162 GFX_CATCH |
|
163 } |
|
164 |
|
165 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawEllipse |
|
166 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight) |
|
167 { |
|
168 GFX_TRY |
|
169 { |
|
170 SWT_LOG_JNI_CALL(); |
|
171 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
172 gc->drawEllipse(aX, aY, aWidth, aHeight); |
|
173 } |
|
174 GFX_CATCH |
|
175 } |
|
176 |
|
177 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawFocus |
|
178 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight) |
|
179 { |
|
180 GFX_TRY |
|
181 { |
|
182 SWT_LOG_JNI_CALL(); |
|
183 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
184 gc->drawFocus(aX, aY, aWidth, aHeight); |
|
185 } |
|
186 GFX_CATCH |
|
187 } |
|
188 |
|
189 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawImage__IIII |
|
190 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aImageHandle, jint aX, jint aY) |
|
191 { |
|
192 GFX_TRY |
|
193 { |
|
194 SWT_LOG_JNI_CALL(); |
|
195 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
196 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
197 gc->drawImage(image, aX, aY); |
|
198 } |
|
199 GFX_CATCH |
|
200 } |
|
201 |
|
202 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawImage__IIIIIIIIIII |
|
203 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aImageHandle, jint aTx, jint aTy, jint aTw, jint aTh, |
|
204 jint aSx, jint aSy, jint aSw, jint aSh, jint aManipulation) |
|
205 { |
|
206 GFX_TRY |
|
207 { |
|
208 SWT_LOG_JNI_CALL(); |
|
209 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
210 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
211 gc->drawImage(image, aManipulation, aTx, aTy, aTw, aTh, aSx, aSy, aSw, aSh); |
|
212 } |
|
213 GFX_CATCH |
|
214 } |
|
215 |
|
216 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawLine |
|
217 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX1, jint aY1, jint aX2, jint aY2) |
|
218 { |
|
219 GFX_TRY |
|
220 { |
|
221 SWT_LOG_JNI_CALL(); |
|
222 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
223 gc->drawLine(aX1, aY1, aX2, aY2); |
|
224 } |
|
225 GFX_CATCH |
|
226 } |
|
227 |
|
228 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawPoint |
|
229 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY) |
|
230 { |
|
231 GFX_TRY |
|
232 { |
|
233 SWT_LOG_JNI_CALL(); |
|
234 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
235 gc->drawPoint(aX, aY); |
|
236 } |
|
237 GFX_CATCH |
|
238 } |
|
239 |
|
240 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawPolygon |
|
241 (JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aPointArray) |
|
242 { |
|
243 GFX_TRY |
|
244 { |
|
245 SWT_LOG_JNI_CALL(); |
|
246 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
247 int length = aJniEnv->GetArrayLength(aPointArray); |
|
248 int* buffer = new int[length]; // might throw bad_alloc |
|
249 AutoRelease<int> release(buffer, true); |
|
250 swtApp->jniUtils().GetJavaIntArrayRegionToIntArray(aJniEnv, aPointArray, 0, length, buffer); // might throw bad_alloc |
|
251 gc->drawPolygon(buffer, length); |
|
252 } |
|
253 GFX_CATCH |
|
254 } |
|
255 |
|
256 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawPolyline |
|
257 (JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aPointArray) |
|
258 { |
|
259 GFX_TRY |
|
260 { |
|
261 SWT_LOG_JNI_CALL(); |
|
262 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
263 int length = aJniEnv->GetArrayLength(aPointArray); |
|
264 int* buffer = new int[length]; // might throw bad_alloc |
|
265 AutoRelease<int> release(buffer, true); |
|
266 swtApp->jniUtils().GetJavaIntArrayRegionToIntArray(aJniEnv, aPointArray, 0, length, buffer); // might throw bad_alloc |
|
267 gc->drawPolyline(buffer, length); |
|
268 } |
|
269 GFX_CATCH |
|
270 } |
|
271 |
|
272 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawRect |
|
273 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight) |
|
274 { |
|
275 GFX_TRY |
|
276 { |
|
277 SWT_LOG_JNI_CALL(); |
|
278 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
279 gc->drawRect(aX, aY, aWidth, aHeight); |
|
280 } |
|
281 GFX_CATCH |
|
282 } |
|
283 |
|
284 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawRGB__I_3IIIIIIIZI |
|
285 (JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aRgbData, jint aOffset, jint aScanlength, |
|
286 jint aX, jint aY, jint aWidth, jint aHeight, jboolean aProcessAlpha, jint aManipulation) |
|
287 { |
|
288 GFX_TRY |
|
289 { |
|
290 SWT_LOG_JNI_CALL(); |
|
291 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
292 int length = aJniEnv->GetArrayLength(aRgbData); |
|
293 |
|
294 int* buffer = new int[length]; // might throw bad_alloc |
|
295 AutoRelease<int> release(buffer, true); |
|
296 swtApp->jniUtils().GetJavaIntArrayRegionToIntArray(aJniEnv, aRgbData, 0, length, buffer); // might throw bad_alloc |
|
297 |
|
298 gc->drawRGB(buffer, length, aOffset, aScanlength, aX, aY, aWidth, aHeight, aProcessAlpha, aManipulation); |
|
299 } |
|
300 GFX_CATCH |
|
301 } |
|
302 |
|
303 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawRGB__I_3B_3BIIIIIIII |
|
304 (JNIEnv *aJniEnv, jclass, jint aHandle, jbyteArray aRgbData, jbyteArray aTransparencyMask, |
|
305 jint aOffset, jint aScanLength, jint aX, jint aY, jint aWidth, jint aHeight, jint aTransform, jint aFormat) |
|
306 { |
|
307 GFX_TRY |
|
308 { |
|
309 SWT_LOG_JNI_CALL(); |
|
310 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
311 |
|
312 int dataLength = aJniEnv->GetArrayLength(aRgbData); |
|
313 int maskLength = aJniEnv->GetArrayLength(aTransparencyMask); |
|
314 |
|
315 char* dataBuffer = new char[dataLength]; // might throw bad_alloc |
|
316 AutoRelease<char> releaseData(dataBuffer, true); |
|
317 swtApp->jniUtils().GetJavaByteArrayRegionToCharArray(aJniEnv, aRgbData, 0, dataLength, dataBuffer); // might throw bad_alloc |
|
318 |
|
319 char* maskBuffer = NULL; |
|
320 AutoRelease<char> releaseMask(NULL, true); // Will delete mask or NULL if there's no mask |
|
321 |
|
322 if(aTransparencyMask) |
|
323 { |
|
324 maskBuffer = new char[maskLength]; // might throw bad_alloc |
|
325 releaseMask.reset(maskBuffer); |
|
326 swtApp->jniUtils().GetJavaByteArrayRegionToCharArray(aJniEnv, aTransparencyMask, 0, maskLength, maskBuffer); // might throw bad_alloc |
|
327 } |
|
328 |
|
329 gc->drawRGB(dataBuffer, maskBuffer, dataLength, aOffset, aScanLength, aX, aY, aWidth, aHeight, aTransform, aFormat); |
|
330 } |
|
331 GFX_CATCH |
|
332 } |
|
333 |
|
334 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawRGB__I_3SIIIIIIZII |
|
335 (JNIEnv * aJniEnv, jclass, jint aImageHandle, jshortArray aRgbData, jint aOffset, jint aScanlength, |
|
336 jint aX, jint aY, jint aWidth, jint aHeight, jboolean aProcessAlpha, jint aManipulation, jint aFormat) |
|
337 { |
|
338 GFX_TRY |
|
339 { |
|
340 SWT_LOG_JNI_CALL(); |
|
341 HANDLE_TO_POINTER(GraphicsContext*, gc, aImageHandle); |
|
342 |
|
343 int length = aJniEnv->GetArrayLength(aRgbData); |
|
344 |
|
345 short* buffer = new short[length]; |
|
346 AutoRelease<short> release(buffer, true); |
|
347 ::memset(buffer, 0, sizeof(short)*length); |
|
348 |
|
349 swtApp->jniUtils().GetJavaShortArrayRegionToShortArray(aJniEnv, aRgbData, 0, length, buffer); // might throw bad_alloc |
|
350 |
|
351 gc->drawRGB(buffer, length, aOffset, aScanlength, aX, aY, aWidth, aHeight, aProcessAlpha, aManipulation, aFormat); |
|
352 } |
|
353 GFX_CATCH |
|
354 } |
|
355 |
|
356 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawRoundRect |
|
357 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jint aArcWidth, jint aArcHeight) |
|
358 { |
|
359 GFX_TRY |
|
360 { |
|
361 SWT_LOG_JNI_CALL(); |
|
362 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
363 gc->drawRoundRect(aX, aY, aWidth, aHeight, aArcWidth, aArcHeight); |
|
364 } |
|
365 GFX_CATCH |
|
366 } |
|
367 |
|
368 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawString |
|
369 (JNIEnv* aJniEnv, jclass, jint aHandle, jstring aText, jint aX, jint aY, jint aWidth, jint aHeight, |
|
370 jint aAlignments, jint aFlags, jboolean aIsTransparent) |
|
371 { |
|
372 GFX_TRY |
|
373 { |
|
374 SWT_LOG_JNI_CALL(); |
|
375 const jchar* chars; // unsigned short (2 bytes) |
|
376 int length; |
|
377 |
|
378 length = aJniEnv->GetStringLength(aText); |
|
379 chars = aJniEnv->GetStringChars(aText, NULL); |
|
380 AutoReleaseStringChars release(aJniEnv, aText, chars); |
|
381 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
382 gc->drawString( |
|
383 (const unsigned short*)chars, |
|
384 aX, |
|
385 aY, |
|
386 aWidth, |
|
387 aHeight, |
|
388 length, |
|
389 aAlignments, |
|
390 aFlags, |
|
391 aIsTransparent); |
|
392 } |
|
393 GFX_CATCH |
|
394 } |
|
395 |
|
396 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawWindowSurface |
|
397 (JNIEnv* aJniEnv, jclass, jint aHandle, jint aSurfaceHandle, jint aX, jint aY, jint aWidth, jint aHeight) |
|
398 { |
|
399 GFX_TRY |
|
400 { |
|
401 SWT_LOG_JNI_CALL(); |
|
402 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
403 HANDLE_TO_POINTER(WindowSurface*, surface, aSurfaceHandle); |
|
404 gc->drawWindowSurface(surface, aX, aY, aWidth, aHeight); |
|
405 } |
|
406 GFX_CATCH |
|
407 } |
|
408 |
|
409 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1fillArc |
|
410 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jint aStartAngle, jint aArcAngle) |
|
411 { |
|
412 GFX_TRY |
|
413 { |
|
414 SWT_LOG_JNI_CALL(); |
|
415 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
416 gc->fillArc(aX, aY, aWidth, aHeight, aStartAngle, aArcAngle); |
|
417 } |
|
418 GFX_CATCH |
|
419 } |
|
420 |
|
421 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1fillEllipse |
|
422 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight) |
|
423 { |
|
424 GFX_TRY |
|
425 { |
|
426 SWT_LOG_JNI_CALL(); |
|
427 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
428 gc->fillEllipse(aX, aY, aWidth, aHeight); |
|
429 } |
|
430 GFX_CATCH |
|
431 } |
|
432 |
|
433 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1fillGradientRect |
|
434 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jboolean aVertical, jboolean aSwapColors) |
|
435 { |
|
436 GFX_TRY |
|
437 { |
|
438 SWT_LOG_JNI_CALL(); |
|
439 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
440 gc->fillGradientRect(aX, aY, aWidth, aHeight, aVertical, aSwapColors); |
|
441 } |
|
442 GFX_CATCH |
|
443 } |
|
444 |
|
445 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1fillPolygon |
|
446 (JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aPointArray) |
|
447 { |
|
448 GFX_TRY |
|
449 { |
|
450 SWT_LOG_JNI_CALL(); |
|
451 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
452 int length = aJniEnv->GetArrayLength(aPointArray); |
|
453 |
|
454 int* buffer = new int[length]; // might throw bad_alloc |
|
455 AutoRelease<int> release(buffer, true); |
|
456 swtApp->jniUtils().GetJavaIntArrayRegionToIntArray(aJniEnv, aPointArray, 0, length, buffer); // might throw bad_alloc |
|
457 |
|
458 gc->fillPolygon(buffer, length); |
|
459 } |
|
460 GFX_CATCH |
|
461 } |
|
462 |
|
463 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1fillRect |
|
464 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight) |
|
465 { |
|
466 GFX_TRY |
|
467 { |
|
468 SWT_LOG_JNI_CALL(); |
|
469 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
470 gc->fillRect(aX, aY, aWidth, aHeight); |
|
471 } |
|
472 GFX_CATCH |
|
473 } |
|
474 |
|
475 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1fillRoundRect |
|
476 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jint aArcWidth, jint aArcHeight) |
|
477 { |
|
478 GFX_TRY |
|
479 { |
|
480 SWT_LOG_JNI_CALL(); |
|
481 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
482 gc->fillRoundRect(aX, aY, aWidth, aHeight, aArcWidth, aArcHeight); |
|
483 } |
|
484 GFX_CATCH |
|
485 } |
|
486 |
|
487 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getBackgroundAlpha |
|
488 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
489 { |
|
490 jint bgAlpha = 0; |
|
491 GFX_TRY |
|
492 { |
|
493 SWT_LOG_JNI_CALL(); |
|
494 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
495 bgAlpha = static_cast<jint>( gc->getBackgroundAlpha() ); |
|
496 } |
|
497 GFX_CATCH |
|
498 return bgAlpha; |
|
499 } |
|
500 |
|
501 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getBackgroundColor |
|
502 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
503 { |
|
504 jint bgColor = 0; |
|
505 GFX_TRY |
|
506 { |
|
507 SWT_LOG_JNI_CALL(); |
|
508 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
509 bgColor = static_cast<jint>( gc->getBackgroundColor() ); |
|
510 } |
|
511 GFX_CATCH |
|
512 return bgColor; |
|
513 } |
|
514 |
|
515 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getCharacterWidth |
|
516 (JNIEnv* aJniEnv , jclass, jint aHandle, jchar aCh, jboolean aIsAdvanced) |
|
517 { |
|
518 jint charWidth = 0; |
|
519 GFX_TRY |
|
520 { |
|
521 SWT_LOG_JNI_CALL(); |
|
522 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
523 charWidth = static_cast<jint>( gc->getCharacterWidth(aCh, aIsAdvanced) ); |
|
524 } |
|
525 GFX_CATCH |
|
526 return charWidth; |
|
527 } |
|
528 |
|
529 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getFontMetricsData |
|
530 (JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aDataArray, jint aFontHandle) |
|
531 { |
|
532 GFX_TRY |
|
533 { |
|
534 SWT_LOG_JNI_CALL(); |
|
535 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
536 |
|
537 int length = aJniEnv->GetArrayLength(aDataArray); |
|
538 |
|
539 int* buffer = new int[length]; // might throw bad_alloc |
|
540 AutoRelease<int> release(buffer, true); |
|
541 ::memset(buffer, 0, sizeof(int)*length); |
|
542 |
|
543 if (aFontHandle) |
|
544 { |
|
545 HANDLE_TO_POINTER(QFont*, font, aFontHandle); |
|
546 gc->getFontMetricsData(buffer, *font); |
|
547 } |
|
548 else |
|
549 { |
|
550 QFont font; |
|
551 gc->getFontMetricsData(buffer, font); |
|
552 } |
|
553 // Copy back changes to the Java array |
|
554 swtApp->jniUtils().SetJavaIntArrayRegionFromIntArray(aJniEnv, aDataArray, 0, length, buffer); |
|
555 } |
|
556 GFX_CATCH |
|
557 } |
|
558 |
|
559 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getBlendingMode |
|
560 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
561 { |
|
562 jint blendingMode = 0; |
|
563 GFX_TRY |
|
564 { |
|
565 SWT_LOG_JNI_CALL(); |
|
566 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
567 blendingMode = static_cast<jint>( gc->getBlendingMode() ); |
|
568 } |
|
569 GFX_CATCH |
|
570 return blendingMode; |
|
571 } |
|
572 |
|
573 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getClip |
|
574 (JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aClipArray) |
|
575 { |
|
576 GFX_TRY |
|
577 { |
|
578 SWT_LOG_JNI_CALL(); |
|
579 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
580 int length = aJniEnv->GetArrayLength(aClipArray); |
|
581 |
|
582 int* buffer = new int[length]; // might throw bad_alloc |
|
583 AutoRelease<int> release(buffer, true); |
|
584 ::memset(buffer, 0, sizeof(int)*length); |
|
585 |
|
586 gc->getClip(buffer); |
|
587 |
|
588 swtApp->jniUtils().SetJavaIntArrayRegionFromIntArray(aJniEnv, aClipArray, 0, length, buffer); |
|
589 } |
|
590 GFX_CATCH |
|
591 } |
|
592 |
|
593 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getForegroundAlpha |
|
594 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
595 { |
|
596 jint fgAlpha = 0; |
|
597 GFX_TRY |
|
598 { |
|
599 SWT_LOG_JNI_CALL(); |
|
600 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
601 fgAlpha = static_cast<jint>( gc->getForegroundAlpha() ); |
|
602 } |
|
603 GFX_CATCH |
|
604 return fgAlpha; |
|
605 } |
|
606 |
|
607 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getForegroundColor |
|
608 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
609 { |
|
610 jint fgColor = 0; |
|
611 GFX_TRY |
|
612 { |
|
613 SWT_LOG_JNI_CALL(); |
|
614 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
615 fgColor = static_cast<jint>( gc->getForegroundColor() ); |
|
616 } |
|
617 GFX_CATCH |
|
618 return fgColor; |
|
619 } |
|
620 |
|
621 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getTextBoundingBox |
|
622 (JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aBoundingBox, jstring aText, |
|
623 jint aAlignments, jint aFlags, jint aRectX, jint aRectY, jint aRectWidth, jint aRectHeight) |
|
624 { |
|
625 GFX_TRY |
|
626 { |
|
627 SWT_LOG_JNI_CALL(); |
|
628 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
629 |
|
630 int length = aJniEnv->GetArrayLength(aBoundingBox); |
|
631 |
|
632 int* buffer = new int[length]; // might throw bad_alloc |
|
633 AutoRelease<int> releaseBuffer(buffer, true); |
|
634 ::memset(buffer, 0, sizeof(int)*length); |
|
635 |
|
636 const jchar* textPtr = aJniEnv->GetStringChars(aText, NULL); |
|
637 AutoReleaseStringChars releaseStringChars(aJniEnv, aText, textPtr); |
|
638 |
|
639 jint textLength = aJniEnv->GetStringLength(aText); |
|
640 |
|
641 gc->getTextBoundingBox( |
|
642 buffer, |
|
643 static_cast<const unsigned short*>(textPtr), |
|
644 textLength, |
|
645 aAlignments, |
|
646 aFlags, |
|
647 aRectX, aRectY, aRectWidth, aRectHeight); |
|
648 |
|
649 // Copy changes to boundingBox |
|
650 swtApp->jniUtils().SetJavaIntArrayRegionFromIntArray(aJniEnv, aBoundingBox, 0, length, buffer); |
|
651 } |
|
652 GFX_CATCH |
|
653 } |
|
654 |
|
655 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getStrokeWidth |
|
656 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
657 { |
|
658 jint strokeWidth = 0; |
|
659 GFX_TRY |
|
660 { |
|
661 SWT_LOG_JNI_CALL(); |
|
662 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
663 strokeWidth = static_cast<jint>( gc->getStrokeWidth() ); |
|
664 } |
|
665 GFX_CATCH |
|
666 return strokeWidth; |
|
667 } |
|
668 |
|
669 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getStrokeStyle |
|
670 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
671 { |
|
672 jint strokeStyle = 0; |
|
673 GFX_TRY |
|
674 { |
|
675 SWT_LOG_JNI_CALL(); |
|
676 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
677 strokeStyle = static_cast<jint>( gc->getStrokeStyle() ); |
|
678 } |
|
679 GFX_CATCH |
|
680 return strokeStyle; |
|
681 } |
|
682 |
|
683 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getTranslateX |
|
684 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
685 { |
|
686 jint translateX = 0; |
|
687 GFX_TRY |
|
688 { |
|
689 SWT_LOG_JNI_CALL(); |
|
690 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
691 translateX = static_cast<jint>( gc->getTranslateX() ); |
|
692 } |
|
693 GFX_CATCH |
|
694 return translateX; |
|
695 } |
|
696 |
|
697 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1getTranslateY |
|
698 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
699 { |
|
700 jint translateY = 0; |
|
701 GFX_TRY |
|
702 { |
|
703 SWT_LOG_JNI_CALL(); |
|
704 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
705 translateY = static_cast<jint>( gc->getTranslateY() ); |
|
706 } |
|
707 GFX_CATCH |
|
708 return translateY; |
|
709 } |
|
710 |
|
711 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setBackgroundAlpha |
|
712 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aAlpha) |
|
713 { |
|
714 GFX_TRY |
|
715 { |
|
716 SWT_LOG_JNI_CALL(); |
|
717 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
718 gc->setBackgroundAlpha(aAlpha); |
|
719 } |
|
720 GFX_CATCH |
|
721 } |
|
722 |
|
723 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setBackgroundColor |
|
724 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aArgb, jboolean aUpdateAlpha) |
|
725 { |
|
726 GFX_TRY |
|
727 { |
|
728 SWT_LOG_JNI_CALL(); |
|
729 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
730 gc->setBackgroundColor(aArgb, aUpdateAlpha); |
|
731 } |
|
732 GFX_CATCH |
|
733 } |
|
734 |
|
735 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setBlendingMode |
|
736 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aMode) |
|
737 { |
|
738 GFX_TRY |
|
739 { |
|
740 SWT_LOG_JNI_CALL(); |
|
741 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
742 gc->setBlendingMode((TBlendingMode)aMode); |
|
743 } |
|
744 GFX_CATCH |
|
745 } |
|
746 |
|
747 jboolean JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1hasClipping |
|
748 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
749 { |
|
750 jboolean hasClipping = JNI_FALSE; |
|
751 GFX_TRY |
|
752 { |
|
753 SWT_LOG_JNI_CALL(); |
|
754 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
755 hasClipping = static_cast<jboolean>( gc->hasClipping() ); |
|
756 } |
|
757 GFX_CATCH |
|
758 return hasClipping; |
|
759 } |
|
760 |
|
761 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1cancelClipping |
|
762 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
763 { |
|
764 GFX_TRY |
|
765 { |
|
766 SWT_LOG_JNI_CALL(); |
|
767 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
768 gc->cancelClipping(); |
|
769 } |
|
770 GFX_CATCH |
|
771 } |
|
772 |
|
773 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setClip |
|
774 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jboolean aIntersects) |
|
775 { |
|
776 GFX_TRY |
|
777 { |
|
778 SWT_LOG_JNI_CALL(); |
|
779 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
780 gc->setClip(aX, aY, aWidth, aHeight, aIntersects); |
|
781 } |
|
782 GFX_CATCH |
|
783 } |
|
784 |
|
785 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setFont |
|
786 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aFontHandle) |
|
787 { |
|
788 GFX_TRY |
|
789 { |
|
790 SWT_LOG_JNI_CALL(); |
|
791 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
792 gc->setFont(aFontHandle); |
|
793 } |
|
794 GFX_CATCH |
|
795 } |
|
796 |
|
797 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setForegroundAlpha |
|
798 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aAlpha) |
|
799 { |
|
800 GFX_TRY |
|
801 { |
|
802 SWT_LOG_JNI_CALL(); |
|
803 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
804 gc->setForegroundAlpha(aAlpha); |
|
805 } |
|
806 GFX_CATCH |
|
807 } |
|
808 |
|
809 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setForegroundColor |
|
810 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aArgb, jboolean aUpdateAlpha) |
|
811 { |
|
812 GFX_TRY |
|
813 { |
|
814 SWT_LOG_JNI_CALL(); |
|
815 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
816 gc->setForegroundColor(aArgb, aUpdateAlpha); |
|
817 } |
|
818 GFX_CATCH |
|
819 } |
|
820 |
|
821 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setStrokeWidth |
|
822 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aWidth) |
|
823 { |
|
824 GFX_TRY |
|
825 { |
|
826 SWT_LOG_JNI_CALL(); |
|
827 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
828 gc->setStrokeWidth(aWidth); |
|
829 } |
|
830 GFX_CATCH |
|
831 } |
|
832 |
|
833 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1setStrokeStyle |
|
834 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aStyle) |
|
835 { |
|
836 GFX_TRY |
|
837 { |
|
838 SWT_LOG_JNI_CALL(); |
|
839 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
840 gc->setStrokeStyle((TStrokeStyle)aStyle); |
|
841 } |
|
842 GFX_CATCH |
|
843 } |
|
844 |
|
845 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1translate |
|
846 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY) |
|
847 { |
|
848 GFX_TRY |
|
849 { |
|
850 SWT_LOG_JNI_CALL(); |
|
851 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
852 gc->translate(aX,aY); |
|
853 } |
|
854 GFX_CATCH |
|
855 } |
|
856 |
|
857 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1scale |
|
858 (JNIEnv* aJniEnv, jclass, jint aHandle, jint aX, jint aY) |
|
859 { |
|
860 GFX_TRY |
|
861 { |
|
862 SWT_LOG_JNI_CALL(); |
|
863 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
864 gc->scale(aX,aY); |
|
865 } |
|
866 GFX_CATCH |
|
867 } |
|
868 |
|
869 |
|
870 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1resetTransform |
|
871 (JNIEnv* aJniEnv, jclass, jint aHandle) |
|
872 { |
|
873 GFX_TRY |
|
874 { |
|
875 SWT_LOG_JNI_CALL(); |
|
876 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
877 gc->resetTransform(); |
|
878 } |
|
879 GFX_CATCH |
|
880 } |
|
881 |
|
882 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1saveSettings |
|
883 (JNIEnv* aJniEnv, jclass, jint aHandle) |
|
884 { |
|
885 GFX_TRY |
|
886 { |
|
887 SWT_LOG_JNI_CALL(); |
|
888 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
889 gc->saveSettings(); |
|
890 } |
|
891 GFX_CATCH |
|
892 } |
|
893 |
|
894 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1restoreSettings |
|
895 (JNIEnv* aJniEnv, jclass, jint aHandle) |
|
896 { |
|
897 GFX_TRY |
|
898 { |
|
899 SWT_LOG_JNI_CALL(); |
|
900 HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); |
|
901 gc->restoreSettings(); |
|
902 } |
|
903 GFX_CATCH |
|
904 } |
|
905 |
|
906 // |
|
907 // Image class JNI calls |
|
908 // |
|
909 |
|
910 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__III |
|
911 (JNIEnv* aJniEnv , jclass, jint aWidth , jint aHeight, jint aFillColor) |
|
912 { |
|
913 Image* img = NULL; |
|
914 GFX_TRY |
|
915 { |
|
916 SWT_LOG_JNI_CALL(); |
|
917 img = GraphicsFactory::createImage(aWidth, aHeight, aFillColor); |
|
918 } |
|
919 GFX_CATCH |
|
920 return POINTER_TO_HANDLE(img); |
|
921 } |
|
922 |
|
923 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__IIIII |
|
924 (JNIEnv* aJniEnv , jclass, jint aImageHandle, jint aX, jint aY, jint aWidth, jint aHeight) |
|
925 { |
|
926 Image* newImage = NULL; |
|
927 GFX_TRY |
|
928 { |
|
929 SWT_LOG_JNI_CALL(); |
|
930 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
931 newImage = GraphicsFactory::createImage(image, aX, aY, aWidth, aHeight); |
|
932 } |
|
933 GFX_CATCH |
|
934 return POINTER_TO_HANDLE(newImage); |
|
935 } |
|
936 |
|
937 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create___3IIIZ |
|
938 (JNIEnv* aJniEnv, jclass, jintArray aRgbData, jint aWidth, jint aHeight, jboolean aHasAlpha) |
|
939 { |
|
940 Image* img = NULL; |
|
941 GFX_TRY |
|
942 { |
|
943 SWT_LOG_JNI_CALL(); |
|
944 |
|
945 int length = aJniEnv->GetArrayLength(aRgbData); |
|
946 |
|
947 int* buffer = new int[length]; // might throw bad_alloc |
|
948 AutoRelease<int> release(buffer, true); |
|
949 swtApp->jniUtils().GetJavaIntArrayRegionToIntArray(aJniEnv, aRgbData, 0, length, buffer); // might throw bad_alloc |
|
950 |
|
951 img = GraphicsFactory::createImage(buffer, aWidth, aHeight, aHasAlpha); |
|
952 } |
|
953 GFX_CATCH |
|
954 return POINTER_TO_HANDLE(img); |
|
955 } |
|
956 |
|
957 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__Lorg_eclipse_swt_graphics_ImageData_2 |
|
958 (JNIEnv* aJniEnv , jclass, jobject aImageData) |
|
959 { |
|
960 Image* img = NULL; |
|
961 GFX_TRY |
|
962 { |
|
963 SWT_LOG_JNI_CALL(); |
|
964 img = swtApp->jniUtils().CreateImage(aJniEnv, aImageData); |
|
965 } |
|
966 GFX_CATCH |
|
967 return POINTER_TO_HANDLE(img); |
|
968 } |
|
969 |
|
970 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__I |
|
971 (JNIEnv* aJniEnv , jclass, jint aPixmapHandle) |
|
972 { |
|
973 Image* img = NULL; |
|
974 GFX_TRY |
|
975 { |
|
976 SWT_LOG_JNI_CALL(); |
|
977 HANDLE_TO_POINTER(QPixmap*, pixmap, aPixmapHandle); |
|
978 if (pixmap) |
|
979 img = GraphicsFactory::createImage(*pixmap); |
|
980 } |
|
981 GFX_CATCH |
|
982 return POINTER_TO_HANDLE(img); |
|
983 } |
|
984 |
|
985 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getFormat |
|
986 (JNIEnv* aJniEnv, jclass, jint aImageHandle) |
|
987 { |
|
988 jint format = 0; |
|
989 GFX_TRY |
|
990 { |
|
991 SWT_LOG_JNI_CALL(); |
|
992 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
993 format = static_cast<jint>( image->getFormat() ); |
|
994 } |
|
995 GFX_CATCH |
|
996 return format; |
|
997 } |
|
998 |
|
999 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getHeight |
|
1000 (JNIEnv* aJniEnv, jclass, jint aImageHandle) |
|
1001 { |
|
1002 jint height = 0; |
|
1003 GFX_TRY |
|
1004 { |
|
1005 SWT_LOG_JNI_CALL(); |
|
1006 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1007 height = static_cast<jint>( image->getHeight() ); |
|
1008 } |
|
1009 GFX_CATCH |
|
1010 return height; |
|
1011 } |
|
1012 |
|
1013 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getWidth |
|
1014 (JNIEnv* aJniEnv , jclass, jint aImageHandle) |
|
1015 { |
|
1016 jint width = 0; |
|
1017 GFX_TRY |
|
1018 { |
|
1019 SWT_LOG_JNI_CALL(); |
|
1020 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1021 width = static_cast<jint>( image->getWidth() ); |
|
1022 } |
|
1023 GFX_CATCH |
|
1024 return width; |
|
1025 } |
|
1026 |
|
1027 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getRGB__I_3IIIIIII |
|
1028 (JNIEnv* aJniEnv, jclass, jint aImageHandle, jintArray aRgbData, jint aOffset, jint aScanlength, jint aX, jint aY, jint aWidth, jint aHeight) |
|
1029 { |
|
1030 GFX_TRY |
|
1031 { |
|
1032 SWT_LOG_JNI_CALL(); |
|
1033 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1034 |
|
1035 int length = aJniEnv->GetArrayLength(aRgbData); |
|
1036 |
|
1037 int* buffer = new int[length]; // might throw bad_alloc |
|
1038 AutoRelease<int> release(buffer, true); |
|
1039 ::memset(buffer, 0, sizeof(int)*length); |
|
1040 |
|
1041 // get the data (populated to data array) |
|
1042 image->getRgb(buffer, aOffset, aScanlength, aX, aY, aWidth, aHeight); |
|
1043 |
|
1044 // Copy data back to java |
|
1045 swtApp->jniUtils().SetJavaIntArrayRegionFromIntArray(aJniEnv, aRgbData, 0, length, buffer); |
|
1046 } |
|
1047 GFX_CATCH |
|
1048 } |
|
1049 |
|
1050 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getRGB__I_3B_3BIIIIIII |
|
1051 (JNIEnv * aJniEnv, jclass, jint aImageHandle, jbyteArray aRgbData, jbyteArray aTransparencyMask, jint aOffset, jint aScanlength, jint aX, jint aY, jint aWidth, jint aHeight, jint aFormat) |
|
1052 { |
|
1053 GFX_TRY |
|
1054 { |
|
1055 SWT_LOG_JNI_CALL(); |
|
1056 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1057 |
|
1058 int dataLength = aJniEnv->GetArrayLength(aRgbData); |
|
1059 int maskLength = aJniEnv->GetArrayLength(aTransparencyMask); |
|
1060 |
|
1061 char* dataBuffer = new char[dataLength]; // might throw bad_alloc |
|
1062 AutoRelease<char> releaseData(dataBuffer, true); |
|
1063 char* maskBuffer = new char[maskLength]; // might throw bad_alloc |
|
1064 AutoRelease<char> releaseMask(maskBuffer, true); |
|
1065 ::memset(dataBuffer, 0, sizeof(char)*dataLength); |
|
1066 ::memset(maskBuffer, 0, sizeof(char)*maskLength); |
|
1067 |
|
1068 // get the data (populated to data array) |
|
1069 image->getRgb(dataBuffer, maskBuffer, aOffset, aScanlength, aX, aY, aWidth, aHeight, aFormat); |
|
1070 |
|
1071 // Copy data back to Java |
|
1072 swtApp->jniUtils().SetJavaByteArrayRegionFromCharArray(aJniEnv, aRgbData, 0, dataLength, dataBuffer); |
|
1073 swtApp->jniUtils().SetJavaByteArrayRegionFromCharArray(aJniEnv, aTransparencyMask, 0, maskLength, maskBuffer); |
|
1074 } |
|
1075 GFX_CATCH |
|
1076 } |
|
1077 |
|
1078 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getRGB__I_3SIIIIIII |
|
1079 (JNIEnv * aJniEnv, jclass, jint aImageHandle, jshortArray aRgbData, jint aOffset, jint aScanlength, jint aX, jint aY, jint aWidth, jint aHeight, jint aFormat) { |
|
1080 GFX_TRY |
|
1081 { |
|
1082 SWT_LOG_JNI_CALL(); |
|
1083 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1084 |
|
1085 int length = aJniEnv->GetArrayLength(aRgbData); |
|
1086 short* buffer = new short[length]; |
|
1087 AutoRelease<short> release(buffer, true); |
|
1088 ::memset(buffer, 0, sizeof(short)*length); |
|
1089 |
|
1090 // get the data (populated to data array) |
|
1091 image->getRgb(buffer, aOffset, aScanlength, aX, aY, aWidth, aHeight, aFormat); |
|
1092 |
|
1093 // Copy data back to java |
|
1094 swtApp->jniUtils().SetJavaShortArrayRegionFromShortArray(aJniEnv, aRgbData, 0, length, buffer); |
|
1095 } |
|
1096 GFX_CATCH |
|
1097 } |
|
1098 |
|
1099 jobject JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getImageData |
|
1100 (JNIEnv* aJniEnv , jclass, jint aImageHandle) |
|
1101 { |
|
1102 SWT_LOG_JNI_CALL(); |
|
1103 jobject imageData = 0; |
|
1104 GFX_TRY |
|
1105 { |
|
1106 ImageDataWrapper* data = NULL; |
|
1107 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1108 data = GraphicsFactory::createImageData(image); |
|
1109 AutoRelease<ImageDataWrapper> release(data, false); |
|
1110 imageData = swtApp->jniUtils().CreateJavaImageData(aJniEnv, *data); |
|
1111 } |
|
1112 GFX_CATCH |
|
1113 return imageData; |
|
1114 } |
|
1115 |
|
1116 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1transform |
|
1117 (JNIEnv* aJniEnv , jclass, jint aImageHandle, jint aTransform) |
|
1118 { |
|
1119 GFX_TRY |
|
1120 { |
|
1121 SWT_LOG_JNI_CALL(); |
|
1122 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1123 image->transform((TTransform)aTransform); |
|
1124 } |
|
1125 GFX_CATCH |
|
1126 } |
|
1127 |
|
1128 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1dispose |
|
1129 (JNIEnv* aJniEnv , jclass, jint aImageHandle) |
|
1130 { |
|
1131 GFX_TRY |
|
1132 { |
|
1133 SWT_LOG_JNI_CALL(); |
|
1134 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1135 image->dispose(); |
|
1136 image = NULL; |
|
1137 } |
|
1138 GFX_CATCH |
|
1139 } |
|
1140 |
|
1141 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getPixmapHandle |
|
1142 (JNIEnv* aJniEnv , jclass, jint aImageHandle) |
|
1143 { |
|
1144 jint pixmapHandle = 0; |
|
1145 GFX_TRY |
|
1146 { |
|
1147 SWT_LOG_JNI_CALL(); |
|
1148 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1149 pixmapHandle = POINTER_TO_HANDLE(image->getPixmap()); |
|
1150 } |
|
1151 GFX_CATCH |
|
1152 return pixmapHandle; |
|
1153 } |
|
1154 |
|
1155 jboolean JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1detectCollision |
|
1156 (JNIEnv* aJniEnv, jclass, jint aImage1PixmapHandle, jint aTransform1, jint aP1x, jint aP1y, jint aR1x1, jint aR1y1, jint aR1x2, jint aR1y2, |
|
1157 jint aImage2PixmapHandle, jint aTransform2, jint aP2x, jint aP2y, jint aR2x1, jint aR2y1, jint aR2x2, jint aR2y2) |
|
1158 { |
|
1159 jboolean collides = JNI_FALSE; |
|
1160 GFX_TRY |
|
1161 { |
|
1162 SWT_LOG_JNI_CALL(); |
|
1163 collides = gfxUtils::detectCollision(aImage1PixmapHandle, aTransform1, aP1x, aP1y, aR1x1, aR1y1, aR1x2, aR1y2, |
|
1164 aImage2PixmapHandle, aTransform2, aP2x, aP2y, aR2x1, aR2y1, aR2x2, aR2y2); |
|
1165 } |
|
1166 GFX_CATCH |
|
1167 return collides; |
|
1168 } |
|
1169 |
|
1170 // |
|
1171 // ImageLoader JNI calls |
|
1172 // |
|
1173 |
|
1174 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1append |
|
1175 (JNIEnv* aJniEnv, jclass, jint aHandle, jint aLenght, jint aOffset, jbyteArray aImageData) |
|
1176 { |
|
1177 GFX_TRY |
|
1178 { |
|
1179 SWT_LOG_JNI_CALL(); |
|
1180 jbyte* data = NULL; |
|
1181 data = aJniEnv->GetByteArrayElements(aImageData, NULL); |
|
1182 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
|
1183 loader->append(reinterpret_cast<const char*>(data), aLenght, aOffset); |
|
1184 // release arrays, don't copy back |
|
1185 aJniEnv->ReleaseByteArrayElements(aImageData, data, JNI_ABORT); |
|
1186 } |
|
1187 GFX_CATCH |
|
1188 } |
|
1189 |
|
1190 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1beginStream |
|
1191 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aBufferSize) |
|
1192 { |
|
1193 GFX_TRY |
|
1194 { |
|
1195 SWT_LOG_JNI_CALL(); |
|
1196 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
|
1197 loader->beginStream(aBufferSize); |
|
1198 } |
|
1199 GFX_CATCH |
|
1200 } |
|
1201 |
|
1202 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1endStream |
|
1203 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
1204 { |
|
1205 Image* image = NULL; |
|
1206 GFX_TRY |
|
1207 { |
|
1208 SWT_LOG_JNI_CALL(); |
|
1209 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
|
1210 image = loader->endStream(); |
|
1211 } |
|
1212 GFX_CATCH |
|
1213 return POINTER_TO_HANDLE(image); |
|
1214 } |
|
1215 |
|
1216 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1init |
|
1217 (JNIEnv* aJniEnv , jclass) |
|
1218 { |
|
1219 ImageLoader* loader = NULL; |
|
1220 GFX_TRY |
|
1221 { |
|
1222 SWT_LOG_JNI_CALL(); |
|
1223 loader = GraphicsFactory::createImageLoader(); |
|
1224 } |
|
1225 GFX_CATCH |
|
1226 return POINTER_TO_HANDLE(loader); |
|
1227 } |
|
1228 |
|
1229 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1dispose |
|
1230 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
1231 { |
|
1232 GFX_TRY |
|
1233 { |
|
1234 SWT_LOG_JNI_CALL(); |
|
1235 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
|
1236 loader->dispose(); |
|
1237 } |
|
1238 GFX_CATCH |
|
1239 } |
|
1240 |
|
1241 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1load |
|
1242 (JNIEnv* aJniEnv , jclass, jint aHandle, jstring aFileName) |
|
1243 { |
|
1244 Image* image = NULL; |
|
1245 GFX_TRY |
|
1246 { |
|
1247 SWT_LOG_JNI_CALL(); |
|
1248 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
|
1249 image = loader->load(swtApp->jniUtils().JavaStringToQString(aJniEnv, aFileName)); |
|
1250 } |
|
1251 GFX_CATCH |
|
1252 return POINTER_TO_HANDLE(image); |
|
1253 } |
|
1254 |
|
1255 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1setLoadSize |
|
1256 (JNIEnv* aJniEnv , jclass, jint aHandle, jint aWidth, jint aHeight) |
|
1257 { |
|
1258 GFX_TRY |
|
1259 { |
|
1260 SWT_LOG_JNI_CALL(); |
|
1261 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
|
1262 loader->setLoadSize(aWidth, aHeight); |
|
1263 } |
|
1264 GFX_CATCH |
|
1265 } |
|
1266 |
|
1267 JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1getImageSize |
|
1268 (JNIEnv *aJniEnv, jclass, jbyteArray aData) |
|
1269 { |
|
1270 jobject size = NULL; |
|
1271 GFX_TRY |
|
1272 { |
|
1273 SWT_LOG_JNI_CALL(); |
|
1274 |
|
1275 jbyte* data = NULL; |
|
1276 data = aJniEnv->GetByteArrayElements(aData, NULL); |
|
1277 int length = aJniEnv->GetArrayLength(aData); |
|
1278 |
|
1279 QByteArray array = QByteArray::fromRawData(reinterpret_cast<const char*>(data), length); |
|
1280 QBuffer buffer(&array); |
|
1281 buffer.open(QIODevice::ReadOnly); |
|
1282 |
|
1283 // Initialize imageReader |
|
1284 QImageReader imgReader(&buffer); |
|
1285 QSize imageSize(-1,-1); |
|
1286 |
|
1287 if (imgReader.supportsOption(QImageIOHandler::Size)) |
|
1288 { |
|
1289 imageSize = imgReader.size(); |
|
1290 } |
|
1291 else //if (imgReader.format() == "svg") |
|
1292 { |
|
1293 // Qt SVG plugin does not support QImageIOHandler::Size option, |
|
1294 // use QSvgRenderer to get the default size of the image instead. |
|
1295 QSvgRenderer svg(array); |
|
1296 imageSize = svg.defaultSize(); |
|
1297 } |
|
1298 |
|
1299 size = swtApp->jniUtils().NewJavaPoint( aJniEnv, QPoint(imageSize.width(), imageSize.height())); |
|
1300 |
|
1301 aJniEnv->ReleaseByteArrayElements(aData, data, JNI_ABORT); |
|
1302 } |
|
1303 GFX_CATCH |
|
1304 |
|
1305 return size; |
|
1306 } |
|
1307 // |
|
1308 // FontUtils |
|
1309 // |
|
1310 |
|
1311 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_fontUtils_1getAscent |
|
1312 (JNIEnv* aJniEnv , jclass, jint aFontHandle) |
|
1313 { |
|
1314 jint ascent = 0; |
|
1315 GFX_TRY |
|
1316 { |
|
1317 SWT_LOG_JNI_CALL(); |
|
1318 HANDLE_TO_POINTER(QFont*, font, aFontHandle); |
|
1319 QFontMetrics fm(*font); |
|
1320 ascent = static_cast<jint>( fm.ascent() ); |
|
1321 } |
|
1322 GFX_CATCH |
|
1323 return ascent; |
|
1324 } |
|
1325 |
|
1326 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_fontUtils_1getBoundingRect__I_3ILjava_lang_String_2 |
|
1327 (JNIEnv* aJniEnv, jclass, jint aFontHandle, jintArray aRectArray, jstring aStr) |
|
1328 { |
|
1329 GFX_TRY |
|
1330 { |
|
1331 SWT_LOG_JNI_CALL(); |
|
1332 QString string = swtApp->jniUtils().JavaStringToQString(aJniEnv, aStr); |
|
1333 |
|
1334 int length = aJniEnv->GetArrayLength(aRectArray); |
|
1335 |
|
1336 int* buffer = new int[length]; // might throw bad_alloc |
|
1337 AutoRelease<int> release(buffer, true); |
|
1338 ::memset(buffer, 0, sizeof(int)*length); |
|
1339 |
|
1340 HANDLE_TO_POINTER(QFont*, font, aFontHandle); |
|
1341 QFontMetrics fm(*font); |
|
1342 |
|
1343 buffer[0] = 0; |
|
1344 buffer[1] = 0; |
|
1345 buffer[2] = fm.width(string); |
|
1346 buffer[3] = fm.height(); |
|
1347 |
|
1348 // Copy changes to rectArray |
|
1349 swtApp->jniUtils().SetJavaIntArrayRegionFromIntArray(aJniEnv, aRectArray, 0, length, buffer); |
|
1350 } |
|
1351 GFX_CATCH |
|
1352 } |
|
1353 |
|
1354 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_fontUtils_1getBoundingRect__I_3ILjava_lang_String_2IIIIII |
|
1355 (JNIEnv* aJniEnv, jclass, jint aFontHandle, jintArray aRectArray, jstring aStr, jint /*aRectX*/, jint /*aRectY*/, jint /*aRectW*/, jint /*aRectH*/, jint /*aAlignments*/, jint /*aFlags*/) |
|
1356 { |
|
1357 GFX_TRY |
|
1358 { |
|
1359 SWT_LOG_JNI_CALL(); |
|
1360 QString string = swtApp->jniUtils().JavaStringToQString(aJniEnv, aStr); |
|
1361 int length = aJniEnv->GetArrayLength(aRectArray); |
|
1362 |
|
1363 int* buffer = new int[length]; // might throw bad_alloc |
|
1364 AutoRelease<int> release(buffer, true); |
|
1365 ::memset(buffer, 0, sizeof(int)*length); |
|
1366 |
|
1367 HANDLE_TO_POINTER(QFont*, font, aFontHandle); |
|
1368 QFontMetrics fm(*font); |
|
1369 |
|
1370 buffer[0] = 0; |
|
1371 buffer[1] = 0; |
|
1372 buffer[2] = fm.width(string); |
|
1373 buffer[3] = fm.height(); |
|
1374 |
|
1375 // Copy changes to rectArray |
|
1376 swtApp->jniUtils().SetJavaIntArrayRegionFromIntArray(aJniEnv, aRectArray, 0, length, buffer); |
|
1377 } |
|
1378 GFX_CATCH |
|
1379 } |
|
1380 |
|
1381 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_fontUtils_1getDescent |
|
1382 (JNIEnv* aJniEnv , jclass, jint aFontHandle) |
|
1383 { |
|
1384 jint descent = 0; |
|
1385 GFX_TRY |
|
1386 { |
|
1387 SWT_LOG_JNI_CALL(); |
|
1388 HANDLE_TO_POINTER(QFont*, font, aFontHandle); |
|
1389 QFontMetrics fm(*font); |
|
1390 descent = static_cast<jint>( fm.descent() ); |
|
1391 } |
|
1392 GFX_CATCH |
|
1393 return descent; |
|
1394 } |
|
1395 |
|
1396 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_fontUtils_1getStringWidth |
|
1397 (JNIEnv* aJniEnv , jclass, jint aFontHandle, jstring aStr) |
|
1398 { |
|
1399 int strWidth = 0; |
|
1400 GFX_TRY |
|
1401 { |
|
1402 SWT_LOG_JNI_CALL(); |
|
1403 HANDLE_TO_POINTER(QFont*, font, aFontHandle); |
|
1404 QString string = swtApp->jniUtils().JavaStringToQString(aJniEnv, aStr); |
|
1405 QFontMetrics fm(*font); |
|
1406 strWidth = fm.width(string); |
|
1407 } |
|
1408 GFX_CATCH |
|
1409 return static_cast<jint>(strWidth); |
|
1410 } |
|
1411 |
|
1412 // |
|
1413 // Buffer JNI calls |
|
1414 // |
|
1415 |
|
1416 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_buffer_1init |
|
1417 (JNIEnv* aJniEnv , jclass) |
|
1418 { |
|
1419 Buffer* buffer = 0; |
|
1420 GFX_TRY |
|
1421 { |
|
1422 SWT_LOG_JNI_CALL(); |
|
1423 buffer = GraphicsFactory::createBuffer(); |
|
1424 } |
|
1425 GFX_CATCH |
|
1426 return POINTER_TO_HANDLE(buffer); |
|
1427 } |
|
1428 |
|
1429 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_buffer_1dispose |
|
1430 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
1431 { |
|
1432 GFX_TRY |
|
1433 { |
|
1434 SWT_LOG_JNI_CALL(); |
|
1435 HANDLE_TO_POINTER(Buffer*, buffer, aHandle); |
|
1436 buffer->dispose(); |
|
1437 } |
|
1438 GFX_CATCH |
|
1439 } |
|
1440 |
|
1441 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_buffer_1getInvalidRect |
|
1442 (JNIEnv* aJniEnv, jclass, jint aHandle, jintArray aRect) |
|
1443 { |
|
1444 GFX_TRY |
|
1445 { |
|
1446 SWT_LOG_JNI_CALL(); |
|
1447 HANDLE_TO_POINTER(Buffer*, buffer, aHandle); |
|
1448 |
|
1449 int length = aJniEnv->GetArrayLength(aRect); |
|
1450 |
|
1451 int* intBuffer = new int[length]; // might throw bad_alloc |
|
1452 AutoRelease<int> release(intBuffer, true); |
|
1453 ::memset(intBuffer, 0, sizeof(int)*length); |
|
1454 |
|
1455 buffer->getInvalidRect(intBuffer); |
|
1456 |
|
1457 // Copy data back to java |
|
1458 swtApp->jniUtils().SetJavaIntArrayRegionFromIntArray(aJniEnv, aRect, 0, length, intBuffer); |
|
1459 } |
|
1460 GFX_CATCH |
|
1461 } |
|
1462 |
|
1463 // |
|
1464 // Windowsurface |
|
1465 // |
|
1466 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_windowsurface_1create |
|
1467 (JNIEnv* aJniEnv, jclass, jint aHandle, jboolean aAutoRefresh) |
|
1468 { |
|
1469 WindowSurface* surface = 0; |
|
1470 HANDLE_TO_POINTER(QWidget*, widget, aHandle); |
|
1471 GFX_TRY |
|
1472 { |
|
1473 SWT_LOG_JNI_CALL(); |
|
1474 surface = GraphicsFactory::createWindowSurface(widget, aAutoRefresh); |
|
1475 } |
|
1476 GFX_CATCH |
|
1477 |
|
1478 return POINTER_TO_HANDLE(surface); |
|
1479 } |
|
1480 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_windowsurface_1beginPaint |
|
1481 (JNIEnv* aJniEnv, jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight) |
|
1482 { |
|
1483 HANDLE_TO_POINTER(WindowSurface*, wsurf, aHandle); |
|
1484 GFX_TRY |
|
1485 { |
|
1486 SWT_LOG_JNI_CALL(); |
|
1487 wsurf->beginPaint(aX, aY, aWidth, aHeight); |
|
1488 } |
|
1489 GFX_CATCH |
|
1490 } |
|
1491 |
|
1492 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_windowsurface_1endPaint |
|
1493 (JNIEnv* aJniEnv, jclass, jint aHandle) |
|
1494 { |
|
1495 HANDLE_TO_POINTER(WindowSurface*, wsurf, aHandle); |
|
1496 GFX_TRY |
|
1497 { |
|
1498 SWT_LOG_JNI_CALL(); |
|
1499 wsurf->endPaint(); |
|
1500 } |
|
1501 GFX_CATCH |
|
1502 } |
|
1503 |
|
1504 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_windowsurface_1flush |
|
1505 (JNIEnv* aJniEnv, jclass, jint aHandle) |
|
1506 { |
|
1507 HANDLE_TO_POINTER(WindowSurface*, wsurf, aHandle); |
|
1508 GFX_TRY |
|
1509 { |
|
1510 SWT_LOG_JNI_CALL(); |
|
1511 wsurf->flush(); |
|
1512 } |
|
1513 GFX_CATCH |
|
1514 } |
|
1515 |
|
1516 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_windowsurface_1getType |
|
1517 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
1518 { |
|
1519 jint type = 0; |
|
1520 GFX_TRY |
|
1521 { |
|
1522 SWT_LOG_JNI_CALL(); |
|
1523 HANDLE_TO_POINTER(WindowSurface*, wsurf, aHandle); |
|
1524 type = static_cast<jint>( wsurf->getType() ); |
|
1525 } |
|
1526 GFX_CATCH |
|
1527 return type; |
|
1528 } |
|
1529 |
|
1530 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_windowsurface_1dispose |
|
1531 (JNIEnv* aJniEnv , jclass, jint aHandle) |
|
1532 { |
|
1533 GFX_TRY |
|
1534 { |
|
1535 SWT_LOG_JNI_CALL(); |
|
1536 HANDLE_TO_POINTER(WindowSurface*, wsurf, aHandle); |
|
1537 wsurf->dispose(); |
|
1538 } |
|
1539 GFX_CATCH |
|
1540 } |
|
1541 |
|
1542 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_windowsurface_1refresh |
|
1543 (JNIEnv* aJniEnv, jclass, jint aHandle) |
|
1544 { |
|
1545 GFX_TRY |
|
1546 { |
|
1547 SWT_LOG_JNI_CALL(); |
|
1548 HANDLE_TO_POINTER(WindowSurface*, wsurf, aHandle); |
|
1549 wsurf->refresh(); |
|
1550 } |
|
1551 GFX_CATCH |
|
1552 } |
|
1553 |
|
1554 void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_windowsurface_1handleSymbianWindowVisibilityChange |
|
1555 (JNIEnv* aJniEnv, jclass, jint aHandle, jboolean aVisible) |
|
1556 { |
|
1557 GFX_TRY |
|
1558 { |
|
1559 SWT_LOG_JNI_CALL(); |
|
1560 HANDLE_TO_POINTER(WindowSurface*, wsurf, aHandle); |
|
1561 wsurf->handleSymbianWindowVisibilityChange(aVisible); |
|
1562 } |
|
1563 GFX_CATCH |
|
1564 } |