|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "javax_microedition_m3g_Transformable.h" |
|
19 |
|
20 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1preRotate |
|
21 (JNIEnv* aEnv, jclass, jint aHandle, jfloat aAngle, jfloat aAx, jfloat aAy, jfloat aAz) |
|
22 { |
|
23 M3G_DO_LOCK |
|
24 m3gPreRotate((M3GTransformable)aHandle, aAngle, aAx, aAy, aAz); |
|
25 M3G_DO_UNLOCK(aEnv) |
|
26 } |
|
27 |
|
28 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getComposite |
|
29 (JNIEnv* aEnv, jclass, jint aHandle, jbyteArray aDstArray) |
|
30 { |
|
31 if (validateArray(aEnv, aDstArray, sizeof(M3GMatrix))) |
|
32 { |
|
33 jbyte* dstArray = aEnv->GetByteArrayElements(aDstArray, NULL); |
|
34 if (dstArray == NULL) |
|
35 { |
|
36 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
37 return; |
|
38 } |
|
39 |
|
40 M3G_DO_LOCK |
|
41 m3gGetCompositeTransform((M3GTransformable)aHandle, (M3GMatrix *)dstArray); |
|
42 M3G_DO_UNLOCK(aEnv) |
|
43 aEnv->ReleaseByteArrayElements(aDstArray, dstArray, 0); |
|
44 } |
|
45 } |
|
46 |
|
47 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1setTransform |
|
48 (JNIEnv* aEnv, jclass, jint aHandle, jbyteArray aSrcArray) |
|
49 { |
|
50 if (aSrcArray != NULL) |
|
51 { |
|
52 jbyte* srcArray = aEnv->GetByteArrayElements(aSrcArray, NULL); |
|
53 if (srcArray == NULL) |
|
54 { |
|
55 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
56 return; |
|
57 } |
|
58 M3G_DO_LOCK |
|
59 m3gSetTransform((M3GTransformable)aHandle, (const M3GMatrix *)srcArray); |
|
60 M3G_DO_UNLOCK(aEnv) |
|
61 aEnv->ReleaseByteArrayElements(aSrcArray, srcArray, JNI_ABORT); |
|
62 } |
|
63 else |
|
64 { |
|
65 M3G_DO_LOCK |
|
66 m3gSetTransform((M3GTransformable)aHandle, NULL); |
|
67 M3G_DO_UNLOCK(aEnv) |
|
68 } |
|
69 } |
|
70 |
|
71 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1setTranslation |
|
72 (JNIEnv* aEnv, jclass, jint aHandle, jfloat aTx, jfloat aTy, jfloat aTz, jboolean aAbsolute) |
|
73 { |
|
74 |
|
75 if (aAbsolute) |
|
76 { |
|
77 M3G_DO_LOCK |
|
78 m3gSetTranslation((M3GTransformable)aHandle, aTx, aTy, aTz); |
|
79 M3G_DO_UNLOCK(aEnv) |
|
80 } |
|
81 else |
|
82 { |
|
83 M3G_DO_LOCK |
|
84 m3gTranslate((M3GTransformable)aHandle, aTx, aTy, aTz); |
|
85 M3G_DO_UNLOCK(aEnv) |
|
86 } |
|
87 } |
|
88 |
|
89 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1setOrientation |
|
90 (JNIEnv* aEnv, jclass, jint aHandle, jfloat aAngle, jfloat aAx, jfloat aAy, jfloat aAz, jboolean aAbsolute) |
|
91 { |
|
92 |
|
93 if (aAbsolute) |
|
94 { |
|
95 M3G_DO_LOCK |
|
96 m3gSetOrientation((M3GTransformable)aHandle, aAngle, aAx, aAy, aAz); |
|
97 M3G_DO_UNLOCK(aEnv) |
|
98 } |
|
99 else |
|
100 { |
|
101 M3G_DO_LOCK |
|
102 m3gPostRotate((M3GTransformable)aHandle, aAngle, aAx, aAy, aAz); |
|
103 M3G_DO_UNLOCK(aEnv) |
|
104 } |
|
105 } |
|
106 |
|
107 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getTransform |
|
108 (JNIEnv* aEnv, jclass, jint aHandle, jbyteArray aDstArray) |
|
109 { |
|
110 if (validateArray(aEnv, aDstArray, sizeof(M3GMatrix))) |
|
111 { |
|
112 jbyte* dstArray = aEnv->GetByteArrayElements(aDstArray, NULL); |
|
113 if (dstArray == NULL) |
|
114 { |
|
115 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
116 return; |
|
117 } |
|
118 M3G_DO_LOCK |
|
119 m3gGetTransform((M3GTransformable)aHandle, (M3GMatrix *)dstArray); |
|
120 M3G_DO_UNLOCK(aEnv) |
|
121 aEnv->ReleaseByteArrayElements(aDstArray, dstArray, 0); |
|
122 } |
|
123 } |
|
124 |
|
125 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1setScale |
|
126 (JNIEnv* aEnv, jclass, jint aHandle, jfloat aSx, jfloat aSy, jfloat aSz, jboolean aAbsolute) |
|
127 { |
|
128 |
|
129 if (aAbsolute) |
|
130 { |
|
131 M3G_DO_LOCK |
|
132 m3gSetScale((M3GTransformable)aHandle, aSx, aSy, aSz); |
|
133 M3G_DO_UNLOCK(aEnv) |
|
134 } |
|
135 else |
|
136 { |
|
137 M3G_DO_LOCK |
|
138 m3gScale((M3GTransformable)aHandle, aSx, aSy, aSz); |
|
139 M3G_DO_UNLOCK(aEnv) |
|
140 } |
|
141 } |
|
142 |
|
143 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getTranslation |
|
144 (JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aDstArray) |
|
145 { |
|
146 if (validateArray(aEnv, (jbyteArray)aDstArray, 3)) |
|
147 { |
|
148 jfloat* dstArray = aEnv->GetFloatArrayElements(aDstArray, NULL); |
|
149 if (dstArray == NULL) |
|
150 { |
|
151 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
152 return; |
|
153 } |
|
154 M3G_DO_LOCK |
|
155 m3gGetTranslation((M3GTransformable)aHandle, (M3Gfloat*)dstArray); |
|
156 M3G_DO_UNLOCK(aEnv) |
|
157 aEnv->ReleaseFloatArrayElements(aDstArray, dstArray, 0); |
|
158 } |
|
159 } |
|
160 |
|
161 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getScale |
|
162 (JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aDstArray) |
|
163 { |
|
164 if (validateArray(aEnv, (jbyteArray)aDstArray, 3)) |
|
165 { |
|
166 jfloat* dstArray = aEnv->GetFloatArrayElements(aDstArray, NULL); |
|
167 if (dstArray == NULL) |
|
168 { |
|
169 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
170 return; |
|
171 } |
|
172 M3G_DO_LOCK |
|
173 m3gGetScale((M3GTransformable)aHandle, (M3Gfloat*)dstArray); |
|
174 M3G_DO_UNLOCK(aEnv) |
|
175 aEnv->ReleaseFloatArrayElements(aDstArray, dstArray, 0); |
|
176 } |
|
177 } |
|
178 |
|
179 JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getOrientation |
|
180 (JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aDstArray) |
|
181 { |
|
182 if (validateArray(aEnv, (jbyteArray)aDstArray, 4)) |
|
183 { |
|
184 jfloat* dstArray = aEnv->GetFloatArrayElements(aDstArray, NULL); |
|
185 if (dstArray == NULL) |
|
186 { |
|
187 M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); |
|
188 return; |
|
189 } |
|
190 M3G_DO_LOCK |
|
191 m3gGetOrientation((M3GTransformable)aHandle, (M3Gfloat*)dstArray); |
|
192 M3G_DO_UNLOCK(aEnv) |
|
193 aEnv->ReleaseFloatArrayElements(aDstArray, dstArray, 0); |
|
194 } |
|
195 } |