1 | /* |
2 | * Copyright (c) 2010, 2013, 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 "GraphicsPrimitiveMgr.h" |
27 | #include "Region.h" |
28 | #include "Trace.h" |
29 | #include "X11SurfaceData.h" |
30 | |
31 | /*#include <xcb/xcb.h>*/ |
32 | #include <X11/extensions/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 | if (pictID == NULL) { |
92 | return; |
93 | } |
94 | xidID = (*env)->GetFieldID(env, xsd, "xid" , "I" ); |
95 | if (xidID == NULL) { |
96 | return; |
97 | } |
98 | |
99 | XShared_initIDs(env, JNI_FALSE); |
100 | #endif /* !HEADLESS */ |
101 | } |
102 | |
103 | |
104 | JNIEXPORT void JNICALL |
105 | Java_sun_java2d_xr_XRSurfaceData_XRInitSurface(JNIEnv *env, jclass xsd, |
106 | jint depth, |
107 | jint width, jint height, |
108 | jlong drawable, jint pictFormat) |
109 | { |
110 | #ifndef HEADLESS |
111 | X11SDOps *xsdo; |
112 | |
113 | J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initSurface" ); |
114 | |
115 | xsdo = X11SurfaceData_GetOps(env, xsd); |
116 | if (xsdo == NULL) { |
117 | return; |
118 | } |
119 | |
120 | XShared_initSurface(env, xsdo, depth, width, height, drawable); |
121 | #endif /* !HEADLESS */ |
122 | } |
123 | |
124 | |
125 | |
126 | JNIEXPORT void JNICALL |
127 | Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture(JNIEnv *env, jobject xsd, |
128 | jlong pXSData) |
129 | { |
130 | #ifndef HEADLESS |
131 | X11SDOps *xsdo; |
132 | |
133 | J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_freeXSDOPicture" ); |
134 | |
135 | xsdo = X11SurfaceData_GetOps(env, xsd); |
136 | if (xsdo == NULL) { |
137 | return; |
138 | } |
139 | |
140 | if(xsdo->xrPic != None) { |
141 | XRenderFreePicture(awt_display, xsdo->xrPic); |
142 | xsdo->xrPic = None; |
143 | } |
144 | #endif /* !HEADLESS */ |
145 | } |
146 | |