Path: blob/master/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h
41159 views
/*1* Copyright (c) 2000, 2011, 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#include "SurfaceData.h"2627#include "awt_p.h"28#include "awt_GraphicsEnv.h"2930#ifdef HEADLESS31#include "GLXGraphicsConfig.h"32#endif3334#include <X11/extensions/Xrender.h>3536/**37* This include file contains support declarations for loops using the38* X11 extended SurfaceData interface to talk to an X11 drawable from39* native code.40*/4142#ifdef HEADLESS43#define X11SDOps void44#else /* HEADLESS */45typedef struct _X11SDOps X11SDOps;4647/*48* This function returns an X11 Drawable which transparent pixels49* (if there are any) were set to the specified color.50*51* The env parameter should be the JNIEnv of the surrounding JNI context.52*53* The xsdo parameter should be a pointer to the ops object upon which54* this function is being invoked.55*56* The pixel parameter should be a color to which the transparent57* pixels of the image should be se set to.58*/59typedef Drawable GetPixmapBgFunc(JNIEnv *env,60X11SDOps *xsdo,61jint pixel);6263/*64* This function releases the lock set by GetPixmapBg65* function of the indicated X11SDOps structure.66*67* The env parameter should be the JNIEnv of the surrounding JNI context.68*69* The ops parameter should be a pointer to the ops object upon which70* this function is being invoked.71*/72typedef void ReleasePixmapBgFunc(JNIEnv *env,73X11SDOps *xsdo);747576#ifdef MITSHM77typedef struct {78XShmSegmentInfo *shmSegInfo; /* Shared Memory Segment Info */79jint bytesPerLine; /* needed for ShMem lock */80jboolean xRequestSent; /* true if x request is sent w/o XSync */81jlong pmSize;8283jboolean usingShmPixmap;84Drawable pixmap;85Drawable shmPixmap;86jint numBltsSinceRead;87jint pixelsReadSinceBlt;88jint pixelsReadThreshold;89jint numBltsThreshold;90} ShmPixmapData;91#endif /* MITSHM */9293struct _X11SDOps {94SurfaceDataOps sdOps;95GetPixmapBgFunc *GetPixmapWithBg;96ReleasePixmapBgFunc *ReleasePixmapWithBg;97jboolean invalid;98jboolean isPixmap;99jobject peer;100Drawable drawable;101GC javaGC; /* used for Java-level GC validation */102GC cachedGC; /* cached for use in X11SD_Unlock() */103jint depth;104jint pixelmask;105AwtGraphicsConfigData *configData;106ColorData *cData;107Pixmap bitmask;108jint bgPixel; /* bg pixel for the pixmap */109jboolean isBgInitialized; /* whether the bg pixel is valid */110jint pmWidth; /* width, height of the */111jint pmHeight; /* pixmap */112Picture xrPic;113#ifdef MITSHM114ShmPixmapData shmPMData; /* data for switching between shm/nonshm pixmaps*/115#endif /* MITSHM */116};117118#define X11SD_LOCK_UNLOCKED 0 /* surface is not locked */119#define X11SD_LOCK_BY_NULL 1 /* surface locked for NOP */120#define X11SD_LOCK_BY_XIMAGE 2 /* surface locked by Get/PutImage */121#define X11SD_LOCK_BY_SHMEM 4 /* surface locked by ShMemExt */122123#ifdef MITSHM124XImage * X11SD_GetSharedImage (X11SDOps *xsdo,125jint width, jint height,126jint maxWidth, jint maxHeight,127jboolean readBits);128XImage * X11SD_CreateSharedImage (X11SDOps *xsdo, jint width, jint height);129Drawable X11SD_CreateSharedPixmap (X11SDOps *xsdo);130void X11SD_DropSharedSegment (XShmSegmentInfo *shminfo);131void X11SD_PuntPixmap (X11SDOps *xsdo, jint width, jint height);132void X11SD_UnPuntPixmap (X11SDOps *xsdo);133jboolean X11SD_CachedXImageFits (jint width, jint height,134jint maxWidth, jint maxHeight,135jint depth, jboolean readBits);136XImage * X11SD_GetCachedXImage (jint width, jint height, jboolean readBits);137#endif /* MITSHM */138jint X11SD_InitWindow(JNIEnv *env, X11SDOps *xsdo);139void X11SD_DisposeOrCacheXImage (XImage * image);140void X11SD_DisposeXImage(XImage * image);141void X11SD_DirectRenderNotify(JNIEnv *env, X11SDOps *xsdo);142#endif /* !HEADLESS */143144jboolean XShared_initIDs(JNIEnv *env, jboolean allowShmPixmaps);145jboolean XShared_initSurface(JNIEnv *env, X11SDOps *xsdo, jint depth, jint width, jint height, jlong drawable);146147/*148* This function returns a pointer to a native X11SDOps structure149* for accessing the indicated X11 SurfaceData Java object. It150* verifies that the indicated SurfaceData object is an instance151* of X11SurfaceData before returning and will return NULL if the152* wrong SurfaceData object is being accessed. This function will153* throw the appropriate Java exception if it returns NULL so that154* the caller can simply return.155*156* Note to callers:157* This function uses JNI methods so it is important that the158* caller not have any outstanding GetPrimitiveArrayCritical or159* GetStringCritical locks which have not been released.160*161* The caller may continue to use JNI methods after this method162* is called since this function will not leave any outstanding163* JNI Critical locks unreleased.164*/165JNIEXPORT X11SDOps * JNICALL166X11SurfaceData_GetOps(JNIEnv *env, jobject sData);167168169