Path: blob/master/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRSurfaceData.c
41159 views
/*1* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifdef HEADLESS26#error This file should not be included in headless library27#endif2829#include "GraphicsPrimitiveMgr.h"30#include "Region.h"31#include "Trace.h"32#include "X11SurfaceData.h"3334/*#include <xcb/xcb.h>*/35#include <X11/extensions/Xrender.h>3637#ifndef RepeatNone /* added in 0.10 */38#define RepeatNone 039#define RepeatNormal 140#define RepeatPad 241#define RepeatReflect 342#endif434445#include <sys/uio.h>46#include <dlfcn.h>47#include <setjmp.h>4849jfieldID pictID;50jfieldID xidID;51jfieldID blitMaskPMID;52jfieldID blitMaskPictID;5354JNIEXPORT void JNICALL55Java_sun_java2d_xr_XRSurfaceData_initXRPicture(JNIEnv *env, jobject xsd,56jlong pXSData,57jint pictFormat)58{59X11SDOps *xsdo;60XRenderPictFormat *fmt;6162J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initXRender");6364xsdo = (X11SDOps *) jlong_to_ptr(pXSData);65if (xsdo == NULL) {66return;67}6869if (xsdo->xrPic == None) {70XRenderPictureAttributes pict_attr;71pict_attr.repeat = RepeatNone;72fmt = XRenderFindStandardFormat(awt_display, pictFormat);73xsdo->xrPic =74XRenderCreatePicture(awt_display, xsdo->drawable, fmt,75CPRepeat, &pict_attr);76}7778(*env)->SetIntField (env, xsd, pictID, xsdo->xrPic);79(*env)->SetIntField (env, xsd, xidID, xsdo->drawable);80}8182JNIEXPORT void JNICALL83Java_sun_java2d_xr_XRSurfaceData_initIDs(JNIEnv *env, jclass xsd)84{85J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initIDs");8687pictID = (*env)->GetFieldID(env, xsd, "picture", "I");88if (pictID == NULL) {89return;90}91xidID = (*env)->GetFieldID(env, xsd, "xid", "I");92if (xidID == NULL) {93return;94}9596XShared_initIDs(env, JNI_FALSE);97}9899100JNIEXPORT void JNICALL101Java_sun_java2d_xr_XRSurfaceData_XRInitSurface(JNIEnv *env, jclass xsd,102jint depth,103jint width, jint height,104jlong drawable, jint pictFormat)105{106X11SDOps *xsdo;107108J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_initSurface");109110xsdo = X11SurfaceData_GetOps(env, xsd);111if (xsdo == NULL) {112return;113}114115XShared_initSurface(env, xsdo, depth, width, height, drawable);116}117118119120JNIEXPORT void JNICALL121Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture(JNIEnv *env, jobject xsd,122jlong pXSData)123{124X11SDOps *xsdo;125126J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_freeXSDOPicture");127128xsdo = X11SurfaceData_GetOps(env, xsd);129if (xsdo == NULL) {130return;131}132133if(xsdo->xrPic != None) {134XRenderFreePicture(awt_display, xsdo->xrPic);135xsdo->xrPic = None;136}137}138139140