1 /*
2 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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.
24 */
25
26 #include "X11SurfaceData.h"
27 #include <jni.h>
28 #include <math.h>
29 #include "Region.h"
30 #include "fontscalerdefs.h"
31
32 #include <X11/extensions/Xrender.h>
33
34 #ifdef __linux__
35 #include <sys/utsname.h>
36 #endif
37
38 /* On Solaris 10 updates 8, 9, the render.h file defines these
39 * protocol values but does not define the structs in Xrender.h.
40 * Thus in order to get these always defined on Solaris 10
41 * we will undefine the symbols if we have determined via the
42 * makefiles that Xrender.h is lacking the structs. This will
43 * trigger providing our own definitions as on earlier updates.
44 * We could assume that *all* Solaris 10 update versions will lack the updated
45 * Xrender.h and do this based solely on O/S being any 5.10 version, but this
291 "artifacts can occur with old graphic drivers.\n"
292 "See the release notes for more details.\n");
293 fflush(stdout);
294 }
295 }
296 }
297 }
298 #endif // __linux__
299
300 return available;
301 }
302 /*
303 * Class: sun_awt_X11GraphicsEnvironment
304 * Method: initGLX
305 * Signature: ()Z
306 */
307 JNIEXPORT jboolean JNICALL
308 Java_sun_awt_X11GraphicsEnvironment_initXRender
309 (JNIEnv *env, jclass x11ge, jboolean verbose, jboolean ignoreLinuxVersion)
310 {
311 #ifndef HEADLESS
312 static jboolean xrenderAvailable = JNI_FALSE;
313 static jboolean firstTime = JNI_TRUE;
314
315 if (firstTime) {
316 #ifdef DISABLE_XRENDER_BY_DEFAULT
317 if (verbose == JNI_FALSE) {
318 xrenderAvailable = JNI_FALSE;
319 firstTime = JNI_FALSE;
320 return xrenderAvailable;
321 }
322 #endif
323 AWT_LOCK();
324 xrenderAvailable = IsXRenderAvailable(verbose, ignoreLinuxVersion);
325 AWT_UNLOCK();
326 firstTime = JNI_FALSE;
327 }
328 return xrenderAvailable;
329 #else
330 return JNI_FALSE;
331 #endif /* !HEADLESS */
332 }
333
334
335 JNIEXPORT void JNICALL
336 Java_sun_java2d_xr_XRBackendNative_initIDs(JNIEnv *env, jclass cls) {
337 char *maskData;
338 XImage* defaultImg;
339 jfieldID maskImgID;
340 jlong fmt8;
341 jlong fmt32;
342
343 jfieldID a8ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_A8", "J");
344 if (a8ID == NULL) {
345 return;
346 }
347 jfieldID argb32ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_ARGB32", "J");
348 if (argb32ID == NULL) {
349 return;
350 }
351
352 if (awt_display == (Display *)NULL) {
353 return;
|
1 /*
2 * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
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 *
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.
24 */
25
26 #ifdef HEADLESS
27 #error This file should not be included in headless library
28 #endif
29
30 #include "X11SurfaceData.h"
31 #include <jni.h>
32 #include <math.h>
33 #include "Region.h"
34 #include "fontscalerdefs.h"
35
36 #include <X11/extensions/Xrender.h>
37
38 #ifdef __linux__
39 #include <sys/utsname.h>
40 #endif
41
42 /* On Solaris 10 updates 8, 9, the render.h file defines these
43 * protocol values but does not define the structs in Xrender.h.
44 * Thus in order to get these always defined on Solaris 10
45 * we will undefine the symbols if we have determined via the
46 * makefiles that Xrender.h is lacking the structs. This will
47 * trigger providing our own definitions as on earlier updates.
48 * We could assume that *all* Solaris 10 update versions will lack the updated
49 * Xrender.h and do this based solely on O/S being any 5.10 version, but this
295 "artifacts can occur with old graphic drivers.\n"
296 "See the release notes for more details.\n");
297 fflush(stdout);
298 }
299 }
300 }
301 }
302 #endif // __linux__
303
304 return available;
305 }
306 /*
307 * Class: sun_awt_X11GraphicsEnvironment
308 * Method: initGLX
309 * Signature: ()Z
310 */
311 JNIEXPORT jboolean JNICALL
312 Java_sun_awt_X11GraphicsEnvironment_initXRender
313 (JNIEnv *env, jclass x11ge, jboolean verbose, jboolean ignoreLinuxVersion)
314 {
315 static jboolean xrenderAvailable = JNI_FALSE;
316 static jboolean firstTime = JNI_TRUE;
317
318 if (firstTime) {
319 #ifdef DISABLE_XRENDER_BY_DEFAULT
320 if (verbose == JNI_FALSE) {
321 xrenderAvailable = JNI_FALSE;
322 firstTime = JNI_FALSE;
323 return xrenderAvailable;
324 }
325 #endif
326 AWT_LOCK();
327 xrenderAvailable = IsXRenderAvailable(verbose, ignoreLinuxVersion);
328 AWT_UNLOCK();
329 firstTime = JNI_FALSE;
330 }
331 return xrenderAvailable;
332 }
333
334 JNIEXPORT void JNICALL
335 Java_sun_java2d_xr_XRBackendNative_initIDs(JNIEnv *env, jclass cls) {
336 char *maskData;
337 XImage* defaultImg;
338 jfieldID maskImgID;
339 jlong fmt8;
340 jlong fmt32;
341
342 jfieldID a8ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_A8", "J");
343 if (a8ID == NULL) {
344 return;
345 }
346 jfieldID argb32ID = (*env)->GetStaticFieldID(env, cls, "FMTPTR_ARGB32", "J");
347 if (argb32ID == NULL) {
348 return;
349 }
350
351 if (awt_display == (Display *)NULL) {
352 return;
|