0N/A/*
2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#include "splashscreen_impl.h"
0N/A#include <jni.h>
0N/A#include <jlong_md.h>
6295N/A#include <sizecalc.h>
0N/A
0N/AJNIEXPORT jint JNICALL
0N/AJNI_OnLoad(JavaVM * vm, void *reserved)
0N/A{
0N/A return JNI_VERSION_1_2;
0N/A}
0N/A
0N/A/* FIXME: safe_ExceptionOccured, why and how? */
0N/A
0N/A/*
0N/A* Class: java_awt_SplashScreen
0N/A* Method: _update
0N/A* Signature: (J[IIIIII)V
0N/A*/
0N/AJNIEXPORT void JNICALL
0N/AJava_java_awt_SplashScreen__1update(JNIEnv * env, jclass thisClass,
0N/A jlong jsplash, jintArray data,
0N/A jint x, jint y, jint width, jint height,
0N/A jint stride)
0N/A{
0N/A Splash *splash = (Splash *) jlong_to_ptr(jsplash);
0N/A int dataSize;
0N/A
0N/A if (!splash) {
0N/A return;
0N/A }
0N/A SplashLock(splash);
0N/A dataSize = (*env)->GetArrayLength(env, data);
0N/A if (splash->overlayData) {
0N/A free(splash->overlayData);
0N/A }
6295N/A splash->overlayData = SAFE_SIZE_ARRAY_ALLOC(malloc, dataSize, sizeof(rgbquad_t));
0N/A if (splash->overlayData) {
0N/A /* we need a copy anyway, so we'll be using GetIntArrayRegion */
0N/A (*env)->GetIntArrayRegion(env, data, 0, dataSize,
0N/A (jint *) splash->overlayData);
0N/A initFormat(&splash->overlayFormat, 0xFF0000, 0xFF00, 0xFF, 0xFF000000);
0N/A initRect(&splash->overlayRect, x, y, width, height, 1,
0N/A stride * sizeof(rgbquad_t), splash->overlayData,
0N/A &splash->overlayFormat);
0N/A SplashUpdate(splash);
0N/A }
0N/A SplashUnlock(splash);
0N/A}
0N/A
0N/A
0N/A/*
0N/A* Class: java_awt_SplashScreen
0N/A* Method: _isVisible
0N/A* Signature: (J)Z
0N/A*/
0N/AJNIEXPORT jboolean JNICALL
0N/AJava_java_awt_SplashScreen__1isVisible(JNIEnv * env, jclass thisClass,
0N/A jlong jsplash)
0N/A{
0N/A Splash *splash = (Splash *) jlong_to_ptr(jsplash);
0N/A
0N/A if (!splash) {
0N/A return JNI_FALSE;
0N/A }
0N/A return splash->isVisible>0 ? JNI_TRUE : JNI_FALSE;
0N/A}
0N/A
0N/A/*
0N/A* Class: java_awt_SplashScreen
0N/A* Method: _getBounds
0N/A* Signature: (J)Ljava/awt/Rectangle;
0N/A*/
0N/AJNIEXPORT jobject JNICALL
0N/AJava_java_awt_SplashScreen__1getBounds(JNIEnv * env, jclass thisClass,
0N/A jlong jsplash)
0N/A{
0N/A Splash *splash = (Splash *) jlong_to_ptr(jsplash);
0N/A static jclass clazz = NULL;
0N/A static jmethodID mid = NULL;
0N/A jobject bounds = NULL;
0N/A
0N/A if (!splash) {
0N/A return NULL;
0N/A }
0N/A SplashLock(splash);
0N/A if (!clazz) {
0N/A clazz = (*env)->FindClass(env, "java/awt/Rectangle");
0N/A if (clazz) {
0N/A clazz = (*env)->NewGlobalRef(env, clazz);
0N/A }
0N/A }
0N/A if (clazz && !mid) {
0N/A mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
0N/A }
0N/A if (clazz && mid) {
0N/A bounds = (*env)->NewObject(env, clazz, mid, splash->x, splash->y,
0N/A splash->width, splash->height);
0N/A if ((*env)->ExceptionOccurred(env)) {
0N/A bounds = NULL;
0N/A (*env)->ExceptionDescribe(env);
0N/A (*env)->ExceptionClear(env);
0N/A }
0N/A }
0N/A SplashUnlock(splash);
0N/A return bounds;
0N/A}
0N/A
0N/A/*
0N/A* Class: java_awt_SplashScreen
0N/A* Method: _getInstance
0N/A* Signature: ()J
0N/A*/
0N/AJNIEXPORT jlong JNICALL
0N/AJava_java_awt_SplashScreen__1getInstance(JNIEnv * env, jclass thisClass)
0N/A{
0N/A return ptr_to_jlong(SplashGetInstance());
0N/A}
0N/A
0N/A/*
0N/A* Class: java_awt_SplashScreen
0N/A* Method: _close
0N/A* Signature: (J)V
0N/A*/
0N/AJNIEXPORT void JNICALL
0N/AJava_java_awt_SplashScreen__1close(JNIEnv * env, jclass thisClass,
0N/A jlong jsplash)
0N/A{
0N/A Splash *splash = (Splash *) jlong_to_ptr(jsplash);
0N/A
0N/A if (!splash) {
0N/A return;
0N/A }
0N/A SplashLock(splash);
0N/A SplashClosePlatform(splash);
0N/A SplashUnlock(splash);
0N/A}
0N/A
0N/A/*
0N/A * Class: java_awt_SplashScreen
0N/A * Method: _getImageFileName
0N/A * Signature: (J)Ljava/lang/String;
0N/A */
0N/AJNIEXPORT jstring JNICALL Java_java_awt_SplashScreen__1getImageFileName
0N/A (JNIEnv * env, jclass thisClass, jlong jsplash)
0N/A{
0N/A Splash *splash = (Splash *) jlong_to_ptr(jsplash);
0N/A
0N/A
0N/A if (!splash || !splash->fileName) {
0N/A return NULL;
0N/A }
0N/A /* splash->fileName is of type char*, but in fact it contains jchars */
0N/A return (*env)->NewString(env, (const jchar*)splash->fileName,
0N/A splash->fileNameLen);
0N/A}
0N/A
0N/A/*
0N/A * Class: java_awt_SplashScreen
0N/A * Method: _getImageJarName
0N/A * Signature: (J)Ljava/lang/String;
0N/A */
0N/AJNIEXPORT jstring JNICALL Java_java_awt_SplashScreen__1getImageJarName
0N/A (JNIEnv * env, jclass thisClass, jlong jsplash)
0N/A{
0N/A Splash *splash = (Splash *) jlong_to_ptr(jsplash);
0N/A
0N/A if (!splash || !splash->jarName) {
0N/A return NULL;
0N/A }
0N/A /* splash->jarName is of type char*, but in fact it contains jchars */
0N/A return (*env)->NewString(env, (const jchar*)splash->jarName,
0N/A splash->jarNameLen);
0N/A}
0N/A
0N/A/*
0N/A * Class: java_awt_SplashScreen
0N/A * Method: _setImageData
0N/A * Signature: (J[B)Z
0N/A */
0N/AJNIEXPORT jboolean JNICALL Java_java_awt_SplashScreen__1setImageData
0N/A (JNIEnv * env, jclass thisClass, jlong jsplash, jbyteArray data)
0N/A{
0N/A Splash *splash = (Splash *) jlong_to_ptr(jsplash);
0N/A int size, rc;
0N/A jbyte* pBytes;
0N/A
0N/A if (!splash) {
0N/A return JNI_FALSE;
0N/A }
0N/A size = (*env)->GetArrayLength(env, data);
0N/A pBytes = (*env)->GetByteArrayElements(env, data, NULL);
0N/A rc = SplashLoadMemory(pBytes, size);
0N/A (*env)->ReleaseByteArrayElements(env, data, pBytes, JNI_ABORT);
0N/A return rc ? JNI_TRUE : JNI_FALSE;
0N/A}