2370N/A/*
3909N/A * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
2370N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2370N/A *
2370N/A * This code is free software; you can redistribute it and/or modify it
2370N/A * under the terms of the GNU General Public License version 2 only, as
2685N/A * published by the Free Software Foundation. Oracle designates this
2370N/A * particular file as subject to the "Classpath" exception as provided
2685N/A * by Oracle in the LICENSE file that accompanied this code.
2370N/A *
2370N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2370N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2370N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2370N/A * version 2 for more details (a copy is included in the LICENSE file that
2370N/A * accompanied this code).
2370N/A *
2370N/A * You should have received a copy of the GNU General Public License version
2370N/A * 2 along with this work; if not, write to the Free Software Foundation,
2370N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2370N/A *
2685N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2685N/A * or visit www.oracle.com if you need additional information or have any
2685N/A * questions.
2370N/A */
2370N/A
2370N/A#include "GraphicsPrimitiveMgr.h"
2370N/A#include "Region.h"
2370N/A#include "Trace.h"
2370N/A#include "X11SurfaceData.h"
2370N/A
2370N/A/*#include <xcb/xcb.h>*/
4632N/A#include <X11/extensions/Xrender.h>
2370N/A
2370N/A#ifndef RepeatNone /* added in 0.10 */
2370N/A#define RepeatNone 0
2370N/A#define RepeatNormal 1
2370N/A#define RepeatPad 2
2370N/A#define RepeatReflect 3
2370N/A#endif
2370N/A
2370N/A
2370N/A#include <sys/uio.h>
2370N/A#include <dlfcn.h>
2370N/A#include <setjmp.h>
2370N/A
2370N/A#ifndef HEADLESS
2370N/AjfieldID pictID;
2370N/AjfieldID xidID;
2370N/AjfieldID blitMaskPMID;
2370N/AjfieldID blitMaskPictID;
2370N/A#endif /* !HEADLESS */
2370N/A
2370N/AJNIEXPORT void JNICALL
2370N/A Java_sun_java2d_xr_XRSurfaceData_initXRPicture(JNIEnv *env, jobject xsd,
2370N/A jlong pXSData,
2370N/A jint pictFormat)
2370N/A{
2370N/A#ifndef HEADLESS
2370N/A
2370N/A X11SDOps *xsdo;
2370N/A XRenderPictFormat *fmt;
2370N/A
2370N/A J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initXRender");
2370N/A
2370N/A xsdo = (X11SDOps *) jlong_to_ptr(pXSData);
2370N/A if (xsdo == NULL) {
2370N/A return;
2370N/A }
2370N/A
2370N/A if (xsdo->xrPic == None) {
2370N/A XRenderPictureAttributes pict_attr;
2370N/A pict_attr.repeat = RepeatNone;
2370N/A fmt = XRenderFindStandardFormat(awt_display, pictFormat);
2370N/A xsdo->xrPic =
2370N/A XRenderCreatePicture(awt_display, xsdo->drawable, fmt,
2370N/A CPRepeat, &pict_attr);
2370N/A }
2370N/A
2370N/A (*env)->SetIntField (env, xsd, pictID, xsdo->xrPic);
2370N/A (*env)->SetIntField (env, xsd, xidID, xsdo->drawable);
2370N/A#endif /* !HEADLESS */
2370N/A}
2370N/A
2370N/AJNIEXPORT void JNICALL
2370N/AJava_sun_java2d_xr_XRSurfaceData_initIDs(JNIEnv *env, jclass xsd)
2370N/A{
2370N/A#ifndef HEADLESS
2370N/A J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initIDs");
2370N/A
2370N/A pictID = (*env)->GetFieldID(env, xsd, "picture", "I");
2370N/A xidID = (*env)->GetFieldID(env, xsd, "xid", "I");
2370N/A
2370N/A XShared_initIDs(env, JNI_FALSE);
2370N/A#endif /* !HEADLESS */
2370N/A}
2370N/A
2370N/A
2370N/AJNIEXPORT void JNICALL
2370N/AJava_sun_java2d_xr_XRSurfaceData_XRInitSurface(JNIEnv *env, jclass xsd,
2370N/A jint depth,
2370N/A jint width, jint height,
2370N/A jlong drawable, jint pictFormat)
2370N/A{
2370N/A#ifndef HEADLESS
2370N/A X11SDOps *xsdo;
2370N/A
2370N/A J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initSurface");
2370N/A
2370N/A xsdo = X11SurfaceData_GetOps(env, xsd);
2370N/A if (xsdo == NULL) {
2370N/A return;
2370N/A }
2370N/A
2370N/A XShared_initSurface(env, xsdo, depth, width, height, drawable);
2370N/A#endif /* !HEADLESS */
2370N/A}
3610N/A
3610N/A
3610N/A
3610N/AJNIEXPORT void JNICALL
3610N/AJava_sun_java2d_xr_XRSurfaceData_freeXSDOPicture(JNIEnv *env, jobject xsd,
3610N/A jlong pXSData)
3610N/A{
3610N/A#ifndef HEADLESS
3610N/A X11SDOps *xsdo;
3610N/A
3610N/A J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_freeXSDOPicture");
3610N/A
3610N/A xsdo = X11SurfaceData_GetOps(env, xsd);
3610N/A if (xsdo == NULL) {
3610N/A return;
3610N/A }
3610N/A
3610N/A if(xsdo->xrPic != None) {
3610N/A XRenderFreePicture(awt_display, xsdo->xrPic);
3610N/A xsdo->xrPic = None;
3610N/A }
3610N/A#endif /* !HEADLESS */
3610N/A}