jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 8356 64c792dbf671
child 11103 e156ce2c4a96
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8356
diff changeset
     2
 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "SurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "awt_p.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "awt_GraphicsEnv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include <jdga.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
    33
#include <X11/extensions/Xrender.h>
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
    34
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * This include file contains support declarations for loops using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * X11 extended SurfaceData interface to talk to an X11 drawable from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * native code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#ifdef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#define X11SDOps void
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#else /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
typedef struct _X11SDOps X11SDOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * This function returns an X11 Drawable which transparent pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * (if there are any) were set to the specified color.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * The env parameter should be the JNIEnv of the surrounding JNI context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * The xsdo parameter should be a pointer to the ops object upon which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * this function is being invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * The pixel parameter should be a color to which the transparent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * pixels of the image should be se set to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
typedef Drawable GetPixmapBgFunc(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                                 X11SDOps *xsdo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                                 jint pixel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * This function releases the lock set by GetPixmapBg
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * function of the indicated X11SDOps structure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * The env parameter should be the JNIEnv of the surrounding JNI context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * The ops parameter should be a pointer to the ops object upon which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * this function is being invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
typedef void ReleasePixmapBgFunc(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                                 X11SDOps *xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
typedef struct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    XShmSegmentInfo     *shmSegInfo;    /* Shared Memory Segment Info */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    jint                bytesPerLine;   /* needed for ShMem lock */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    jboolean            xRequestSent;   /* true if x request is sent w/o XSync */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    jint                pmSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    jboolean            usingShmPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    Drawable            pixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    Drawable            shmPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    jint                numBltsSinceRead;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    jint                pixelsReadSinceBlt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    jint                pixelsReadThreshold;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    jint                numBltsThreshold;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
} ShmPixmapData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
struct _X11SDOps {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    SurfaceDataOps      sdOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    GetPixmapBgFunc     *GetPixmapWithBg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    ReleasePixmapBgFunc *ReleasePixmapWithBg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    jboolean            invalid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    jboolean            isPixmap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    jobject             peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    Drawable            drawable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    Widget              widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    GC                  javaGC;        /* used for Java-level GC validation */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    GC                  cachedGC;      /* cached for use in X11SD_Unlock() */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    jint                depth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    jint                pixelmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    JDgaSurfaceInfo     surfInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    AwtGraphicsConfigData *configData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    ColorData           *cData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    jboolean            dgaAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    void                *dgaDev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    Pixmap              bitmask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    jint                bgPixel;       /* bg pixel for the pixmap */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    jboolean            isBgInitialized; /* whether the bg pixel is valid */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    jint                pmWidth;       /* width, height of the */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    jint                pmHeight;      /* pixmap */
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
   115
    Picture             xrPic;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
#ifdef MITSHM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    ShmPixmapData       shmPMData;     /* data for switching between shm/nonshm pixmaps*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
#endif /* MITSHM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
#define X11SD_LOCK_UNLOCKED     0       /* surface is not locked */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
#define X11SD_LOCK_BY_NULL      1       /* surface locked for NOP */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
#define X11SD_LOCK_BY_XIMAGE    2       /* surface locked by Get/PutImage */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
#define X11SD_LOCK_BY_DGA       3       /* surface locked by DGA */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#define X11SD_LOCK_BY_SHMEM     4       /* surface locked by ShMemExt */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
#ifdef MITSHM
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   128
XImage * X11SD_GetSharedImage       (X11SDOps *xsdo,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   129
                                     jint width, jint height,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   130
                                     jint maxWidth, jint maxHeight,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   131
                                     jboolean readBits);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
XImage * X11SD_CreateSharedImage    (X11SDOps *xsdo, jint width, jint height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
Drawable X11SD_CreateSharedPixmap   (X11SDOps *xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
void     X11SD_DropSharedSegment    (XShmSegmentInfo *shminfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
void     X11SD_PuntPixmap           (X11SDOps *xsdo, jint width, jint height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
void     X11SD_UnPuntPixmap         (X11SDOps *xsdo);
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   137
jboolean X11SD_CachedXImageFits     (jint width, jint height,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   138
                                     jint maxWidth, jint maxHeight,
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   139
                                     jint depth, jboolean readBits);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
XImage * X11SD_GetCachedXImage      (jint width, jint height, jboolean readBits);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
#endif /* MITSHM */
8356
64c792dbf671 7018364: XShmGetImage with image's > drawable's size causes BadMatch
prr
parents: 7668
diff changeset
   142
jint     X11SD_InitWindow(JNIEnv *env, X11SDOps *xsdo);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
void     X11SD_DisposeOrCacheXImage (XImage * image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
void     X11SD_DisposeXImage(XImage * image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
void     X11SD_DirectRenderNotify(JNIEnv *env, X11SDOps *xsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
5579
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
   148
jboolean XShared_initIDs(JNIEnv *env, jboolean allowShmPixmaps);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
   149
jboolean XShared_initSurface(JNIEnv *env, X11SDOps *xsdo, jint depth, jint width, jint height, jlong drawable);
1a5e995a710b 6307603: [X11] Use RENDER extension for complex operations done in software
ceisserer
parents: 2
diff changeset
   150
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * This function returns a pointer to a native X11SDOps structure
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * for accessing the indicated X11 SurfaceData Java object.  It
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * verifies that the indicated SurfaceData object is an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * of X11SurfaceData before returning and will return NULL if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * wrong SurfaceData object is being accessed.  This function will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * throw the appropriate Java exception if it returns NULL so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * the caller can simply return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * Note to callers:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *      This function uses JNI methods so it is important that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 *      caller not have any outstanding GetPrimitiveArrayCritical or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 *      GetStringCritical locks which have not been released.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 *      The caller may continue to use JNI methods after this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 *      is called since this function will not leave any outstanding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 *      JNI Critical locks unreleased.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
JNIEXPORT X11SDOps * JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
X11SurfaceData_GetOps(JNIEnv *env, jobject sData);