author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 33653 | jdk/src/java.desktop/share/native/libsplashscreen/java_awt_SplashScreen.c@c1ee09fe3274 |
child 50471 | f0aeede1b855 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32427
diff
changeset
|
2 |
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include "splashscreen_impl.h" |
|
23320
fa1a77a296fc
8033573: [parfait] warning from b128 for share/native/sun/awt/splashscreen/java_awt_SplashScreen.c: JNI exception pending
serb
parents:
18232
diff
changeset
|
27 |
#include <jlong_md.h> |
2 | 28 |
#include <jni.h> |
23320
fa1a77a296fc
8033573: [parfait] warning from b128 for share/native/sun/awt/splashscreen/java_awt_SplashScreen.c: JNI exception pending
serb
parents:
18232
diff
changeset
|
29 |
#include <jni_util.h> |
18232 | 30 |
#include <sizecalc.h> |
2 | 31 |
|
32 |
JNIEXPORT jint JNICALL |
|
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32427
diff
changeset
|
33 |
DEF_JNI_OnLoad(JavaVM * vm, void *reserved) |
2 | 34 |
{ |
35 |
return JNI_VERSION_1_2; |
|
36 |
} |
|
37 |
||
38 |
/* FIXME: safe_ExceptionOccured, why and how? */ |
|
39 |
||
40 |
/* |
|
41 |
* Class: java_awt_SplashScreen |
|
42 |
* Method: _update |
|
43 |
* Signature: (J[IIIIII)V |
|
44 |
*/ |
|
45 |
JNIEXPORT void JNICALL |
|
46 |
Java_java_awt_SplashScreen__1update(JNIEnv * env, jclass thisClass, |
|
47 |
jlong jsplash, jintArray data, |
|
48 |
jint x, jint y, jint width, jint height, |
|
49 |
jint stride) |
|
50 |
{ |
|
51 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
52 |
int dataSize; |
|
53 |
||
54 |
if (!splash) { |
|
55 |
return; |
|
56 |
} |
|
57 |
SplashLock(splash); |
|
58 |
dataSize = (*env)->GetArrayLength(env, data); |
|
59 |
if (splash->overlayData) { |
|
60 |
free(splash->overlayData); |
|
61 |
} |
|
18232 | 62 |
splash->overlayData = SAFE_SIZE_ARRAY_ALLOC(malloc, dataSize, sizeof(rgbquad_t)); |
2 | 63 |
if (splash->overlayData) { |
64 |
/* we need a copy anyway, so we'll be using GetIntArrayRegion */ |
|
65 |
(*env)->GetIntArrayRegion(env, data, 0, dataSize, |
|
66 |
(jint *) splash->overlayData); |
|
67 |
initFormat(&splash->overlayFormat, 0xFF0000, 0xFF00, 0xFF, 0xFF000000); |
|
68 |
initRect(&splash->overlayRect, x, y, width, height, 1, |
|
69 |
stride * sizeof(rgbquad_t), splash->overlayData, |
|
70 |
&splash->overlayFormat); |
|
71 |
SplashUpdate(splash); |
|
72 |
} |
|
73 |
SplashUnlock(splash); |
|
74 |
} |
|
75 |
||
76 |
||
77 |
/* |
|
78 |
* Class: java_awt_SplashScreen |
|
79 |
* Method: _isVisible |
|
80 |
* Signature: (J)Z |
|
81 |
*/ |
|
82 |
JNIEXPORT jboolean JNICALL |
|
83 |
Java_java_awt_SplashScreen__1isVisible(JNIEnv * env, jclass thisClass, |
|
84 |
jlong jsplash) |
|
85 |
{ |
|
86 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
87 |
||
88 |
if (!splash) { |
|
89 |
return JNI_FALSE; |
|
90 |
} |
|
91 |
return splash->isVisible>0 ? JNI_TRUE : JNI_FALSE; |
|
92 |
} |
|
93 |
||
94 |
/* |
|
95 |
* Class: java_awt_SplashScreen |
|
96 |
* Method: _getBounds |
|
97 |
* Signature: (J)Ljava/awt/Rectangle; |
|
98 |
*/ |
|
99 |
JNIEXPORT jobject JNICALL |
|
100 |
Java_java_awt_SplashScreen__1getBounds(JNIEnv * env, jclass thisClass, |
|
101 |
jlong jsplash) |
|
102 |
{ |
|
103 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
104 |
static jclass clazz = NULL; |
|
105 |
static jmethodID mid = NULL; |
|
106 |
jobject bounds = NULL; |
|
107 |
||
108 |
if (!splash) { |
|
109 |
return NULL; |
|
110 |
} |
|
111 |
SplashLock(splash); |
|
112 |
if (!clazz) { |
|
113 |
clazz = (*env)->FindClass(env, "java/awt/Rectangle"); |
|
114 |
if (clazz) { |
|
115 |
clazz = (*env)->NewGlobalRef(env, clazz); |
|
116 |
} |
|
117 |
} |
|
118 |
if (clazz && !mid) { |
|
119 |
mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V"); |
|
120 |
} |
|
121 |
if (clazz && mid) { |
|
122 |
bounds = (*env)->NewObject(env, clazz, mid, splash->x, splash->y, |
|
123 |
splash->width, splash->height); |
|
124 |
if ((*env)->ExceptionOccurred(env)) { |
|
125 |
bounds = NULL; |
|
126 |
(*env)->ExceptionDescribe(env); |
|
127 |
(*env)->ExceptionClear(env); |
|
128 |
} |
|
129 |
} |
|
130 |
SplashUnlock(splash); |
|
131 |
return bounds; |
|
132 |
} |
|
133 |
||
134 |
/* |
|
135 |
* Class: java_awt_SplashScreen |
|
136 |
* Method: _getInstance |
|
137 |
* Signature: ()J |
|
138 |
*/ |
|
139 |
JNIEXPORT jlong JNICALL |
|
140 |
Java_java_awt_SplashScreen__1getInstance(JNIEnv * env, jclass thisClass) |
|
141 |
{ |
|
142 |
return ptr_to_jlong(SplashGetInstance()); |
|
143 |
} |
|
144 |
||
145 |
/* |
|
146 |
* Class: java_awt_SplashScreen |
|
147 |
* Method: _close |
|
148 |
* Signature: (J)V |
|
149 |
*/ |
|
150 |
JNIEXPORT void JNICALL |
|
151 |
Java_java_awt_SplashScreen__1close(JNIEnv * env, jclass thisClass, |
|
152 |
jlong jsplash) |
|
153 |
{ |
|
154 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
155 |
||
156 |
if (!splash) { |
|
157 |
return; |
|
158 |
} |
|
159 |
SplashLock(splash); |
|
160 |
SplashClosePlatform(splash); |
|
161 |
SplashUnlock(splash); |
|
162 |
} |
|
163 |
||
164 |
/* |
|
165 |
* Class: java_awt_SplashScreen |
|
166 |
* Method: _getImageFileName |
|
167 |
* Signature: (J)Ljava/lang/String; |
|
168 |
*/ |
|
169 |
JNIEXPORT jstring JNICALL Java_java_awt_SplashScreen__1getImageFileName |
|
170 |
(JNIEnv * env, jclass thisClass, jlong jsplash) |
|
171 |
{ |
|
172 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
173 |
||
174 |
||
175 |
if (!splash || !splash->fileName) { |
|
176 |
return NULL; |
|
177 |
} |
|
178 |
/* splash->fileName is of type char*, but in fact it contains jchars */ |
|
179 |
return (*env)->NewString(env, (const jchar*)splash->fileName, |
|
180 |
splash->fileNameLen); |
|
181 |
} |
|
182 |
||
183 |
/* |
|
184 |
* Class: java_awt_SplashScreen |
|
185 |
* Method: _getImageJarName |
|
186 |
* Signature: (J)Ljava/lang/String; |
|
187 |
*/ |
|
188 |
JNIEXPORT jstring JNICALL Java_java_awt_SplashScreen__1getImageJarName |
|
189 |
(JNIEnv * env, jclass thisClass, jlong jsplash) |
|
190 |
{ |
|
191 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
192 |
||
193 |
if (!splash || !splash->jarName) { |
|
194 |
return NULL; |
|
195 |
} |
|
196 |
/* splash->jarName is of type char*, but in fact it contains jchars */ |
|
197 |
return (*env)->NewString(env, (const jchar*)splash->jarName, |
|
198 |
splash->jarNameLen); |
|
199 |
} |
|
200 |
||
201 |
/* |
|
202 |
* Class: java_awt_SplashScreen |
|
203 |
* Method: _setImageData |
|
204 |
* Signature: (J[B)Z |
|
205 |
*/ |
|
206 |
JNIEXPORT jboolean JNICALL Java_java_awt_SplashScreen__1setImageData |
|
207 |
(JNIEnv * env, jclass thisClass, jlong jsplash, jbyteArray data) |
|
208 |
{ |
|
209 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
210 |
int size, rc; |
|
211 |
jbyte* pBytes; |
|
212 |
||
213 |
if (!splash) { |
|
214 |
return JNI_FALSE; |
|
215 |
} |
|
23320
fa1a77a296fc
8033573: [parfait] warning from b128 for share/native/sun/awt/splashscreen/java_awt_SplashScreen.c: JNI exception pending
serb
parents:
18232
diff
changeset
|
216 |
pBytes = (*env)->GetByteArrayElements(env, data, NULL); |
fa1a77a296fc
8033573: [parfait] warning from b128 for share/native/sun/awt/splashscreen/java_awt_SplashScreen.c: JNI exception pending
serb
parents:
18232
diff
changeset
|
217 |
CHECK_NULL_RETURN(pBytes, JNI_FALSE); |
2 | 218 |
size = (*env)->GetArrayLength(env, data); |
219 |
rc = SplashLoadMemory(pBytes, size); |
|
220 |
(*env)->ReleaseByteArrayElements(env, data, pBytes, JNI_ABORT); |
|
221 |
return rc ? JNI_TRUE : JNI_FALSE; |
|
222 |
} |
|
25552
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
223 |
|
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
224 |
/* |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
225 |
* Class: java_awt_SplashScreen |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
226 |
* Method: _getScaleFactor |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
227 |
* Signature: (J)F |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
228 |
*/ |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
229 |
JNIEXPORT jfloat JNICALL Java_java_awt_SplashScreen__1getScaleFactor |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
230 |
(JNIEnv *env, jclass thisClass, jlong jsplash) |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
231 |
{ |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
232 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
233 |
if (!splash) { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
234 |
return 1; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
235 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
236 |
return splash->scaleFactor; |
32427
c22b7e41adf3
8134984: Text files should end in exactly one newline
martin
parents:
25859
diff
changeset
|
237 |
} |