0N/A/*
3909N/A * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#include "SurfaceData.h"
0N/A
0N/A#include "awt_p.h"
0N/A#include "awt_GraphicsEnv.h"
0N/A
0N/A#include <jdga.h>
0N/A
2370N/A#include <X11/extensions/Xrender.h>
2370N/A
0N/A/**
0N/A * This include file contains support declarations for loops using the
0N/A * X11 extended SurfaceData interface to talk to an X11 drawable from
0N/A * native code.
0N/A */
0N/A
0N/A#ifdef HEADLESS
0N/A#define X11SDOps void
0N/A#else /* HEADLESS */
0N/Atypedef struct _X11SDOps X11SDOps;
0N/A
0N/A/*
0N/A * This function returns an X11 Drawable which transparent pixels
0N/A * (if there are any) were set to the specified color.
0N/A *
0N/A * The env parameter should be the JNIEnv of the surrounding JNI context.
0N/A *
0N/A * The xsdo parameter should be a pointer to the ops object upon which
0N/A * this function is being invoked.
0N/A *
0N/A * The pixel parameter should be a color to which the transparent
0N/A * pixels of the image should be se set to.
0N/A */
0N/Atypedef Drawable GetPixmapBgFunc(JNIEnv *env,
0N/A X11SDOps *xsdo,
0N/A jint pixel);
0N/A
0N/A/*
0N/A * This function releases the lock set by GetPixmapBg
0N/A * function of the indicated X11SDOps structure.
0N/A *
0N/A * The env parameter should be the JNIEnv of the surrounding JNI context.
0N/A *
0N/A * The ops parameter should be a pointer to the ops object upon which
0N/A * this function is being invoked.
0N/A */
0N/Atypedef void ReleasePixmapBgFunc(JNIEnv *env,
0N/A X11SDOps *xsdo);
0N/A
0N/A
0N/A#ifdef MITSHM
0N/Atypedef struct {
0N/A XShmSegmentInfo *shmSegInfo; /* Shared Memory Segment Info */
0N/A jint bytesPerLine; /* needed for ShMem lock */
0N/A jboolean xRequestSent; /* true if x request is sent w/o XSync */
0N/A jint pmSize;
0N/A
0N/A jboolean usingShmPixmap;
0N/A Drawable pixmap;
0N/A Drawable shmPixmap;
0N/A jint numBltsSinceRead;
0N/A jint pixelsReadSinceBlt;
0N/A jint pixelsReadThreshold;
0N/A jint numBltsThreshold;
0N/A} ShmPixmapData;
0N/A#endif /* MITSHM */
0N/A
0N/Astruct _X11SDOps {
0N/A SurfaceDataOps sdOps;
0N/A GetPixmapBgFunc *GetPixmapWithBg;
0N/A ReleasePixmapBgFunc *ReleasePixmapWithBg;
0N/A jboolean invalid;
0N/A jboolean isPixmap;
0N/A jobject peer;
0N/A Drawable drawable;
0N/A Widget widget;
0N/A GC javaGC; /* used for Java-level GC validation */
0N/A GC cachedGC; /* cached for use in X11SD_Unlock() */
0N/A jint depth;
0N/A jint pixelmask;
0N/A JDgaSurfaceInfo surfInfo;
0N/A AwtGraphicsConfigData *configData;
0N/A ColorData *cData;
0N/A jboolean dgaAvailable;
0N/A void *dgaDev;
0N/A Pixmap bitmask;
0N/A jint bgPixel; /* bg pixel for the pixmap */
0N/A jboolean isBgInitialized; /* whether the bg pixel is valid */
0N/A jint pmWidth; /* width, height of the */
0N/A jint pmHeight; /* pixmap */
2370N/A Picture xrPic;
0N/A#ifdef MITSHM
0N/A ShmPixmapData shmPMData; /* data for switching between shm/nonshm pixmaps*/
0N/A#endif /* MITSHM */
0N/A};
0N/A
0N/A#define X11SD_LOCK_UNLOCKED 0 /* surface is not locked */
0N/A#define X11SD_LOCK_BY_NULL 1 /* surface locked for NOP */
0N/A#define X11SD_LOCK_BY_XIMAGE 2 /* surface locked by Get/PutImage */
0N/A#define X11SD_LOCK_BY_DGA 3 /* surface locked by DGA */
0N/A#define X11SD_LOCK_BY_SHMEM 4 /* surface locked by ShMemExt */
0N/A
0N/A#ifdef MITSHM
3539N/AXImage * X11SD_GetSharedImage (X11SDOps *xsdo,
3539N/A jint width, jint height,
3539N/A jint maxWidth, jint maxHeight,
3539N/A jboolean readBits);
0N/AXImage * X11SD_CreateSharedImage (X11SDOps *xsdo, jint width, jint height);
0N/ADrawable X11SD_CreateSharedPixmap (X11SDOps *xsdo);
0N/Avoid X11SD_DropSharedSegment (XShmSegmentInfo *shminfo);
0N/Avoid X11SD_PuntPixmap (X11SDOps *xsdo, jint width, jint height);
0N/Avoid X11SD_UnPuntPixmap (X11SDOps *xsdo);
3539N/Ajboolean X11SD_CachedXImageFits (jint width, jint height,
3539N/A jint maxWidth, jint maxHeight,
3539N/A jint depth, jboolean readBits);
0N/AXImage * X11SD_GetCachedXImage (jint width, jint height, jboolean readBits);
0N/A#endif /* MITSHM */
3539N/Ajint X11SD_InitWindow(JNIEnv *env, X11SDOps *xsdo);
0N/Avoid X11SD_DisposeOrCacheXImage (XImage * image);
0N/Avoid X11SD_DisposeXImage(XImage * image);
0N/Avoid X11SD_DirectRenderNotify(JNIEnv *env, X11SDOps *xsdo);
0N/A#endif /* !HEADLESS */
0N/A
2370N/Ajboolean XShared_initIDs(JNIEnv *env, jboolean allowShmPixmaps);
2370N/Ajboolean XShared_initSurface(JNIEnv *env, X11SDOps *xsdo, jint depth, jint width, jint height, jlong drawable);
2370N/A
0N/A/*
0N/A * This function returns a pointer to a native X11SDOps structure
0N/A * for accessing the indicated X11 SurfaceData Java object. It
0N/A * verifies that the indicated SurfaceData object is an instance
0N/A * of X11SurfaceData before returning and will return NULL if the
0N/A * wrong SurfaceData object is being accessed. This function will
0N/A * throw the appropriate Java exception if it returns NULL so that
0N/A * the caller can simply return.
0N/A *
0N/A * Note to callers:
0N/A * This function uses JNI methods so it is important that the
0N/A * caller not have any outstanding GetPrimitiveArrayCritical or
0N/A * GetStringCritical locks which have not been released.
0N/A *
0N/A * The caller may continue to use JNI methods after this method
0N/A * is called since this function will not leave any outstanding
0N/A * JNI Critical locks unreleased.
0N/A */
0N/AJNIEXPORT X11SDOps * JNICALL
0N/AX11SurfaceData_GetOps(JNIEnv *env, jobject sData);