|
1 /* |
|
2 * Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 #include "GraphicsPrimitiveMgr.h" |
|
27 #include "Region.h" |
|
28 #include "Trace.h" |
|
29 #include "X11SurfaceData.h" |
|
30 |
|
31 /*#include <xcb/xcb.h>*/ |
|
32 #include <Xrender.h> |
|
33 |
|
34 #ifndef RepeatNone /* added in 0.10 */ |
|
35 #define RepeatNone 0 |
|
36 #define RepeatNormal 1 |
|
37 #define RepeatPad 2 |
|
38 #define RepeatReflect 3 |
|
39 #endif |
|
40 |
|
41 |
|
42 #include <sys/uio.h> |
|
43 #include <dlfcn.h> |
|
44 #include <setjmp.h> |
|
45 |
|
46 #ifndef HEADLESS |
|
47 jfieldID pictID; |
|
48 jfieldID xidID; |
|
49 jfieldID blitMaskPMID; |
|
50 jfieldID blitMaskPictID; |
|
51 #endif /* !HEADLESS */ |
|
52 |
|
53 JNIEXPORT void JNICALL |
|
54 Java_sun_java2d_xr_XRSurfaceData_initXRPicture(JNIEnv *env, jobject xsd, |
|
55 jlong pXSData, |
|
56 jint pictFormat) |
|
57 { |
|
58 #ifndef HEADLESS |
|
59 |
|
60 X11SDOps *xsdo; |
|
61 XRenderPictFormat *fmt; |
|
62 |
|
63 J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initXRender"); |
|
64 |
|
65 xsdo = (X11SDOps *) jlong_to_ptr(pXSData); |
|
66 if (xsdo == NULL) { |
|
67 return; |
|
68 } |
|
69 |
|
70 if (xsdo->xrPic == None) { |
|
71 XRenderPictureAttributes pict_attr; |
|
72 pict_attr.repeat = RepeatNone; |
|
73 fmt = XRenderFindStandardFormat(awt_display, pictFormat); |
|
74 xsdo->xrPic = |
|
75 XRenderCreatePicture(awt_display, xsdo->drawable, fmt, |
|
76 CPRepeat, &pict_attr); |
|
77 } |
|
78 |
|
79 (*env)->SetIntField (env, xsd, pictID, xsdo->xrPic); |
|
80 (*env)->SetIntField (env, xsd, xidID, xsdo->drawable); |
|
81 #endif /* !HEADLESS */ |
|
82 } |
|
83 |
|
84 JNIEXPORT void JNICALL |
|
85 Java_sun_java2d_xr_XRSurfaceData_initIDs(JNIEnv *env, jclass xsd) |
|
86 { |
|
87 #ifndef HEADLESS |
|
88 J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initIDs"); |
|
89 |
|
90 pictID = (*env)->GetFieldID(env, xsd, "picture", "I"); |
|
91 xidID = (*env)->GetFieldID(env, xsd, "xid", "I"); |
|
92 |
|
93 XShared_initIDs(env, JNI_FALSE); |
|
94 #endif /* !HEADLESS */ |
|
95 } |
|
96 |
|
97 |
|
98 JNIEXPORT void JNICALL |
|
99 Java_sun_java2d_xr_XRSurfaceData_XRInitSurface(JNIEnv *env, jclass xsd, |
|
100 jint depth, |
|
101 jint width, jint height, |
|
102 jlong drawable, jint pictFormat) |
|
103 { |
|
104 #ifndef HEADLESS |
|
105 X11SDOps *xsdo; |
|
106 |
|
107 J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initSurface"); |
|
108 |
|
109 xsdo = X11SurfaceData_GetOps(env, xsd); |
|
110 if (xsdo == NULL) { |
|
111 return; |
|
112 } |
|
113 |
|
114 XShared_initSurface(env, xsdo, depth, width, height, drawable); |
|
115 #endif /* !HEADLESS */ |
|
116 } |