author | ihse |
Wed, 18 Apr 2018 14:22:53 +0200 | |
branch | ihse-jdk-library-branch |
changeset 56454 | 82c3ae69914f |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
56454 | 2 |
* Copyright (c) 2005, 2018, 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> |
56454 | 31 |
#include "java_awt_SplashScreen.h" |
2 | 32 |
|
33 |
JNIEXPORT jint JNICALL |
|
33653
c1ee09fe3274
8136556: Add the ability to perform static builds of MacOSX x64 binaries
bobv
parents:
32427
diff
changeset
|
34 |
DEF_JNI_OnLoad(JavaVM * vm, void *reserved) |
2 | 35 |
{ |
36 |
return JNI_VERSION_1_2; |
|
37 |
} |
|
38 |
||
39 |
/* FIXME: safe_ExceptionOccured, why and how? */ |
|
40 |
||
41 |
/* |
|
42 |
* Class: java_awt_SplashScreen |
|
43 |
* Method: _update |
|
44 |
* Signature: (J[IIIIII)V |
|
45 |
*/ |
|
46 |
JNIEXPORT void JNICALL |
|
47 |
Java_java_awt_SplashScreen__1update(JNIEnv * env, jclass thisClass, |
|
48 |
jlong jsplash, jintArray data, |
|
49 |
jint x, jint y, jint width, jint height, |
|
50 |
jint stride) |
|
51 |
{ |
|
52 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
53 |
int dataSize; |
|
54 |
||
55 |
if (!splash) { |
|
56 |
return; |
|
57 |
} |
|
58 |
SplashLock(splash); |
|
59 |
dataSize = (*env)->GetArrayLength(env, data); |
|
60 |
if (splash->overlayData) { |
|
61 |
free(splash->overlayData); |
|
62 |
} |
|
18232 | 63 |
splash->overlayData = SAFE_SIZE_ARRAY_ALLOC(malloc, dataSize, sizeof(rgbquad_t)); |
2 | 64 |
if (splash->overlayData) { |
65 |
/* we need a copy anyway, so we'll be using GetIntArrayRegion */ |
|
66 |
(*env)->GetIntArrayRegion(env, data, 0, dataSize, |
|
67 |
(jint *) splash->overlayData); |
|
68 |
initFormat(&splash->overlayFormat, 0xFF0000, 0xFF00, 0xFF, 0xFF000000); |
|
69 |
initRect(&splash->overlayRect, x, y, width, height, 1, |
|
70 |
stride * sizeof(rgbquad_t), splash->overlayData, |
|
71 |
&splash->overlayFormat); |
|
72 |
SplashUpdate(splash); |
|
73 |
} |
|
74 |
SplashUnlock(splash); |
|
75 |
} |
|
76 |
||
77 |
||
78 |
/* |
|
79 |
* Class: java_awt_SplashScreen |
|
80 |
* Method: _isVisible |
|
81 |
* Signature: (J)Z |
|
82 |
*/ |
|
83 |
JNIEXPORT jboolean JNICALL |
|
84 |
Java_java_awt_SplashScreen__1isVisible(JNIEnv * env, jclass thisClass, |
|
85 |
jlong jsplash) |
|
86 |
{ |
|
87 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
88 |
||
89 |
if (!splash) { |
|
90 |
return JNI_FALSE; |
|
91 |
} |
|
92 |
return splash->isVisible>0 ? JNI_TRUE : JNI_FALSE; |
|
93 |
} |
|
94 |
||
95 |
/* |
|
96 |
* Class: java_awt_SplashScreen |
|
97 |
* Method: _getBounds |
|
98 |
* Signature: (J)Ljava/awt/Rectangle; |
|
99 |
*/ |
|
100 |
JNIEXPORT jobject JNICALL |
|
101 |
Java_java_awt_SplashScreen__1getBounds(JNIEnv * env, jclass thisClass, |
|
102 |
jlong jsplash) |
|
103 |
{ |
|
104 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
105 |
static jclass clazz = NULL; |
|
106 |
static jmethodID mid = NULL; |
|
107 |
jobject bounds = NULL; |
|
108 |
||
109 |
if (!splash) { |
|
110 |
return NULL; |
|
111 |
} |
|
112 |
SplashLock(splash); |
|
113 |
if (!clazz) { |
|
114 |
clazz = (*env)->FindClass(env, "java/awt/Rectangle"); |
|
115 |
if (clazz) { |
|
116 |
clazz = (*env)->NewGlobalRef(env, clazz); |
|
117 |
} |
|
118 |
} |
|
119 |
if (clazz && !mid) { |
|
120 |
mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V"); |
|
121 |
} |
|
122 |
if (clazz && mid) { |
|
123 |
bounds = (*env)->NewObject(env, clazz, mid, splash->x, splash->y, |
|
124 |
splash->width, splash->height); |
|
125 |
if ((*env)->ExceptionOccurred(env)) { |
|
126 |
bounds = NULL; |
|
127 |
(*env)->ExceptionDescribe(env); |
|
128 |
(*env)->ExceptionClear(env); |
|
129 |
} |
|
130 |
} |
|
131 |
SplashUnlock(splash); |
|
132 |
return bounds; |
|
133 |
} |
|
134 |
||
135 |
/* |
|
136 |
* Class: java_awt_SplashScreen |
|
137 |
* Method: _getInstance |
|
138 |
* Signature: ()J |
|
139 |
*/ |
|
140 |
JNIEXPORT jlong JNICALL |
|
141 |
Java_java_awt_SplashScreen__1getInstance(JNIEnv * env, jclass thisClass) |
|
142 |
{ |
|
143 |
return ptr_to_jlong(SplashGetInstance()); |
|
144 |
} |
|
145 |
||
146 |
/* |
|
147 |
* Class: java_awt_SplashScreen |
|
148 |
* Method: _close |
|
149 |
* Signature: (J)V |
|
150 |
*/ |
|
151 |
JNIEXPORT void JNICALL |
|
152 |
Java_java_awt_SplashScreen__1close(JNIEnv * env, jclass thisClass, |
|
153 |
jlong jsplash) |
|
154 |
{ |
|
155 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
156 |
||
157 |
if (!splash) { |
|
158 |
return; |
|
159 |
} |
|
160 |
SplashLock(splash); |
|
161 |
SplashClosePlatform(splash); |
|
162 |
SplashUnlock(splash); |
|
163 |
} |
|
164 |
||
165 |
/* |
|
166 |
* Class: java_awt_SplashScreen |
|
167 |
* Method: _getImageFileName |
|
168 |
* Signature: (J)Ljava/lang/String; |
|
169 |
*/ |
|
170 |
JNIEXPORT jstring JNICALL Java_java_awt_SplashScreen__1getImageFileName |
|
171 |
(JNIEnv * env, jclass thisClass, jlong jsplash) |
|
172 |
{ |
|
173 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
174 |
||
175 |
||
176 |
if (!splash || !splash->fileName) { |
|
177 |
return NULL; |
|
178 |
} |
|
179 |
/* splash->fileName is of type char*, but in fact it contains jchars */ |
|
180 |
return (*env)->NewString(env, (const jchar*)splash->fileName, |
|
181 |
splash->fileNameLen); |
|
182 |
} |
|
183 |
||
184 |
/* |
|
185 |
* Class: java_awt_SplashScreen |
|
186 |
* Method: _getImageJarName |
|
187 |
* Signature: (J)Ljava/lang/String; |
|
188 |
*/ |
|
189 |
JNIEXPORT jstring JNICALL Java_java_awt_SplashScreen__1getImageJarName |
|
190 |
(JNIEnv * env, jclass thisClass, jlong jsplash) |
|
191 |
{ |
|
192 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
193 |
||
194 |
if (!splash || !splash->jarName) { |
|
195 |
return NULL; |
|
196 |
} |
|
197 |
/* splash->jarName is of type char*, but in fact it contains jchars */ |
|
198 |
return (*env)->NewString(env, (const jchar*)splash->jarName, |
|
199 |
splash->jarNameLen); |
|
200 |
} |
|
201 |
||
202 |
/* |
|
203 |
* Class: java_awt_SplashScreen |
|
204 |
* Method: _setImageData |
|
205 |
* Signature: (J[B)Z |
|
206 |
*/ |
|
207 |
JNIEXPORT jboolean JNICALL Java_java_awt_SplashScreen__1setImageData |
|
208 |
(JNIEnv * env, jclass thisClass, jlong jsplash, jbyteArray data) |
|
209 |
{ |
|
210 |
Splash *splash = (Splash *) jlong_to_ptr(jsplash); |
|
211 |
int size, rc; |
|
212 |
jbyte* pBytes; |
|
213 |
||
214 |
if (!splash) { |
|
215 |
return JNI_FALSE; |
|
216 |
} |
|
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
|
217 |
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
|
218 |
CHECK_NULL_RETURN(pBytes, JNI_FALSE); |
2 | 219 |
size = (*env)->GetArrayLength(env, data); |
220 |
rc = SplashLoadMemory(pBytes, size); |
|
221 |
(*env)->ReleaseByteArrayElements(env, data, pBytes, JNI_ABORT); |
|
222 |
return rc ? JNI_TRUE : JNI_FALSE; |
|
223 |
} |
|
25552
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 |
/* |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
226 |
* Class: java_awt_SplashScreen |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
227 |
* Method: _getScaleFactor |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
228 |
* Signature: (J)F |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
229 |
*/ |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
230 |
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
|
231 |
(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
|
232 |
{ |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
233 |
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
|
234 |
if (!splash) { |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
235 |
return 1; |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
236 |
} |
96abb01815f6
8043869: [macosx] java -splash does not honor @2x hi dpi notation for retina support
alexsch
parents:
23328
diff
changeset
|
237 |
return splash->scaleFactor; |
32427
c22b7e41adf3
8134984: Text files should end in exactly one newline
martin
parents:
25859
diff
changeset
|
238 |
} |